1.0.23 • Published 2 years ago

use-animation-on-screen v1.0.23

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

UseAnimationOnScreen

UseAnimationOnScreen is a lightweight React hook that allows you to give life to your website by animating any element when it enters the screen.

Including many animation types, transition duration, screen entry ratio.

Installation

npm install use-animation-on-screen

usage

import { useAnimationOnScreen } from "use-animation-on-screen";
export default App = () => {
  //  With default config
  const element = useAnimationOnScreen();

  // With custom config
  const element = useAnimationOnScreen({
    screenEntryRatio: 0.9,
    animationType: "fade-up",
    transitionDuration: 800,
    makeAnimationUnique: false,
  });

  //Add the ref to your element
  return (
    <>
      <div ref={element}>Hello World</div>
    </>
  );
};

Config

keyoption typedefaultComment
screenEntryRationumber0.9When the animation happens on the screen. From 0 (top of the screen) to 1 (bottom of the screen )
animationTypestringfade-upType of animation (fade-up, fade-left, fade-right, zoom-in, zoom-out)
makeAnimationUniquebooleanfalseMakes the animation happen only once after the element enters the screen
transitionDurationnumber800In ms, 0 disables the transition
animationDelaynumber0In ms, delays when the animation happens
transitionTimingFunctionstringease-outThe transition-timing-function property specifies the speed curve of the transition effect.
1.0.23

2 years ago

1.0.22

2 years ago

1.0.21

2 years ago

1.0.20

2 years ago

1.0.19

2 years ago

1.0.18

2 years ago

1.0.17

2 years ago

1.0.16

2 years ago

1.0.15

2 years ago

1.0.14

2 years ago

1.0.13

2 years ago

1.0.12

2 years ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

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

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago