/
githubmirror
/
fullPage.js
Обзор
Документация
Войти
/
githubmirror
/
fullPage.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/js/bindings.js
39 строк
1 KB
Alvaro Trigo López
- Refactoring: transforming event strings to properties
16 сен 2022, 15:33
16 сен 2022, 15:33
5c4dfc4
Код
Авторство
О чём код?
import * as utils from './common/utils.js'; import { EventEmitter } from './common/eventEmitter.js'; import { setState } from './common/state.js'; import { events } from './common/events.js'; EventEmitter.on(events.bindEvents, bindEvents); function bindEvents(){ //Scrolls to the section when clicking the navigation bullet //simulating the jQuery .on('click') event using delegation ['click', 'touchstart'].forEach(function(eventName){ utils.docAddEvent(eventName, delegatedEvents); }); utils.windowAddEvent('focus', focusHandler); internalEvents(); } function internalEvents(){ EventEmitter.on(events.onDestroy, onDestroy); } function delegatedEvents(e){ EventEmitter.emit(events.onClickOrTouch, {e: e, target: e.target}); } function onDestroy(){ ['click', 'touchstart'].forEach(function(eventName){ utils.docRemoveEvent(eventName, delegatedEvents); }); } // changing isWindowFocused to true on focus event function focusHandler(){ setState({isWindowFocused: true}); }