列表无限滚动是否可以改为循环加载更多内容?
- 内容介绍
- 文章标签
- 相关推荐
本文共计110个文字,预计阅读时间需要1分钟。
javascript/** * 无限滚动列表 * @return {Array} [type, description] */initAutoScroll() { let $listWrapper=this.$template.find('list-wrapper'); let $list=$listWrapper.find('ul'); $list.clone().appendTo($listWrapper); this.scroll();}
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); }
本文共计110个文字,预计阅读时间需要1分钟。
javascript/** * 无限滚动列表 * @return {Array} [type, description] */initAutoScroll() { let $listWrapper=this.$template.find('list-wrapper'); let $list=$listWrapper.find('ul'); $list.clone().appendTo($listWrapper); this.scroll();}
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); }

