如何实现列表内容的无限滚动功能?

2026-04-06 19:561阅读0评论SEO基础
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计111个文字,预计阅读时间需要1分钟。

如何实现列表内容的无限滚动功能?

javascriptinitAutoScroll.js/** * 无限滚动列表 * @return {Array} [type, description] */initAutoScroll() { let $listWrapper=this.$template.find('list-wrapper'); let $list=$listWrapper.find('ul'); $list.clone().appendTo($listWrapper); this.scro...

init-auto-scroll.js

/** * 列表无限滚动 * @return {[type]} [description] */ initAutoScroll() { let $listWrapper = this.$template.find('.list-wrapper'); let $list = $listWrapper.find('>ul'); $list.clone().appendTo($listWrapper); this.scrollInterval = setInterval(() => { if($listWrapper.height() > $list.height()) { $list.next().remove(); clearInterval(this.scrollInterval); return false; } let marginTop = Number.parseInt($list.css('marginTop')); if(Math.abs(marginTop) >= $list.height()) { marginTop = Number.parseInt($listWrapper.css('marginTop')); } $list.css({ marginTop: `${marginTop - 1}px` }); }, 50); }

如何实现列表内容的无限滚动功能?

本文共计111个文字,预计阅读时间需要1分钟。

如何实现列表内容的无限滚动功能?

javascriptinitAutoScroll.js/** * 无限滚动列表 * @return {Array} [type, description] */initAutoScroll() { let $listWrapper=this.$template.find('list-wrapper'); let $list=$listWrapper.find('ul'); $list.clone().appendTo($listWrapper); this.scro...

init-auto-scroll.js

/** * 列表无限滚动 * @return {[type]} [description] */ initAutoScroll() { let $listWrapper = this.$template.find('.list-wrapper'); let $list = $listWrapper.find('>ul'); $list.clone().appendTo($listWrapper); this.scrollInterval = setInterval(() => { if($listWrapper.height() > $list.height()) { $list.next().remove(); clearInterval(this.scrollInterval); return false; } let marginTop = Number.parseInt($list.css('marginTop')); if(Math.abs(marginTop) >= $list.height()) { marginTop = Number.parseInt($listWrapper.css('marginTop')); } $list.css({ marginTop: `${marginTop - 1}px` }); }, 50); }

如何实现列表内容的无限滚动功能?