npm.io
1.0.2 • Published 3 years ago

simplyrotate-js

Licence
GPL-3.0-or-later
Version
1.0.2
Deps
0
Size
50 kB
Vulns
0
Weekly
0

simplyrotate-js

Package to rotate elements with js

Attribution to this post on stackoverflow for pointing out how to go about this. Figured that this is a feature that many people just need a one stop solution for (particularly myself included). So here this is for when I or anyone might need it later.

Usage:

HTML

<span class="rotatible"></span>

JavaScript

import { makeRotatable } from 'simplyrotate-js'

//get all elements classed rotatible
var rotatibleArr = document.querySelectorAll('.rotatible')
//for each of these called makeRotatable on them
rotatibleArr.forEach((r) => makeRotatable(r as HTMLElement))

and there you go...

It should just rotate on drag about the edges of your element

Keywords