admin管理员组文章数量:1303536
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 ?
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 ?
Share Improve this question edited Sep 26, 2012 at 2:12 Eli 14.8k5 gold badges61 silver badges77 bronze badges asked Apr 21, 2011 at 2:20 JeffJeff 2,8628 gold badges32 silver badges35 bronze badges 1- 1 Did you not get a good enough answer, Deca? – Levi Morrison Commented May 24, 2011 at 19:41
2 Answers
Reset to default 6No, 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:
var api = pane.data('jsp');
$('#but-scroll-to').bind(
'click',
function()
{
// Note, there is also scrollToX and scrollToY methods if you only
// want to scroll in one dimension
api.scrollTo(parseInt($('#toX').val()), parseInt($('#toY').val()));
return false;
}
);
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.
本文标签: javascriptcan39t use animate scrollTop with jscrollpaneStack Overflow
版权声明:本文标题:javascript - can't use animate scrollTop with jscrollpane? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741723009a2394496.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论