rotator-js
v2.0.1
Published
A simple plugin to manage element rotations.
Readme
Rotator for JavaScript
A simple plugin to manage element rotations.
Installation
Yarn
$ yarn add rotator-jsNPM
$ npm install rotator-jsUsage
Say you have the
<img>that you want to rotate<img href="cat.png" id="my-image">You can use any HTML tag element that can accept the
styleattribute, not just the<img>s!In order to rotate it, you'll need 2 buttons (clockwise & anticlockwise) with ids prepended with the same
idas your<img>element<button id="my-image-anticlockwise-button">Anticlockwise Button</button> <button id="my-image-clockwise-button">Clockwise Button</button>After the page loads, require and create a new ImageRotator instance while passing your image's
idvar Rotator = require("rotator-js"); var rotator = new Rotator(["my-image"]);You can also setup multiple elements to be rotated at once by passing multiple element
ids!Call
configure()to configure the buttons to rotate the given elements.rotator.configure();That's all!
Now, the HTML element(s) whose id(s) was passed to Rotator, will be rotated clockwise/counter-clockwise when their corresponding buttons are clicked, respectively.
Limitations
Rotations are currently limited to 90° (clockwise) or -90° (counter-clockwise) per rotation.
Contributing
We'd love to accept your patches and contributions to this project! Checkout contributing and code of conduct to learn more.
License
Refer to the license file.
