此代码显示5张幻灯片相互显示的图片。
它们都是静态定位和重叠。
这种方式当他们被切换时,他们互相展示。
在firefox中完美运行,但不适用于chrome或safari。
有人能解释为什么吗?
提前致谢
var curPhoto = 6;
var scrollAmountUp = 0;
var scrollAmountDown = 0;
$(function(){
//last scroll will always save the current scroll position value
var CurrentScroll = 0;
$(window).scroll(function(event){
console.log('Event triggered');
var NextScroll = $(this).scrollTop();
if (NextScroll > CurrentScroll){
//Scrolling Down
scrollAmountUp = 0;
scrollAmountDown++
if(scrollAmountDown > 12){
curPhoto--;
console.log('Setting next photo:' + curPhoto);
scrollAmountDown = 0;
//Change Photo
$('#swift-slider-' + curPhoto).slideToggle("900");
if(curPhoto == 2){
window.scrollTo(0, document.body.scrollHeight);
}
}
}
else {
//Scrolling up
scrollAmountDown = 0;
scrollAmountUp++;
if(scrollAmountUp > 12){
console.log('Setting prev photo:' + curPhoto);
scrollAmountUp = 0;
//Change Photo
$('#swift-slider-' + curPhoto).slideToggle("900");
curPhoto++;
if(curPhoto == 6){
window.scrollTo(0, 0);
}
}
}
//Updates current scroll position
CurrentScroll = NextScroll;
}); });