谷歌+和Javascript - 选择圆圈时禁用滚动?
我创建了很多圈子。因此,当我将鼠标悬停在“添加到圈子”google plus 按钮上时,会弹出一个小 div,允许我垂直滚动我的圈子。
真正酷的部分是它禁用身体滚动。因此,当我滚动到圆圈查看器的底部时,身体不会移动。
这怎么可能用 JavaScript 实现呢?
(我找到了一种奇怪的方法来做到这一点:
$('body').css({'overflow':'hidden'});
$(document).bind('scroll',function () {
window.scrollTo(0,0);
});
但谷歌做得更好。主体滚动条保持在原位(它不会像我的代码那样消失),并且主体仍然不可滚动......)
重要的是要注意(到目前为止被忽视)正文页面上的滚动条必须保持在原位。它不能像溢出:隐藏那样消失,因为这会将所有页面内容猛拉到右侧。 Google 以某种方式解决了这个问题...
屏幕截图:
I've created a lot of Circles. And so when I hover over the "Add to Circles" google plus button, a small div pops up that allows me to vertically scroll through my circles.
The really cool part is that it disable body scrolling. So when I scroll to the bottom of the circles viewer, the body doesn't budge.
How is this possible with javascript?
(I've found a hacky way to do it:
$('body').css({'overflow':'hidden'});
$(document).bind('scroll',function () {
window.scrollTo(0,0);
});
But Google does it better. The body scroll bar stays in place (it doesn't vanish like my code makes it), and the body is still unscrollable...)
It's important to note (and so far overlooked) that the scroll bar on the body page has to stay in place. It can't vanish like overflow:hidden makes it, because that jerks all of the page content to the right. Google solves this problem somehow...
SCREENSHOT:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试使用:
Try using :