Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

stylefire

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stylefire

Performant, simplified stylers for CSS, SVG, path and DOM scroll.

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
54K
decreased by-35.83%
Maintainers
1
Weekly downloads
 
Created
Source

Stylefire

Style-setters for CSS, SVG and scroll, optimized for animation.

npm version npm downloads Twitter Follow

Install

npm install stylefire --save

Documentation

Setting CSS properties

Stylefire will automatically detect and set vendor prefixes for newer CSS properties.

It also allows you to:

  • Set transform as seperate properties,
  • Provides x, y, and z shorthands for translate, and
  • Follows the latest CSS spec in ordering seperate transform props by translate, scale and rotate.
import css from 'stylefire/css';

const div = document.querySelector('div');
const divStyler = css(div);

divStyler.set({
  scale: 0.5,
  x: 100,
  y: 100,
  rotate: 45,
  background: '#f00'
});

transform is still supported for more complex transformations.

Demo on CodePen

Line drawing

Stylefire simplifies SVG line drawing. It works out the total path length and allows you to set pathLength, pathSpacing and pathOffset properties as percentages:

import { tween } from 'popmotion';
import svg from 'stylefire/svg';

const path = document.querySelector('path');
const pathStyler = svg(path);

tween({ to: 100 })
  .start((v) => pathStyler.set('pathLength', v));

Demo on CodePen

stroke-dasharray and stroke-dashoffset are still supported if you wish to work with these attributes directly.

Overriding render batching

By default, firing set will schedule a render on the next available frame. This way, we batch renders and help prevent layout thrashing.

This behaviour can be manually overridden with the render method.

import css from 'stylefire/css';

const div = document.querySelector('div');
const divStyler = css(div);

divStyler
  .set({ width: 500 })
  .render();

console.log(div.offsetWidth); // 500

divStyler.set({ width: 100 });

console.log(div.offsetWidth); // 500

divStyler.render();

console.log(div.offsetWidth); // 100

Demo on CodePen

Keywords

FAQs

Package last updated on 27 Feb 2018

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc