Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
@zhaostephen/avoidance
Advanced tools
A standalone library for creating avoidance-cloud particle effects, beautifully.
Make HTML elements avoid your mouse cursor and touches, beautifully.
The two easiest ways to use avoidance.js are
Choose one of the following script tags to add directly to your HTML.
<!-- Get a specific version -->
<script src="https://cdn.jsdelivr.net/npm/@zhaostephen/avoidance@0.2.3/dist/avoidance.min.js"></script>
<!-- Get patch fixes within the minor version -->
<script src="https://cdn.jsdelivr.net/npm/@zhaostephen/avoidance@0.2/dist/avoidance.min.js"></script>
<!-- Get minor updates and patch fixes within the major version -->
<script src="https://cdn.jsdelivr.net/npm/@zhaostephen/avoidance@0/dist/avoidance.min.js"></script>
<!-- Always get the latest version -->
<!-- Not recommended for production sites! Only use if you know what you're doing. -->
<script src="https://cdn.jsdelivr.net/npm/@zhaostephen/avoidance/dist/avoidance.min.js"></script>
Run in one of the following in your project directory (depending on your package manager):
yarn add @zhaostephen/avoidance
npm install --save @zhaostephen/avoidance
If using with ES modules, import the library like so:
import Avoidance from "@zhaostephen/avoidance";
If using CommonJS, import the library like so:
const Avoidance = require("@zhaostephen/avoidance");
If using directly in the browser, the library is accessible through a global variable, Avoidance
.
Then simply instantiate an Avoidance
on the container of your choice, and call start.
new Avoidance('#my-container').start();
Replace #my-container
with the query selector for the container on which you want the mouse-over/touch effect to occur. All children elements will then be animated as particles.
new Avoidance(containerSelector: string, options?: AvoidanceUserOptions, addChildrenAsParticles?: boolean)
containerSelector
: a query selector (similar to CSS selector) that specifies which elements will activate the avoidance effect when moused over or touched.options
[optional]: a options object that specifies parameters for how the avoidance effect behaves. Defaults to {}
. See the options section below for what can be tweaked!addChildrenAsParticles
[optional]: a boolean that specifies whether or not the children of the specified containers will be automatically added as particles upon instantiation. Defaults to true
.TODO: Documentation for other methods will be added later.
The Avoidance
constructor takes in an options object as its second parameter.
An example AvoidanceUserOptions
object is given below.
{
factorMethod: {
name: "powerInverse",
offset: 0.05,
power: 0.8,
},
displacementMethod: "noThreshold",
timing: "easeOutCubic",
}
An AvoidanceUserOptions
object can take any combination of the following optional keys and values.
factorMethod
specifies what method to use to determine the avoidance distance multiplier.
It can be either a string or an object.
"inverse"
, "powerInverse"
, or "exponential"
.name
: one of "inverse"
, "powerInverse"
, or "exponential"
.scale
: a floating-point number.offset
: a floating-point number.power
: a floating-point number.The default behaviour is
{
name: "powerInverse",
scale: 0.02,
offset: 0.0,
power: 0.6,
}
This may be used as a reference point for modifying the values.
If only a name is provided, the default value for the remaining keys will adjust accordingly.
displacementMethod
specifies what method to use to calculate avoidance displacement, given the distance multiplier.
It can be either a string or an object.
"noThreshold"
, or "threshold"
.name
: one of "noThreshold"
, or "threshold"
.thresholdRadius
: a floating-point numberThe default behaviour is
{
name: "threshold",
thresholdRadius: 0.1,
}
This may be used as a reference point for modifying the values.
If only a name is provided, the default value for thresholdRadius
will adjust accordingly.
timing
is a string that specifies an easing for the touch animations.
It can be one of "linear"
, "easeOutCubic"
, or "easeOutExpo"
.
The default value is "easeOutExpo"
.
pathing
is a string that specifies the path taken by touch animations.
It can be one of "linear"
or "bezierQuad"
.
The default value is "bezierQuad"
.
TODO: additional options will come in the future. Stay on the lookout!
FAQs
A standalone library for creating avoidance-cloud particle effects, beautifully.
We found that @zhaostephen/avoidance demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.