Animate anything just like it was attracted by the cursor
Demo on the github page
For nodejs
$ npm i @yoannchb/cattract
Or with the cdn
<script src="https://unpkg.com/@yoannchb/cattract@1.0.0/dist/index.js"></script>
import Cattract from "cattract";
//Or
const Cattract = require("cattract");
const animation = new Cattract(document.querySelector("#button"));
Or with specified options
const animation = new Cattract(document.querySelector("#button"), {
//options you need
});
animation.stop()
stop the animationanimation.start()
Start the animation after a stopanimation.reset()
Reset the target styleanimation.debug(color: string = "#e1e1e130")
Create two circle around the target to see theelementRadius
anddetectionRadius
type With3dOptions = {
axe?: "x" | "y";
inverted?: boolean | "x" | "y";
maxAngle?: number;
perspective?: number;
};
type Options = {
elementRadius?: number;
detectionRadius?: number | "full";
animation?: {
ease?: string;
duration?: number;
};
scale?: {
from?: number;
to?: number;
animated?: boolean;
};
inverted?: boolean | "x" | "y";
axe?: "x" | "y";
with_3d?: boolean | With3dOptions;
};