[英]How to animate scrolling from current scroll position to target scroll position with help of jQuery?
I want to have scroll animation for my block. 我想为我的块添加滚动动画。 The block should scroll from current scroll position of the
page(page_scroll_value)
to target scroll position (my_scroll_value)
. 该块应从
page(page_scroll_value)
当前滚动位置page(page_scroll_value)
滚动到目标滚动位置(my_scroll_value)
。
I know about .animate()
method in jQuery but I didn't find something about animation from value A to value B. How I can solve the task? 我知道jQuery中的
.animate()
方法,但没有找到关于动画从值A到值B的知识。我如何解决任务?
If I read your question right, this will work: 如果我没看错你的问题,这将起作用:
$("#element").animate({scrollTop: my_scroll_value}, 500);
where 100 is the duration in milliseconds. 其中100是持续时间(以毫秒为单位)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.