jQuery .animate scrollTop无法滚动电视演示

yuvru6vn  于 2023-11-17  发布在  jQuery
关注(0)|答案(1)|浏览(174)

我一直在尝试用jQuery. animate滚动一个long/large。但我没有得到任何移动。我包括了div的html和. animate前后的输出。
如有任何帮助,我们将不胜感激。

  1. <div id="content" style="height: 868px;">
  2. This height: is calculated and placed here by jquery onready function.
  3. It is hight of window - Header - Footer.
  4. <div id="content_row" style="height:inherit overflow:hidden;">
  5. <div id="scroll_me" style="width:100%; height:auto; margin-left:auto; margin-right:auto; margin-top:0.8rem;">
  6. function downScroll() {
  7. ...
  8. // Debug info of variables done here!
  9. console.log( "my_scroll_container: " + my_scroll_container );
  10. console.log( "my_container_height: " + $(my_scroll_container).height() );
  11. console.log( "my_scroll_selector: " + my_scroll_selector );
  12. console.log( "my_scroll_selector_height: " + $(my_scroll_selector).height() );
  13. console.log( "myPos: " + $(my_scroll_selector).scrollTop() );
  14. console.log( "max_scroll: " + max_scroll_distance );
  15. console.log( "swing_time: " + swing_time );
  16. $(my_scroll_selector)
  17. .stop(true, false)
  18. .animate( { scrollTop: max_scroll_distance },
  19. swing_time,
  20. 'swing',
  21. function() {
  22. //$(my_scroll_selector).trigger( 'up.startScroll' );
  23. } );
  24. }
  25. JUST BEFORE ANIMATE
  26. my_scroll_container: #content_row
  27. my_container_height: 984
  28. my_scroll_selector: #scroll_me
  29. my_scroll_selector_height: 1587.2
  30. myPos: 0 // Expected postion, just loaded page.
  31. max_scroll: 603
  32. swing_time: 3000
  33. ANIMATION FINISHED:
  34. my_scroll_container: #content_row
  35. my_container_height: 984
  36. my_scroll_selector: #scroll_me
  37. my_scroll_selector_height: 1587.2
  38. myPos: 0 // This did not change here or on screen!
  39. max_scroll: 603
  40. swing_time: 3000

字符串

nlejzf6q

nlejzf6q1#

好吧,我终于弄明白了!我应该对我来说很明显......我正在将动画应用到作为“数据”的div上。
动画应适用于指定的“查看端口”,这是小于数据的div!

  1. $(my_scroll_container)
  2. .stop(true, false)
  3. .animate({scrollTop: max_scroll_distance },
  4. swing_time,
  5. 'swing',
  6. function () {
  7. $(my_scroll_selector).trigger('up.startScroll');
  8. });

字符串

相关问题