Micron.JS is a micro interaction library which can be used to add Interactions to different DOM Elements. Micron.JS animates an element using CSS power and the interactive behaviours are controlled by JavaScript.
Micron.JS is easy to adapt and can bring interactions to life using html5 data attributes or a chain of JavaScript methods.
To get started with Micron.JS, you need to include both micron.min.css * (which have all ready to use interaction animations) and micron.min.js
* If you don't need all the available interactions, you can simply include the respective *.min.css file only.
Compiled CSS and JavaScript minified files can be directly linked from unpkg.com CDN or Micron.JS can be included within your workflow using your favorite package managers as well.
Include both the Micron CSS and JavaScript files in the header section of your document.
You can use either npm or bower to get the Micron.JS package
Copy and Paste the command below in your terminal to get package with npm -
npm install webkul-micron
Copy and Paste the command below in your terminal to get package with bower -
bower install webkul-micron
Micron JS is very easy and quick to use.
Add the data-micron="interaction" attribute to the respective element and Voila! you are already there.
Example Code
Example Code Preview
LabelMicron Interactions defaults to ".45" seconds. Add the data-micron-duration="number" attribute to control the duration of the defined interaction.
Example Code
Example Code Preview
LabelMicron Interactions defaults to "ease-in-out". Add the data-micron-timing="@type" attribute to control the easing of the defined interaction.
For now, @typeonly supports the easings mentioned below-
linear
ease-in
ease-out
ease-in-out
Example Code
Example Code Preview
LabelAdd data-micron-bind="true" & data-micron-id="name" to the defined triggering element, and interaction will be applied to the element which reference to the defined id attribute.
Example Code
Example Code Preview
Label BindedCall micron chained methods to apply interactions to any DOM Element, right in your custom block of JavaScript Code.
micron.getEle("").interaction("").duration("").timing("");Pass an argument with selector name which can either be id or a class to getEle() method.
Pass an argument with interaction name to interaction() method.
Pass an argument which is a number to duration() method.
Pass an argument with type of ease to timing() method.
Example Code
Currently, Micron.JS supports the interactions mentioned below, head back to the Homepage to see all interactions in the real action.
data-micron="shake"
data-micron="fade"
data-micron="jelly"
data-micron="bounce"
data-micron="tada"
data-micron="groove"
data-micron="swing"
data-micron="squeeze"
data-micron="flicker"
data-micron="jerk"
data-micron="blink"
data-micron="pop"
You can even add your very own css interaction to Micron.JS.
First include the code mentioned below in your css file.
Create a class with .mjs- prefix. Call the keyframe css animation inside it. Use the interaction with your class name without .mjs- prefix.
Example Code
Now use interaction withdata-micron="custom"
Have you created a pen or a fiddle; or using Micron.JS in any of your live projects. It will be showcased right here in the front of entire the community.
© Copyright 2018 Webkul Software, All rights reserved.
Kudos to Vipin Sahu, Ratnesh Kumar and Nikhil Malik from the Author.