@atyoursite/animation

Shared code to use accross our projects

Usage no npm install needed!

<script type="module">
  import atyoursiteAnimation from 'https://cdn.skypack.dev/@atyoursite/animation';
</script>

README

Animation

animateBody()

Description

Scroll the body to a given position. (cross browser). In the configuration you can opt to use a callback before or after the animation.

Installation

Open a terminal window inside the root of your project to install the node package.

npm install --save-dev @atyoursite/animation

Dependency

To be able to use the function, you will have to import it as a dependency

import { animateBody } from '@atyoursite/animation';

Usage

function runAfter() {
    console.log('After scrolling');
}

function runBefore() {
    console.log('Before scrolling');
}

animateBody({
    scrollTop: 150,
    duration: 2000,
    cbBefore: runBefore,
    cbAfter: runAfter
});