Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

技术沉淀汇总 #6

Open
XingGuoZM opened this issue Mar 13, 2023 · 2 comments
Open

技术沉淀汇总 #6

XingGuoZM opened this issue Mar 13, 2023 · 2 comments

Comments

@XingGuoZM
Copy link
Owner

XingGuoZM commented Mar 13, 2023

• 命令式队列管理的弹窗:
命令式队列管理弹窗
promisify弹窗
• 无限滚动列表/瀑布流:
长列表与视频
长列表与埋点
long-list
时长统计脚本
用户行为跟踪
特殊字体动态打包webpack plugin
fontmin
• 数据预请求
• 复用组件与自定义hook
进度条组件
h5头部适配组件
自定义复用hook

vue 树形表格、自定义指令v-drag,自由拖动
node工具,json与excel文件互转批量修改json文件
swiper.js在项目中的应用anime.js在项目中的应用

@XingGuoZM
Copy link
Owner Author

XingGuoZM commented Mar 14, 2023

无限滚动(虚拟列表)

  • 可视区域第一条startIndex
  • 渲染列表最后一条endIndex
  • 列表偏移量offset
  • 列表展示items数量showCount
  • 每个item的高度itemHeight

滚动的过程中不断更新startIndex和offset,如果滚动到最后一条(endIndex.current >= startIndex.current + showCount - 1)时加载下一页,加载完成之后,更新endIndex

// 当前滚动位置
const scrollTop = scroller.scrollTop;
// 滚动高度超过一个itemHeight
if (Math.abs(scrollTop - preScrollTop.current) >= itemHeight) {
  // 此时可视区域第一条item的索引
  startIndex.current = Math.floor(scrollTop / itemHeight);
  // 最后一条item索引
  if (endIndex.current >= startIndex.current + showCount - 1) {
    // loadMore结束之后,更新endIndex
    loadMore();
  }
  //偏移
  offsetRef.current = scrollTop - (scrollTop % itemHeight);
  // 缓存当前scrollTop
  preScrollTop.current = scrollTop;
}

@XingGuoZM
Copy link
Owner Author

时长统计脚本

  1. 统计开始的时机,页面加载过程的哪个阶段开始,document.readyState

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant