2017-03-16 37 views
-3

我知道可能我有错误的东西!但是什么?动画jQuery不写正确的CSS属性

$(".page-splash-page").bind("mousewheel DOMMouseScroll", function(){ 
    $(this).animate({ 
     -webkit-animation: slide-out-top 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both, 
     -moz-animation: slide-out-top 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both, 
     animation: slide-out-top 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both, 
      }, 1000, function() { 
       { window.location.href = "http:..../work/"; } 
      }); 
    }); 
$(".page-splash-page").on("click touchstart", function() { 
    $(this).animate({ 
     -webkit-animation: slide-out-top 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both, 
     -moz-animation: slide-out-top 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both, 
     animation: slide-out-top 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both, 
      }, 1000, function() { 
       { window.location.href = "http:...../work/"; } 
      }); 
    }); 
$(".page-splash-page").on("touchmove", function() { 
    $(this).animate({ 
     -webkit-animation: slide-out-top 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both, 
     -moz-animation: slide-out-top 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both, 
     animation: slide-out-top 0.5s cubic-bezier(0.550, 0.085, 0.680, 0.530) both, 
      }, 1000, function() { 
       { window.location.href = "http:..../work/"; } 
      }); 
    }); 

对不起,我希望这个功能可以工作,但我不是那么专业的js或jQuery! 有些可以帮助我!谢谢!

+0

动画的'animation' ????这只是错误的只是添加一个新的类与该动画,然后超时去window.location – DaniP

+0

http://stackoverflow.com/help/how-to-ask –

+0

对于初学者,你应该看看开发控制台对于错误。 – Pango

回答

1

那么首先你要混合jQuery动画和CSS动画。

我在这里添加了一个简单的笔,它可以点击-500px来为页面上的飞溅页添加动画。希望这可以帮助你开始:

http://codepen.io/anon/pen/MpOabq

$(".page-splash-page").on("click", function() { 
$(this).animate({ 
    top:'-500px', 
     }, 1000, function() { 
      { window.location.href = 'http://www.google.com' } 
     }); 
}); 
+0

嗨@mrsq,首先谢谢你,你的代码在我改变了元素在Relative中的位置后工作。但有线的动画是动画不稳定,不平滑,它以三个步骤移动......你知道为什么吗? –

+0

它可能是mousewheel,DOMMouseScroll,touchmove,touchstart事件互相干扰。你可以把所有这些都留下,只是尝试点击事件本身。 – mrsq

+0

我尝试过,但仍然不能很好地工作......无论如何,你的回答让我走上了一条好路!希望我能解决它! –