1.0.1 • Published 4 years ago

simple-scroll.js v1.0.1

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

Simple-Scroll

A simple JavaScript script to add and remove or to modify styling of an element based on the scrolling position

Installation

With NPM

npm i simple-scroll.js

Without NPM

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/simple-scroll.js@1.0.1/src/simple-scroll.min.css"></script>
<script defer src="https://cdn.jsdelivr.net/npm/simple-scroll.js@1.0.1/src/simple-scroll.min.js"></script>

Usage

Just add the 'ss-target' attribute to the element you want to be animated.

<body>
    <section>
        <h1 ss-target>This is simple-scroll!</h1>
        <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Praesentium, obcaecati.</p>
    </section>
</body>

Attributes

There are some settings to do some more advanced animations. | Attribute | Description | |---------------------|---------------------------------------------------------------------------------| |ss-target | Tells the script that this element should be animated | |ss-delay | Delay before css class changes | |ss-in | The css class the element receives when it gets inside the "viewport" | |ss-out | The css class the element receives when it gets outside the "viewport" | |ss-object | Change the "viewport" object which triggers the class changes | |ss-scroll-position | Use the scroll position instead of the "viewport" to trigger class changes | |ss-scroll-anim | Animate a css property based on the scroll position |

AttributeUsage / Values
ss-target<h1 ss-target>
ss-delayss-delay="Number"
ss-inss-in="ss-fade-in"
ss-outss-out="ss-fade-out"
ss-objectss-object=".container"
ss-scroll-positionss-scroll-position="700"
ss-scroll-animss-scroll-anim="opacity, 0 0, 400 1"

License

MIT