A simple plugin to manage element rotations.
$ yarn add rotator-js
$ npm install rotator-js
-
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
style
attribute, not just the<img>
s! -
In order to rotate it, you'll need 2 buttons (clockwise & anticlockwise) with ids prepended with the same
id
as 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
id
var 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
id
s! -
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.
Rotations are currently limited to 90° (clockwise) or -90° (counter-clockwise) per rotation.
We'd love to accept your patches and contributions to this project! Checkout contributing and code of conduct to learn more.
Refer to the license file.