npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@adoratorio/apollo

v3.0.1

Published

A JS library for custom cursor

Downloads

128

Readme

Apollo

An engine to create custom cursor animations and effects.

Installation

Apollo s written in typescript and available as npm package with the alongside types definitions. So install as always

# Install package
npm install @adoratorio/apollo

Usage

Then it can be required or imported as module

import Apollo from '@adoratorio/apollo';
const apollo = new Apollo({ });

From now on you can instanciate and register plugins to handle the rendering of the amount with different teqniques or to add functionalities. Plugins stucture is explained later.

For the plugins they can also be imported singularly as modules from the plguins folder and then registered using the registerPlugin method.

import CSSRender from '@/adoratorio/apollo/plugins/css-render';
apollo.registerPlugin(new CSSRender({ /* ... plugin options */ }));

Available options

Apollo accept in the constructor an option object with the following possible props.

|parameter|type|default|description| |:--------|:--:|:-----:|:----------| |easing|Easing|{ mode: Apollo.EASING.CUBIC, duration: 1000 }|An easing object used to describe the cursor element aniamtion| |initialPosition|Vec2|{ x: 0, y: 0 }|A Two components (x, y) vector to determinate the strarting position of the cursor element| |detectTouch|boolean|true|If the touch events counts as valid interaction to evaluate a new cursor position| |aion|Aion|new Aion()|An Aion instance to be used as engine, if not submitted one will be created for you|

APIs

Public Methods

registerPlugin()

Register a plugin inside the current Apollo instance. Return a string with the registration id, useful for unregister

apollo.registerPlugin(plugin : ApolloPlugin) : string

Parameters

| parameter | required | description | |:---|:---:|:---| | plugin | ApolloPlugin | The instance of the plugin to register |

registerPlugins()

Register multiple plugins inside the current Apollo instance. Return an array of strings with the registration ids in positional corrispondence with the provided plugins array

apollo.registerPlugins(plugin : Array<ApolloPlugin>) : Array<string>

Parameters

| parameter | required | description | |:---|:---:|:---| | plugin | ApolloPlugin | The instance of the plugin to register |

unregisterPlugin()

Remove a plugin from the current Apollo instance using the registration id of the plugin. Return true if the plugin was found and unregistered

apollo.unregisterPlugin(id : string) : boolean

Parameters

| parameter | required | description | |:---|:---:|:---| | plugin | ApolloPlugin | The instance of the plugin to register |

getPlugin()

Get instance of a registerd plugin using his name

apollo.getPlugin(name : String) : ApolloPlugin | undefined

Parameters

| parameter | required | description | |:---|:---:|:---| | name | string | The name of the plugin to retrive |

startMouseTracking()

Starts the mouse tracking per frame. Same as apollo.trackMouse = true.

apollo.startMouseTracking();

stopMouseTracking()

Stops temporarly the mouse tracking per frame. Same as apollo.trackMouse = false.

apollo.stopMouseTracking();

Instance Properties

The Apollo instance exposes two main properties:

coords

• Type: interface Vec2 { x:number, y:number } With x and y props exposes the current smoothed position in screen pixels, updated frame-by-frame.

normalizedCoords

• Type: interface Vec2 { x:number, y:number } With x and y props exposes the current smoothed position in normalized values from -1 to 1, updated frame-by-frame.

mouse

• Type: interface Vec2 { x:number, y:number } With x and y props exposes the current native mouse pointer position in screen pixels, updated frame-by-frame.

normalizedMouse

• Type: interface Vec2 { x:number, y:number } With x and y props exposes the current native mouse pointer position in normalized values from -1 to 1, updated frame-by-frame.

velocity

• Type: interface Vec2 { x:number, y:number } With x and y props exposes the diffrence in time from the previous frame of the smoothed coords (not the mouse) indicating how much they have change in one frame using absolute values, updated frame-by-frame.

direction

• Type: interface Vec2 { x:number, y:number } Comparing the previous frame and the current one holds the value of the direction the cursor is moving -1 for right to left and bottom to top, 1 for left to right or top to bottom. Can be multiplied with velocity to have full information about the cursor movement compared to previous frame.

trackMouse

• Type: boolean Get or set the current mouse tracking state. If true the mouse is being tracked and the coords and mouse are updated respectively. If false it will stop recording mouse position (not the frame or the engine itself).