bind-event
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

bind-event

Bind event handler for all browsers by adding prefix automaticlly.

Install

npm install bind-event --save

Usage

import bindEvent from 'bind-event';
 
// bind some event
bindEvent(
    document.getElementById('some-element'),
    'transitionend',
    function(evt) {
        if (evt.propertyName == 'opacity' && !evt.target.style.opacity)
            evt.target.parentNode.removeChild(evt.target)
    }
)

result

If client's browser support transitionend event type, it will bind listener function directly to the element. If not, it will automaticlly bind listener function to event type prefix with vendor prefix, such as webkitTransitionend, mozTransitionend, etc...

Options

bindEvent( HTMLElement, type, listener[, options] );
bindEvent( HTMLElement, type, listener[, useCapture] );

HTMLElement

The Element object you want bind for.

type, listener, options, useCapture

The same as EventTarget.addEventListener(), read more at MDN.

Readme

Keywords

none

Package Sidebar

Install

npm i bind-event

Weekly Downloads

4

Version

1.1.2

License

MIT

Unpacked Size

3.99 kB

Total Files

5

Last publish

Collaborators

  • diablohu