项目作者: taimursaeed

项目描述 :
Trigger animation on scroll
高级语言: CSS
项目地址: git://github.com/taimursaeed/onscroll.git
创建时间: 2020-03-27T14:24:24Z
项目社区:https://github.com/taimursaeed/onscroll

开源协议:MIT License

下载


OnScroll

Animate elements in the website on scroll.

onScroll Demo

Demo

https://taimursaeed.github.io/onscroll/

Prerequisite

jQuery

Setup

Get the CSS and JS files from the /dist folder

Include CSS and JS files in the page

  1. <link rel="stylesheet" href="/path/onscroll-animation.css">
  2. ...
  3. <script src="/path/onscroll-animation.js"></script>

Usage

Add attribute data-animation to the element you wish to animate.

E.g

  1. <div data-animation="fade">

Animation Options

Change animation behavior with data-animation-* attributes.

  1. <div
  2. data-animation="fade"
  3. data-animation-delay="1000"
  4. data-animation-speed="3000"
  5. data-animation-offset="300"
  6. >
  7. </div>

data-animation-delay

Controls the delay, value in milliseconds

data-animation-speed

Controls the speed, value in milliseconds. Default 1000ms

data-animation-offset

Controls the trigger point of the animation, value in px.

Predefined values

data-animation

  • fade

  • fade-up

  • fade-down

  • fade-left

  • fade-right

Customization

Use onscroll-animation.css to extend animation or change current ones. Like default distance for animation is 30px.

You can change it to 100px like this:

  1. [data-animation="fade-up"] {
  2. transform: translate(0, 100px);
  3. }

Contribute

Please feel free to contribute pull requests or create issues for bugs and feature requests.