Skip to content

Latest commit

 

History

History
49 lines (37 loc) · 860 Bytes

README.md

File metadata and controls

49 lines (37 loc) · 860 Bytes

h-scroll

目的

hjh-scroll 是为了解决移动端获取设备滚动距离,是否滚动到底部提示并刷新新数据的工具函数

安装

yarn add hjh-scroll

基础使用

import { useScroll } from "hjh-scroll";
const { isReachBottom, clientHeight, scrollTop, scrollHeight } = useScroll();

元素点击滑动到指定位置

<div class="detail top-page" ref="contentRef">
  <tab-control
    v-if="showTabControl"
    class="tabs"
    :titles="names"
    @tabItemClick="tabClick"
  />
</div>
// tabControl相关的操作
const contentRef = ref();
const { scrollTop } = useScroll(contentRef);

//指定位置显示tabControl
const showTabControl = computed(() => {
  return scrollTop.value >= 300;
});

//滚动到指定距离
contentRef.value.scrollTo({
  top: xxxx,
  behavior: "smooth",
});