Rotator for JavaScript
A simple plugin to manage element rotations.
Installation
Yarn
$ yarn add rotator-js
NPM
$ npm install rotator-js
Usage
-
Say you have the
<img>
that you want to rotateYou 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>
elementAnticlockwise ButtonClockwise Button -
After the page loads, require and create a new ImageRotator instance while passing your image's
id
var Rotator = ;var 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; -
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.