webkit transition syntax in javascript?

半城伤御伤魂 提交于 2019-12-01 18:15:25

Use style.setProperty.

moveingEl.style.setProperty("-webkit-transition", "left 5s linear");

moveingEl.style.setProperty("left", "200px");

http://jsfiddle.net/7b4VZ/3/

Allow 1ms for the rendered to get the thread back.

setTimeout(function() {
    myElement.style.height = '200px'; /* or whatever css changes you want to do */
}, 1);​

You can use:

element.style.webkitTransition = "set your transition up here"

captainclam

I know it's a workaround, but can you use jQuery?

$(moveingEl).css('-webkit-transform', 'translateX(200px)');
<script>
        $(document).ready(function(){

                var x = 100;
                var y = 0;
            setInterval(function(){
                x += 1;
                y += 1;
                var element = document.getElementById('cube');
                element.style.webkitTransform = "translateZ(-100px) rotateY("+x+"deg) rotateX("+y+"deg)"; //for safari and chrome
                element.style.MozTransform = "translateZ(-100px) rotateY("+x+"deg) rotateX("+y+"deg)"; //for firefox
            },50);
            //for other browsers use:   "msTransform",    "OTransform",    "transform"

        });
    </script>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!