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

transhand

v0.2.0

Published

A 2d transformation manager for graphic editor tools

Downloads

38

Readme

npm

Transhand is a React based 2d transformation tool. It's aiming to have all the features that you would expect from a transform handler in a modern graphic editor.

###Demos nested, custom, iframe(wip)

Developed as part of the Animachine project.

###Install

npm install --save transhand

###Current features

  • translate, rotate, scale, move transform origin
  • shift + guided scale/move/rotate
  • alt + scale from the opposite side

###Basic usage

import { Transhand } from 'transhand'

//the current transformation
var transform = {
  tx: 0, ty: 0,     //translate in px
  sx: 1, sy: 1,     //scale
  rz: 0,            //rotation in radian
  ox: 0.5, oy: 0.5, //transform origin
}
//the bounding box without transformations
var rect = {x: 10, y: 10, w: 100, h: 100}
var onChange = (change) => {
  //change object contains only the changed properties
  //ex. change = {tx: -12, sx: 1.12}
}

<Transhand
  transform = {transform}
  rect = {rect}
  onChange = {onChange}/>

###Basic usage with CSS Transform

import { CSSTranshand } from 'transhand'

<CSSTranshand
  transform = {transform}
  deTarget = {transformedDOMElement}
  onChange = {onChange}/>

CSSTranshand is a wrapper for Transhand. It use the provided DOM Element to calculate the rect and handle if the parent elements are onalso transformed and when deTarget is inside an iframe.

###API ####Transhand

  • transform: see above
  • rect: see above
  • stroke = {strokeWidth: '1', stroke: 'lime'}: A set of svg attributes to customize drawed svg.

events:

  • onChange(change): see above
  • onClick(mouseEvent): Called on the user just clicks on the handler and not changing it. Useful for selecting items behind the handler.
  • onStartDrag: Called on the user grab the handler.
  • onEndDrag: Called on the user release the handler.

advanced customization:

  • rotateFingerDist = 16: The width of the rotate hit area.
  • originRadius = 6: The radius of the transform origin hit area.
  • coordinator = new DefaultCoordinator(): Use this to change the way as Transhand convert global coordinates into its local coordinate system (ex. mouse positions) and back (ex. render to screen). Coordinator is an object with two functions globalToLocal(point):point and localToGlobal(point):point. If you need more detail check out the source.
  • grabEvent: If this parameter is presented Transhand will simulate the mouse down event with it. It's useful when you want to drag the target immediately after selecting it with mouse down. See it in use in the demo sources.
  • hints = default: Map of tooltips for the different transformation types.
  • cursors = new Cursors(): Map of cursors for the different transformation types.
  • DesignComponent = TranshandDesign: You can replace the basic Component that Transhand renders to fully customize its appearance.
  • CursorHintDesignComponent = CursorHintDesign: You can replace the basic Component that CursorHint renders to fully customize its appearance.
  • transformTypes = ['translate', 'rotate', 'scale', 'origin']: List of the allowed transform functions.

####CSSTranshand Inherits all the properties of transhand but replaces coordinator and rect with an extra property called deTarget. see above

Although it's already usable, most of the features are still in progress. If you find something that is may not working as expected or you miss something do not hesitate to open an issue!