移动设备jQuery上的视差滚动

时间:2014-05-07 14:00:06

标签: jquery mobile

如何让这种视差滚动在移动设备上运行?它适用于所有浏览器,但不适用于带触摸屏的移动设备。

// scoll images    
$(document).ready(function(){
    $('div[data-type="background"]').each(function(){
        var $bgobj = $(this); // assigning the object

        $(window).scroll(function() {
            var yPos = -($window.scrollTop() / $bgobj.data('speed')); 

            // Put together our final background position
            var coords = '50% '+ yPos + 'px';

            // Move the background
            $bgobj.css({ backgroundPosition: coords });
        }); 
    });    
});

0 个答案:

没有答案
相关问题