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

morpheus

v0.7.2

Published

A Brilliant Animator

Downloads

2,317

Readme

_  _ ____ ____ ___  _  _ ____ _  _ ____
|\/| |  | |__/ |__] |__| |___ |  | [__
|  | |__| |  \ |    |  | |___ |__| ___]

A Brilliant Animator.

Morpheus lets you "tween anything" in parallel on multiple elements; from colors to integers of any unit (px, em, %, etc), with easing transitions and bezier curves, including CSS3 transforms (roate, scale, skew, & translate) -- all in a single high-performant loop utilizing the CPU-friendly requestAnimationFrame standard.

It looks like this:

var anim = morpheus(elements, {
  // CSS
    left: -50
  , top: 100
  , width: '+=50'
  , height: '-=50px'
  , fontSize: '30px'
  , color: '#f00'
  , transform: 'rotate(30deg) scale(+=3)'
  , "background-color": '#f00'

    // API
  , duration: 500
  , easing: easings.easeOut
  , bezier: [[100, 200], [200, 100]]
  , complete: function () {
      console.log('done')
    }
})

// stop an animation
anim.stop()

// jump to the end of an animation and run 'complete' callback
anim.stop(true)

General Tweening

morpheus.tween(1000,
  function (position) {
    // do stuff with position...
    // like for example, use bezier curve points :)
    var xy = morpheus.bezier([[startX, startY], <[n control points]>, [endX, endY]], position)
  },
  function () {
    console.log('done')
  },
  easings.bounce,
  100, // start
  300 // end
)

API

/**
  * morpheus:
  * @param element(s): HTMLElement(s)
  * @param options: mixed bag between CSS Style properties & animation options
  *  - {n} CSS properties|values
  *     - value can be strings, integers,
  *     - or callback function that receives element to be animated. method must return value to be tweened
  *     - relative animations start with += or -= followed by integer
  *  - duration: time in ms - defaults to 1000(ms)
  *  - easing: a transition method - defaults to an 'easeOut' algorithm
  *  - complete: a callback method for when all elements have finished
  *  - bezier: array of arrays containing x|y coordinates that define the bezier points. defaults to none
  *     - this may also be a function that receives element to be animated. it must return a value
  * @return animation instance
  */

See the live examples

Language LTR - RTL support

For those who run web services that support languages spanning from LTR to RTL, you can use the drop-in plugin filed called rtltr.js found in the src directory which will automatically mirror all animations without having to change your implementation. It's pretty rad.

Browser support

Grade A & C Browsers according to Yahoo's Graded Browser Support. CSS3 transforms are only supported in browsers that support the transform specification.

Ender integration

Got Ender? No? Get it.

$ npm install ender -g

Add Morpheus to your existing Ender build

$ ender add morpheus

Write code like a boss:

$('#content .boosh').animate({
  left: 911,
  complete: function () {
    console.log('boosh')
  }
})

Usage Notes

Therefore, at minimum, you need to set a color before animating.

element.style.color = '#ff0';
morpheus(element, {
  color: '#000'
})

With Bonzo installed in Ender.

$('div.things').css('color', '#ff0').animate({
  color: '#000'
})
$('div.intro')
  .css({
      fontSize: '2em'
    , width: '50%'
  })
  .animate({
      fontSize: '+=1.5em'
    , width: '100%'
  })

You also get two other fancy fading hooks

$('p').fadeIn(250, function () {
  console.log('complete')
})

$('p').fadeOut(500, function () {
  console.log('complete')
})
element.style[morpheus.transform] = 'rotate(30deg) scale(1)'
morpheus(element, {
  transform: 'rotate(0deg) scale(+=3)'
})

AMD Support

require('morpheus.js', function (morpheus) {
  morpheus(elements, config)
})

or as usual with ender

var morpheus = require('morpheus')

Developers

If you're looking to contribute. Add your changes to src/morpheus.js Then run the following

npm install .
make
open tests/tests.html

Morpheus (c) Dustin Diaz 2011 - License MIT

Happy Morphing!