# hjh-scroll

> a scroll utils

Latest version **1.0.3** (published 2023-02-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install hjh-scroll
pnpm add hjh-scroll
yarn add hjh-scroll
bun add hjh-scroll
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: esm support; no vulnerabilities.

Warnings: low downloads; no types.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2023-02-02 |
| First published | 2023-01-31 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | clare-hjh |
| Maintainers | clare-hjh |
| Keywords | clientHeight, scrollTop, scrollHeight, utils |

## Links

- npm: https://www.npmjs.com/package/hjh-scroll
- Repository: https://github.com/clarehjh/h-scroll
- Homepage: https://github.com/clarehjh/h-scroll#readme
- Issues: https://github.com/clarehjh/h-scroll/issues
- npm.io page: https://npm.io/package/hjh-scroll

## Dependencies (1)

- [vue](https://npm.io/package/vue.md) ^3.2.36

## Recent versions

- 1.0.3 (latest) — 2023-02-02
- 1.0.2 — 2023-02-01
- 1.0.1 — 2023-01-31
- 1.0.0 — 2023-01-31

## README

# h-scroll

# 目的

hjh-scroll 是为了解决移动端获取设备滚动距离，是否滚动到底部提示并刷新新数据的工具函数

# 安装

```js
yarn add hjh-scroll

```

# 基础使用

```js
import { useScroll } from "hjh-scroll";
const { isReachBottom, clientHeight, scrollTop, scrollHeight } = useScroll();
```

# 元素点击滑动到指定位置

```html
<div class="detail top-page" ref="contentRef">
  <tab-control
    v-if="showTabControl"
    class="tabs"
    :titles="names"
    @tabItemClick="tabClick"
  />
</div>
```

```js
// tabControl相关的操作
const contentRef = ref();
const { scrollTop } = useScroll(contentRef);

//指定位置显示tabControl
const showTabControl = computed(() => {
  return scrollTop.value >= 300;
});

//滚动到指定距离
contentRef.value.scrollTo({
  top: xxxx,
  behavior: "smooth",
});
```

---
_Source: https://npm.io/package/hjh-scroll · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
