简体   繁体   English

我如何制作连续的水平滚动

[英]How do i make a continous horizontal scroll

I used a method that allow an auto scroll on mouse hover, but the thing I am looking to achieve is to make the items in the list continue scrolling even at the last item.我使用了一种允许在鼠标 hover 上自动滚动的方法,但我想要实现的目标是使列表中的项目即使在最后一项也继续滚动。 ie: Let it continue to scroll starting from the first item again.即:让它再次从第一项开始滚动。

   $(function() {
     $(window).load(function() {
       var $gal = $("#propertyThumbnails"),
       galW = $gal.outerWidth(true),
       galSW = $gal[0].scrollWidth,
       wDiff = (galSW / galW) - 1, // widths difference ratio
       mPadd = 60, // mousemove Padding
       damp = 20, // Mmusemove response softness
       mX = 0, // real mouse position
       mX2 = 0, // modified mouse position
       posX = 0,
       mmAA = galW - (mPadd * 2), // the mousemove available area
       mmAAr = (galW / mmAA); // get available mousemove didderence ratio
         $gal.mousemove(function(e) {
       mX = e.pageX - $(this).parent().offset().left - this.offsetLeft;
       mX2 = Math.min(Math.max(0, mX - mPadd), mmAA) * mmAAr;
       });
         setInterval(function() {
       posX += (mX2 - posX) / damp; // zeno's paradox equation "catching delay" 
       $gal.scrollLeft(posX * wDiff);
         }, 10);
       });
    });

Here is the method I used => Codepen这是我使用的方法=> Codepen

Thanks to Wilbur.感谢威尔伯。

But like I said, I'd rather have it in continues scroll.但就像我说的,我宁愿让它继续滚动。 And I'd appreciate some help here.我很感激这里的一些帮助。

when you reach the end of the list, move the first item to the end(append it to the list).当您到达列表末尾时,将第一项移动到末尾(将其附加到列表中)。 In the opposite direction take the last item and move it to the beginning(prepend the list) You will need to consider some time tweaking it, interactive scrollbars are tricky to get to the point where they feel fluent and organic在相反的方向上,将最后一个项目移到开头(在列表前面)你需要考虑一些时间来调整它,交互式滚动条很难达到他们感觉流畅和有机的程度

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM