webkit transition syntax in javascript?

前端 未结 5 1028
借酒劲吻你
借酒劲吻你 2021-01-19 03:34

I\'m looking for the webkitTransition object reference here

 function spawnAnimation(what){
    //sets the moving element
    var moveingEl = document.getEl         


        
相关标签:
5条回答
  • 2021-01-19 04:02

    Use style.setProperty.

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

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

    0 讨论(0)
  • 2021-01-19 04:03

    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);​
    
    0 讨论(0)
  • 2021-01-19 04:13
    <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>
    
    0 讨论(0)
  • 2021-01-19 04:17

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

    $(moveingEl).css('-webkit-transform', 'translateX(200px)');
    
    0 讨论(0)
  • 2021-01-19 04:18

    You can use:

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

    0 讨论(0)
提交回复
热议问题