禁用页面滚动直到页面加载 - JQuery [英] Disable page scroll until page loads - JQuery
问题描述
我为客户网站构建了一个视差滚动介绍 - 该网站包含许多高分辨率图像 - 所以我创建了一个快速加载器,用全屏高z-index div消隐屏幕,然后使用setTimeout方法在文档准备好后4秒钟淡入页面(不确定这是否是最好的方法,但它在我尝试过的每个测试中都有效)。
I have built a parallax scrolling intro for a clients website - the site contains many high res images - so I have created a quick loader which blanks out the screen with a full screen high z-index div and then uses the setTimeout method to fade in the page 4 seconds after document ready (not sure if this is the best way to do this but it works in every test I've tried).
I想要禁用滚动以防止用户在动画出现之前滚动动画 - 任何人都可以推荐一个好的跨浏览器方法来执行此操作吗?
I would like to disable the scroll to prevent users scrolling through the animation before it appears -can anyone recommend a good cross-browser method to do this?
推荐答案
如果要在加载所有图像时淡入,可以试试这个
If you want to fade in when all images are loaded, you can try this
var images = $('img');
var images_nbr = images.length;
images.load(function() {
images_nbr--;
if (images_nbr == 0) {
$('body').css('overflow','auto');
$('...').fadeIn();
}
});
这篇关于禁用页面滚动直到页面加载 - JQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!