Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
css-keyframer
Advanced tools
Dynamic css animation keyframes Manipulation library.
See demo page: https://tsuyoshiwada.github.io/css-keyframer/
css-keyframer.js provides a Low-level API that add to the head element dynamically generates a style element.
Therefore, linking to the DOM element must be handled by the user side.
When you want to apply the same animation to multiple elements, it is inefficient to update the in-line style of all the elements.
If you reuse one of @keyframes
it can be realized efficient animation.
You can install the css-keyframer.js from npm.
$ npm install css-keyframer --save
or Download the css-keyframer.min.js
In the following example, to apply the spin animation to div.element
.
<div class="element"></div>
import CSSKeyframer from "css-keyframer";
const keyframer = new CSSKeyframer({ /* options */ });
// CSS property will be added vendor-prefix is automatically!
keyframer.register("spin", [
{ transform: "rotate(0deg)" },
{ transform: "rotate(360deg)" }
]);
document.querySelector(".element").style[keyframer.animationProp.js] = "spin 1500ms linear infinite";
To the constructor of CSSKeyframer
You can specify the following options.
Key | Default | Description |
---|---|---|
namePrefix | "" | Grant prefix to @keyframes . |
styleDataName | "data-keyframes" | To specify the attributes to be used in the style element. |
pretty | false | Output pretty code @keyframes . Primarily used for debugging applications. |
useAgent | null | Specify the UserAgent to be used for inline-style-prefixer. When set to null , it is judged automatically. since: v1.0.0 |
since: v1.0.0
Get CSS string containing the keyframes.
keyframer.getKeyframesString("spin", {
"0%": { transform: "rotate(0deg)" },
"100%": { transform: "rotate(360deg)" }
});
// or Array style
keyframer.getKeyframesString("spin", [
{ transform: "rotate(0deg)" },
{ transform: "rotate(360deg)" }
]);
// Result (pretty: true)
// @keyframes spin {
// 0% {
// transform: rotate(0deg);
// }
// 100% {
// transform: rotate(360deg);
// }
// }
since: v1.0.0
Get a style element containing a keyframe as a string.
It is an API that you do not normally use. But, this is a useful API for Server-side Rendering.
keyframer.getKeyframeStylesheet("spin", {
"0%": { transform: "rotate(0deg)" },
"100%": { transform: "rotate(360deg)" }
});
// or Array style
keyframer.getKeyframeStylesheet("spin", [
{ transform: "rotate(0deg)" },
{ transform: "rotate(360deg)" }
]);
// Result (pretty: true)
// <style type="text/css" data-keyframe="spin">@keyframes spin {
// 0% {
// transform: rotate(0deg);
// }
// 100% {
// transform: rotate(360deg);
// }
// }</style>
Register the @keyframes
.
If @keyframes
of the same name exists overwrites it.
Example:
// Object style
keyframer.register("spin", {
"0%": { transform: "rotate(0deg)" },
"100%": { transform: "rotate(360deg)" }
});
// or Array style
keyframer.register("spin", [
{ transform: "rotate(0deg)" },
{ transform: "rotate(360deg)" }
]);
// Result (pretty: true)
// <style type="text/css" data-keyframe="spin">
// @keyframes spin {
// 0% {
// transform: rotate(0deg);
// }
// 100% {
// transform: rotate(360deg);
// }
// }
// </style>
Unregister the @keyframes
.
Example:
keyframer.unregister("spin");
Unregister all @keyframes
.
Example:
keyframer.unregisterAll();
Check whether the specified @keyframes exists.
Example:
keyframer.contains("spin"); // true or false
since: v1.0.0
It provides the name of the property required for the animation of the set with a vendor prefix. (CSS and JS)
Example:
import CSSKeyframer from "css-keyframer";
const keyframer = new CSSKeyframer();
keyframer.register("spin", [
{ transform: "rotate(0deg)" },
{ transform: "rotate(360deg)" }
]);
document.querySelector(".target").style[keyframer.animationProp.js] = "spin 1500ms linear infinite";
Released under the MIT Licence
See CHANGELOG.md.
Initialization of the project.
$ cd /your/project/dir
$ git clone https://github.com/tsuyoshiwada/css-keyframer.git
Install some dependencies.
$ npm install
Start the development and can you see demo page (access to the http://localhost:3000/
).
$ npm start
Run lint and testing.
$ npm test
Generates build file.
$ npm run build
Thank you for your interest in css-keyframer.js.
Bugs, feature requests and comments are more than welcome in the issues.
Before you open a PR:
Be careful to follow the code style of the project. Run npm test
after your changes and ensure you do not introduce any new errors or warnings.
All new features and changes need documentation.
Thanks!
1.0.1 (2017-02-01)
keyframer.animationProp.(js | css)
becomes undefined.FAQs
Dynamic css animation keyframes Manipulation library.
The npm package css-keyframer receives a total of 2,535 weekly downloads. As such, css-keyframer popularity was classified as popular.
We found that css-keyframer 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
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.