events-machine
v0.9.5
Published
events
Downloads
20
Readme
INSTALL
npm i events-machine
Машина событии, обертка над addEventListener/removeEventListener, для удобного наложении событии на множество DOM элементов Так-же хранение всех событии в массиве, потому можно удалять события зная лишь DOM элемент либо dom + функцию(callback), комбинировать функции и наложении множество каллбэков на группу DOM элементов или на один DOM элемент.
create() - Создание события
Принимает 3 параметра
1. Dom элемент(либо строку, строка будет равнятся ID элемента) или массив элементов к которым надо добавить событие
2. событие на которое должен отреагировать названия событиям == названиям событии в addEventListener
3. callback - функция или массив функции которые должны выполнится после выполнения события
remove - Удаления события
Принимает до 3 элементов(такие же как и при удалении) однако имеет особенности
1. Удаление всех событий у конкретного DOM элемента (dom)
2. Удаления событии у DOM элемента который привязан к данной функции(dom+func)
3. Удаление всех событии по типу событии(dom + event_type)
removeAll - Удаление всех зарегистрированных событии
Примеры:
import {Events} from 'event_machine';
Events.create("DOM", "click", function(){})
Events.remove("DOM")
Events.remove("DOM", Func)
Events.remove("Dom", "click")
Events.removeAll()
В случае каких либо ошибок, пишите, писал для своего проекта и ошибок обнаружено небыло.