From a6b949e31a4c511f25dcf7f0fc0dda2bab862739 Mon Sep 17 00:00:00 2001 From: Victor Häggqvist Date: Wed, 13 Jan 2016 17:05:44 +0100 Subject: basic working click on image --- src/CSSUtil.js | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/CSSUtil.js (limited to 'src/CSSUtil.js') diff --git a/src/CSSUtil.js b/src/CSSUtil.js new file mode 100644 index 0000000..f08a0da --- /dev/null +++ b/src/CSSUtil.js @@ -0,0 +1,55 @@ +/** + * Created by Victor Häggqvist on 1/12/16. + */ + +export class CSSUtil { + + /** + * transion need to be set on property + * + * using key-value dont work + * + * @param ele + * @param value + */ + static setTransitionProperty(ele, value) { + if (ele.transition === '') { + ele.transition = value; + return; + } + if (ele.WebkitTransition === '') { + ele.WebkitTransition = value; + return; + } + if (ele.MozTransition === '') { + ele.MozTransition = value; + return; + } + if (ele.OTransition === '') { + ele.OTransition = value; + } + } + + static cssTransitionSupport() { + let d = document.body || document.documentElement, s = d.style; + if (s.WebkitTransition === '') + return '-webkit-'; + if (s.MozTransition === '') + return '-moz-'; + if (s.OTransition === '') + return '-o-'; + if (s.transition === '') + return ''; + return false; + } + + static cssTransitionTranslateX(element, positionX, speed) { + let options = {}; + let prefix = CSSUtil.cssTransitionSupport(); + element.style[prefix + 'transform'] = 'translateX(' + positionX + ')'; + element.style[prefix + 'transition'] = prefix + 'transform ' + speed + 's linear'; + //element.style = Object.assign(options, element.style); + } + +} +CSSUtil.isCssTransitionSupport = CSSUtil.cssTransitionSupport() !== false; -- cgit v1.2.3