1.0.6 • Published 3 years ago

animated-highlight.js v1.0.6

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

animated-highlight.js

Simple JS package to highlight DOM elements with some animation

Instalation

Browser

Download File

<script src="animated-highlight.js" type="module"></script>

NPM

npm i animated-highlight.js

YARN

yarn add animated-highlight.js

How to use

import animatedHighlight from 'animated-highlight.js';

const elem = document.getElementById('container');
const options = { speed: 'fast' };

animatedHighlight(elem, options);

// or just

animatedHighlight('container'); // with default options

Options

NameTypeDescriptionDefault Value
colorAstringmain color to generate the gradient#4BB543
colorBstringsecondary color to generate the gradient#ffffff
directionstringanimation direction (see options below)bottom
directionsarraydirections sequence (overrides direction)[]
speedstringanimation speed (see options below)medium
speedsobjectspecific speed for a given direction{}
tremblestringtrembles the element while animatingnull
trembleModestringoptions: 'soft', 'default' or 'hard'default
onDonefunctioncallback function after animation is donenull

Available directions

  • right top
  • right
  • right bottom
  • bottom
  • left bottom
  • left
  • left top
  • top
  • circle

Available speeds

  • superfast
  • fast
  • medium
  • slow
  • superslow

Tremble values

  • horizontal
  • vertical

warning: requires element's position as 'relative', 'absolute' or 'fixed'

Examples

Directions sequence

const options = {
  directions: ['right top', 'circle'],
};

animatedHighlight('elementId', options);

first example

Custom colors

const options = {
  directions: [
    'right top',
    'left top',
    'circle',
  ],
  colorA: 'rgb(51, 102, 204)',
  colorB: 'rgb(174, 194, 234)',
};

animatedHighlight('elementId', options);

second example

Specific speed for each direction

const options = {
  directions: [
    'top',
    'bottom',
  ],
  colorA: '#b300b3',
  colorB: '#ff80ff',
  speeds: {
    'top': 'slow',
    'bottom': 'superfast',
  },
};

animatedHighlight('elementId', options);

third example

Trembeling the element while animating

const options = {
  direction: 'circle',
  colorA: '#FFCCCC',
  colorB: '#ffffff',
  speed: 'slow',
  tremble: 'vertical',
  trembleMode: 'hard',
};

animatedHighlight('elementId', options);

third example

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago