2011-11-02 65 views
0

我在另一個網站上看到了這個,當你向下滾動頁面(垂直)時,它會觸發一個動畫,一個圓圈旋轉到位。我怎樣才能扭轉這一所以動畫觸發,當我水平滾動從Y軸到X軸的反轉腳本功能

$(document).ready(function() { 

    $(window).scroll(function(e) { 
     var top = $(document).scrollTop(); 
     var wHeight = Math.max(640,$(window).height()); 

     if (top < wHeight) { 
      //$('.bg').css('top',70+top/2); 
      $('.bg .maze').css({ 
       '-webkit-transform':'rotate('+top+'deg)', 
       '-moz-transform':'rotate('+top+'deg)', 
       '-o-transform':'rotate('+top+'deg)', 
       '-ms-transform':'rotate('+top+'deg)', 
       'transform':'rotate('+top+'deg)' 
      }); 
     } 
    }); 

}); 
+0

試着思考它。也許而不是scrollTop,你應該採用scrollLeft屬性。 – TJHeuvel

+0

感謝這個新的現在得到它 – Marcus

回答

1

你必須使用jQuery::scrollLeft()代替jQuery::scrollTop(),並將其與窗口寬度:

var left = $(document).scrollLeft(); 
var wWidth = Math.max(640,$(window).width()); 

if (left < wWidth) { /* ... */ } 
+0

非常感謝你現在似乎很明顯,真的很感激它! – Marcus