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

grunt-path-to-animation

v0.1.1

Published

Predefine CSS keyframe animations by interpolating array of points

Downloads

35

Readme

grunt-path-to-animation

Getting Started

If you haven't used Grunt before, be sure to check out the Getting Started guide, as it explains how to create a Gruntfile as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:

npm install grunt-path-to-animation --save-dev

Once the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:

grunt.loadNpmTasks('grunt-path-to-animation');

Synopsis

Use to generate scss files with predefined @keyframes animations by reading configuration of paths to be interpolated.

Why would you need this?

  • Do you want to have smooth css animations you don't want to handle by java script?
  • Do you need to pause them?
  • Do you need to resize and keep the animated element's position?
  • Do you want to write such animation manually? And rewrite them every time the client changes the design?
  • Animations using translate instead of top/left positioning are considered as better performance and calculating translate movement manually could be painfully sometimes.

path-to-animation needs just a JSON file with animations paths you would need and it will interpolate them and create the file with predefined @keyframes animations you need.

path-to-animation task

Run this task with the grunt path-to-animation command.

Usage Examples

'path-to-animation': {
	'customTask': {
		
		// Points to the file containing animation path arrays
		src: 'animation-paths.json',
  
        // where to save the sass file when ready
        dest: './output/outputfile.scss',
        
        // property name to read from. It will be used for the css class name
        //  and for the css @keyframes name.
        // the namespace should contain valid css class names characters
        namespace: 'custom-namespace-name',
        
        // we need the size of the animated element in order to calculate the translate values
        elementSize: {
          width: 100,
          height: 100
        },
        
        // which sass mixin to @include (this should be  created by the user)s
        //  the default is 'curved-animation'
        sassMixin: 'sassence',
      }
  },
},

options:

src

  • Description: The JSON file contains animation path arrays
  • Type: String
  • Default: animation-paths.json
  • Example file: JSON file example

dest

  • Description: The destination path for the output SASS file
  • Type: String

namespace

  • Description: Current subtask namespace to read the animations from. It will be used for the generates @keyframes and css class name.
  • Type: String

elementSize

  • Description: The Object contains width and height of the animated element. It's needed in order to calculate the path related to its size in percentages.
  • Type: Object
  • elementSize.width - Type: Number|String
  • elementSize.height - Type: Number|String

sassMixin

  • Description: The name of the sass mixin to be used for the generated css class.
  • Type: String
  • Default: curved-animation

JSON file example:

Here is how we expect your JSON file to look like:

{
	"custom-namespace-name": {
		"item1": [50,50, 70,400, 500, 600, 100, 100],
		"item2": [100, 200, 300, 400]
	},
	"another-namespace": {
		"item1": [400,500, 600, 700]
	}
}

// The path could be flat array in that format:
"item1": [x,y, x,y, x,y]

// or it could be nested:
"item2": [
	[x,y],
	[x,y]
]

The @keyframes name and the css class name will be as follows:

// the @keyframes:
@keyframes custom-namespace-name-item1 { ... }

// the class that will be applied to trigger the animation:
.animated-namespace-name-item1 { ... }

Dependancies

We depend on SASS. We expect the developers to use SASS in the project they plan to use path-to-animation

Why?

In order to give to the developers the freedom to add any animation rules to the generated animations without configuring templates we rely on using SASS for the generated content.

You will be obligated to provide sassMixin for the mixin name you have created already.

Example:

There should be an existing sass code in your project containing mixin like this:

@mixin my-custom-mixin-name($animationName) {
	animation-duration: 10s;
	animation-delay: 300ms;
	animation-name: $animationName
}

The Gruntfile configuration contains:

namespace: 'my-namespace',
sassMixin: 'my-custom-mixin-name',

When we are ready, we will generate css class for you containing:

@include my-custom-mixin-name(my-namespace-item1);

Test

Run

npm install
npm test

Other tools:

Changelog

  • 0.1.1 - Synchronize version numbers between the path-to-animation modules
  • 0.1.0 - Separating path-to-animation in a separate module. There's no changes in the API.
  • 0.0.1 - Initial version

Contributions

If you have any suggestions or the tool doesn't cover your needs, don't hasitate to fork us or send us an email [email protected]. Every comment or contribution will be very appreciated.

MIT License

Copyright (c) 2016 Mobile Wave Solutions ([email protected])

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.