1.0.7 • Published 2 years ago

sticky-change v1.0.7

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

sticky-change

NPM Package Build Size

watching HTMLElement's sticky state, without scroll events.

play on stackblitz (a bug from stackblitz, when in build-in browser, can not use IntersectionObserver API normally, so just click open in new window)

Demo

Usage

pure

<head>
    <script src="./dist/index.js"></script>
</head>
<div id="page-title" style="position: sticky; top: 30px">Page Title</div>
<script>
    new WatchSticky(
            document.getElementById('page-title'), 
            null, 
            () => {
                document.getElementById('page-title').classList.toggle('shadow', true)
            },
            () => {
                document.getElementById('page-title').classList.toggle('shadow', false)
            }
    )
</script>

npm

npm i sticky-change

import {WatchSticky} from 'sticky-change'

new WatchSticky(ref, null, stickyCb, unstickyCb)

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago