2017-03-16 35 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

我嘗試過,但仍然不能很好地工作......無論如何,你的回答讓我走上了一條好路!希望我能解決它! –