Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
<div align="center">
<img width="100px" src="https://raw.githubusercontent.com/phucbm/scroll-direction/main/logo.svg" align="center" alt="Scroll Direction" />
<h1 align="center">Scroll Direction</h1>
<p align="center">A lightweight jQuery plugin to detect scroll direction on your website. </p>
<p align="center">A lightweight Javascript plugin to detect scroll direction on your website.</p>
</div>

<div align="center">
<a href="https://github.com/phucbm/https://badgen.net/github/release/phucbm/jquery-scroll-direction-plugin/?cache=600/releases/latest">
<img src="https://badgen.net/github/release/phucbm/jquery-scroll-direction-plugin/?cache=600/?cache=600">
</a>
<a href="https://www.jsdelivr.com/package/gh/phucbm/jquery-scroll-direction-plugin">
<img src="https://data.jsdelivr.com/v1/package/gh/phucbm/jquery-scroll-direction-plugin/badge">
<img src="https://data.jsdelivr.com/v1/package/gh/phucbm/jquery-scroll-direction-plugin/badge?style=rounded">
</a>
<span>
<img src="https://raw.githubusercontent.com/webuild-community/badge/master/svg/made.svg" alt="made-in-vietnam">
</span>
</div>

> **Update**: Scroll Direction now works with other libraries that hijack the native scrollbar (like Locomotive Scroll).

**[View demo on CodePen &rarr;](https://codepen.io/phucbui/pen/yLaeqBw)**

## Getting started

### Download locally
### Self-hosting

You
can [download the plugin directly from Github](https://raw.githubusercontent.com/phucbm/jquery-scroll-direction-plugin/main/jquery.scroll-direction.js)
.

```html

<script src="your-path/jquery.scroll-direction.js"></script>
<script src="/jquery.scroll-direction.js"></script>
```

### Using CDN
Expand All @@ -36,24 +37,27 @@ You can also browse for the latest version by
visiting [Scroll Direction on jsDelivr](https://cdn.jsdelivr.net/gh/phucbm/jquery-scroll-direction-plugin/)

```html
<!-- Scroll Direction - v1.1.0 -->
<script src="https://cdn.jsdelivr.net/gh/phucbm/jquery-scroll-direction-plugin@1.1.0/jquery.scroll-direction.js"></script>
<!-- Scroll Direction - v2.0.0 -->
<script src="https://cdn.jsdelivr.net/gh/phucbm/jquery-scroll-direction-plugin@2.0.0/jquery.scroll-direction.js"></script>
```

or minified version

```html
<!-- Scroll Direction - v1.1.0 -->
<script src="https://cdn.jsdelivr.net/gh/phucbm/jquery-scroll-direction-plugin@1.1.0/jquery.scroll-direction.min.js"></script>
<!-- Scroll Direction - v2.0.0 -->
<script src="https://cdn.jsdelivr.net/gh/phucbm/jquery-scroll-direction-plugin@2.0.0/jquery.scroll-direction.min.js"></script>
```

### Initialize Scroll Direction

After init, you will have some classes on your body tag to indicate the scroll direction and position.

```js
// init Scroll Direction
// jQuery
$.scrollDirection.init();

// Pure JS
window.scrollDirection.init();
```

```html
Expand Down Expand Up @@ -193,4 +197,4 @@ And start test server

```shell
gulp serve
```
```