2.3.0 • Published 1 year ago

kis-animate v2.3.0

Weekly downloads
-
License
-
Repository
-
Last release
1 year ago

kis-animate

Lightweight library that helps you to animate elements on your pages.

All the animations are written using CSS @keyframes and transition properties what makes them as smooth as possible. You can also add your own animations by supplementing css. All source files are placed in src/lib directory.

Usage

Install library

npm install kis-animate

Import library and initialize animation instance

// your-file.js

import 'kis-animate/style'
import { KisAnimate, KisAnimateText } from 'kis-animate'

const animation = new KisAnimate();
animation.init();

const customisedAnimation = new KisAnimate({
	items: '.items-selector', // or NodeListOf<HTMLElement>
	delayStep: 200,
	duration: 500,
	// ...
	// You can find more parameters in API section bellow
});
customisedAnimation.init();

const textAnimation = new KisAnimateText();
textAnimation.init();

const customisedTextAnimation = new KisAnimateText({
	items: '.text-selector', // or NodeListOf<HTMLElement>
	symbolDelay: 20,
	// ...
	// You can find more parameters in API section bellow
});
customisedTextAnimation.init();

API

KisAnimate

NameAttributeTypeDefaultDescription
items-string or NodeListOf<HTMLElement>'[data-a-type]:not([data-a-state])'CSS selector or collection of items you want to animate or NodeList of HTML elements.
typedata-a-typestring'slide-in-from-bottom'Name of the animation you want to use. Check the list of animations available out of the box.
timingFunctiondata-a-timing-functionstring'ease'Animation timing function.
delaydata-a-delaynumber0Delay in milliseconds after which the animation starts playing.
delayStep-number0Delay in milliseconds after which the next item animation will be fired.
durationdata-a-durationnumber800Animation duration in milliseconds.
offsetdata-a-offsetstring'0px'Allows you to trigger animation a bit later. Technically this is IntersectionObserver rootMargin.
thresholddata-a-thresholdnumber0.1Technically this is IntersectionObserver threshold.

List of available animation types

- fade-in
- fade-out
- grow-in
- grow-out
- slide-in-from-bottom
- slide-in-from-top

KisAnimateText

NameAttributeTypeDefaultDescription
items-string or NodeListOf<HTMLElement>'[data-a-text-type]:not([data-a-text-state])'CSS selector or collection of items you want to animate or NodeList of HTML elements.
typedata-a-text-typestring'slide-in-from-bottom'Name of the animation you want to use. Check the list of animations available out of the box.
timingFunctiondata-a-text-timing-functionstring'ease'Transition timing function.
delaydata-a-text-delaynumber0Delay in milliseconds after which the animation starts playing.
symbolDelaydata-a-text-symbol-delaynumber10Delay between each symbol animation. Personal recommendation: use something like half of the element font size in pixels. 20 for 40px text, 8 for 16px text etc..
durationdata-a-text-durationnumber800Animation duration in milliseconds for each symbol.
offsetdata-a-text-offsetstring'0px'Allows you to trigger animation a bit later. Technically this is IntersectionObserver rootMargin.
thresholddata-a-text-thresholdnumber0.1Technically this is IntersectionObserver threshold.
wordPaddingInlinedata-a-text-word-word-padding-inlinestring0.5emIncrease this parameter if your text cuts of on left/right. (We use padding and negative margin combo to make mask effect.)
wordPaddingBlockdata-a-text-word-word-padding-blockstring0.2emIncrease this parameter if your text cuts of on top/bottom. Do not make it huge, it will make your mask animations look worse. (We use padding and negative margin combo to make mask effect.)

List of available text animation types

- slide-in-from-bottom
- slide-in-from-bottom-mask
- slide-in-from-bottom-mask-with-rotation-anticlockwise
2.2.9

1 year ago

2.2.8

1 year ago

2.3.0

1 year ago

2.2.1

1 year ago

2.2.0

1 year ago

2.2.3

1 year ago

2.2.2

1 year ago

2.2.5

1 year ago

2.2.4

1 year ago

2.2.7

1 year ago

2.2.6

1 year ago

2.1.0

1 year ago

2.0.1

1 year ago

2.0.0

1 year 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