无法将 animatescrollTop 与 jscrollpane 一起使用?
我使用以下 jQuery 函数平滑滚动到页面部分:
function scrollTo(element) {
//$('html, body').animate({ // before the addition of jscrollpane
$('#full-page-container').animate({ // after addition of jscrollpane
scrollTop: $(element).offset().top
}, 1500);
}
我已添加 jscrollpane 到替换默认的页面滚动条,上面带有 scrollTop 的 animate 函数似乎无法与 jscrollpane 一起使用,但如果没有它,则可以完美地工作。
是否可以将 jscrollpane 和 animate 与 scrollTop 一起使用?
I'm using the following jQuery function to smoothly scroll to page sections:
function scrollTo(element) {
//$('html, body').animate({ // before the addition of jscrollpane
$('#full-page-container').animate({ // after addition of jscrollpane
scrollTop: $(element).offset().top
}, 1500);
}
I've added jscrollpane to replace the default page scrollbar, and it seems that the animate function with scrollTop above won't work with jscrollpane, but works flawlessly without it.
Is it possible to use both jscrollpane and animate with scrollTop ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,你不能使用scrollTop。
但是,scrollpane 有自己的内置滚动功能,您可以在此处查看示例。
滚动到 - JScrollPane
示例,取自 jScrollPane 站点:
No, you can't use scrollTop.
However, scrollpane has their own built in scrolling, which you can see examples of here.
Scroll To - JScrollPane
Example, taken from the jScrollPane site:
注意: animate() 和 jScrollPane 不能一起使用。然而,jScrollPane 已经足够好,可以包含此功能。这不是很直观,但我为你做了一些例子。干杯!
请参阅 jScrollPane API 以获取更多有用的信息。
我有一些示例,但 jsfiddle 挂在它们上(我什至看不到源代码),所以我已经删除了它们。
Notes: You can't animate() and jScrollPane together. However, jScrollPane is nice enough to include this feature. It isn't very intuitive, but I made a some examples for you. Cheerio!
See the jScrollPane API for more useful information.
I had some examples, but jsfiddle is hanging on them (I can't even see the source code), so I have removed them.