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

@dnvr/transform

v1.0.13

Published

A library implements CSS Transforms in JavaScript.

Downloads

32

Readme

Transform

A CSS Transform library.

Greater things to come...

Install

npm install @dnvr/transform

How it works

Transform provides a way to write CSS compute CSS Transform Matrices using JavaScript / TypeScript.

This includes chainable methods for all CSS Transform functions except of course matrix and matrix3d.

Methods that take length parameters such as translateX, translateY, translateZ, translate and translate3d and perspective take the same number of parameters as their CSS counterpart, with the numbers being in the px unit.

Methods dealing with angles rotate, rotateX, rotateY, rotateZ, rotate3d, skew, skewX, and skewY use degree as their unit, while similar methods with the Rad infix use radians.

Plain numbers work as is in methods such as scale, scale3d, scaleX, scaleY, scaleZ and rotate3d.

The final property string can be obtained using the css method.

The library also provides alterDial, a method that allows an effect similar to ScrollTimeline.

Note

The import is called dirtyTransform as it is a quick and dirty implementation of DOMMatrix. There is a roadmap to improve the library and I'd like to reserve the term transform when it's implemented. This is also why dirtyTransform is not a default import.

Usage

import {

  dirtyTransform

} from '@dnvr/transform'

let el = document.querySelector( 'element-of-interest' )

// The following will displace the element rightward by 100px
el.style.transform = dirtyTransform().translateX( 100 ).css()

// The following will displace the element downward by 50px
// Note the absence of the .css() method when placed within a template string
el.style.transform = `${ dirtyTransform( 0.5 ).translateY( 50 ) }`

// The following will rotate the element clockwise by a quarter turn which is a composition of a half turn clockwise and a quarter ( a half of a half ) turn counter-clockwise
// Note the chaining of methods
el.style.transform = dirtyTransform().rotate( 180 ).alterDial( 0.5 ).rotate( -180 ).css()