Security News
Namecheap Takes Down Polyfill.io Service Following Supply Chain Attack
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
shorter-js
Advanced tools
Readme
A small ES6/ES7 library with various JavaScript tools useful for creating light libraries. Featured in KUTE.js, BSN and other libraries.
dist
folder, that is mainly for build consistency testing.npm install shorter-js
// import the tool you need
import {supportTransform} from 'shorter-js'
// use the tool in your ES6/ES7 sources
if (supportTransform) {
doSomeAction()
}
perspective
transform
transition
passive
event option// EXAMPLES
import {support3DTransform} from 'shorter-js'
// filter myAction to supported browsers
if (support3DTransform) {
myAction()
}
// EXAMPLES
import {addClass,removeClass,hasClass} from 'shorter-js'
// add a class
addClass(targetElement,'className')
// remove a class
removeClass(targetElement,'className')
// check for a class
if (hasClass(targetElement,'className')) {
myAction()
}
// EXAMPLES
import {on,off,one,passiveHandler} from 'shorter-js'
// attach a passive mousedown eventHandler
on(targetElement,'click',eventHandler,passiveHandler)
// detach a passive mouseup eventHandler
off(targetElement,'mouseup',eventHandler,passiveHandler)
// attach a single instance passive touchstart eventHandler
one(targetElement,'touchstart',eventHandler,passiveHandler)
transitionend
event is triggered, or execute the callback right after for legacy browserstransitionDuration
property of a transition
propertyoptions
with passive: true event
option usedtry()
and catch()
wrapper for functions// EXAMPLES
import {queryElement,emulateTransitionEnd} from 'shorter-js'
// get some target
let targetElement = queryElement('.mySelectorClass');
// emulateTransitionEnd for the above
emulateTransitionEnd(targetElement,callback)
// check if element is in scroll range
// emulateTransitionEnd for the above
if (isElementInScrollRange(targetElement)){
doSomeAction()
}
mousedown
, up: mouseup
mouseenter
and mouseleave
OR mouseover
and mouseout
touchstart
, end: touchend
, move: touchmove
, cancel: touchcancel
transitionDuration
event property supported by the client browsertransitionend
event name supported by the client browser// EXAMPLES
import {on,off,one,mouseClickEvents,touchEvents,passiveHandler} from 'shorter-js'
// attach a passive mousedown eventHandler
on(targetElement,mouseClickEvents.down,eventHandler,passiveHandler)
// detach a passive mousedown eventHandler
off(targetElement,mouseClickEvents.down,eventHandler,passiveHandler)
// attach a single instance passive touchstart eventHandler
one(targetElement,touchEvents.start,eventHandler,passiveHandler)
To avoid adding un-necessary shorties into your code, you might want to import them directly from their location
// Example
import {on} from 'shorter-js/src/event/on.js'
import {addClass} from 'shorter-js/src/class/addClass.js'
FAQs
JavaScript shorties for the modern web.
The npm package shorter-js receives a total of 862 weekly downloads. As such, shorter-js popularity was classified as not popular.
We found that shorter-js demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Polyfill.io has been serving malware for months via its CDN, after the project's open source maintainer sold the service to a company based in China.
Security News
OpenSSF is warning open source maintainers to stay vigilant against reputation farming on GitHub, where users artificially inflate their status by manipulating interactions on closed issues and PRs.
Security News
A JavaScript library maintainer is under fire after merging a controversial PR to support legacy versions of Node.js.