2.0.3 • Published 6 years ago

sponlax v2.0.3

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

do stuff when shit's in the view

Intersection Observer + requestAnimationFrame...

Install

npm install sponlax or yarn add sponlax

import SponLax from 'sponlax'


<div data-motion data-spon-track>track on scroll when in view</div>
<div data-motion>Just onEnter and onLeave events triggered</div>

new SponLax('[data-motion]', {
    rootMargin: '0px',
    threshold: 0,
    shouldUnObserve: () => false,
    onEnter: ($node) => {},
    onLeave: ($node) => {},
    inview($node) {
        const { top } = $node.getBoundingClientRect()
        const { speed } = $node.dataset
        $node.style.transform = `translate3d(0, ${top * parseFloat(speed)}px, 0)`
    },
})
2.0.3

6 years ago

2.0.2

6 years ago

2.0.1

6 years ago

2.0.0

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.2.0

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago