查看第一个链接的源代码,它似乎使用一个主要的 JQuery 插件来处理滚动事件 - Parallax。http://stephband.info/jparallax/。这允许开发人员设置页面不同部分相对于正常滚动事件的滚动速度。以下代码是第一个链接的摘录,它应该为正在发生的事情提供一些上下文。
$(document).ready(function(){
//.parallax(xPosition, speedFactor, outerHeight) options:
//xPosition - Horizontal position of the element
//inertia - speed to move relative to vertical scroll. Example: 0.1 is one tenth the speed of scrolling, 2 is twice the speed of scrolling
//outerHeight (true/false) - Whether or not jQuery should use it's outerHeight option to determine when a section is in the viewport
$('#first').parallax("25%", 0.1);
$('.ft1-small-1-bg').parallax("75%", 0.4);
$('.ft1-small-2-bg').parallax("75%", 0.2);
$('#second').parallax("25%", 0.1);
$('.ft2-small-1-bg').parallax("100%", 0.4);
$('.ft2-small-2-bg').parallax("100%", 0.2);
$('#third').parallax("50%", 0.3);
$('.ft3-small-1-bg').parallax("100%", 0.4);
$('.ft3-small-2-bg').parallax("100%", 0.2);
$('#fourth').parallax("50%", 0.3);
$('.ft4-small-1-bg').parallax("10%", 0.4);
$('.ft4-small-2-bg').parallax("10%", 0.2);
$('.ft4-small-3-bg').parallax("110%", 0.2);
$('.ft4-small-4-bg').parallax("110%", 0.2);
$('.tabs-menu a').fttabs();
var viewportHeight = screen.height;
var headerHeight = $('.fulltoss-header').outerHeight();
var vheight = viewportHeight-headerHeight;
$('#fourth.page').height(vheight);
$('#fourth .story').css('height',vheight);
$('#fourth .story').css('min-height',vheight);
$('#fourth .story').css('overflow','hidden');
$('.ft4-small-1-bg, .ft4-small-2-bg, .ft4-small-3-bg, .ft4-small-4- bg').height(vheight);
});
来源 - http://www.espncricinfo.com/navigation/zones/fulltoss/main.js?10