/
githubmirror
/
fullPage.js
Обзор
Документация
Войти
/
githubmirror
/
fullPage.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/js/slides/index.js
45 строк
1 KB
Alvaro Trigo López
- Fixed bug: getScrollX won't return the right value on afterLoad #4652
30 авг 2024, 12:51
30 авг 2024, 12:51
bb21c5c
Код
Авторство
О чём код?
import { nullOrSlide } from '../callbacks/nullOrSlide.js'; import { EventEmitter } from '../common/eventEmitter.js'; import { getState, setState, state } from '../common/state.js'; import { landscapeScroll, onDestroy } from './landscapeScroll.js'; import { moveSlideLeft, moveSlideRight } from './moveSlide.js'; import { FP } from '../common/constants.js'; import { events } from '../common/events.js'; FP.getActiveSlide = getActiveSlide; FP.getScrollX = function(){ return state.scrollX; }; EventEmitter.on(events.bindEvents, bindEvents); function bindEvents(){ EventEmitter.on(events.onDestroy, onDestroy); EventEmitter.on(events.landscapeScroll, function(params){ landscapeScroll(params.slides, params.destination); }); EventEmitter.on(events.moveSlideRight, function(params){ moveSlideRight(params.section); }); EventEmitter.on(events.moveSlideLeft, function(params){ moveSlideLeft(params.section); }); EventEmitter.on(events.afterSectionLoads, updateScrollX); } function updateScrollX(params){ var activeSlide = params.items.destination.activeSlide; var scrollX = activeSlide ? Math.round(activeSlide.offsetLeft) : 0; setState({ scrollX: scrollX }); } /** * Gets the active slide. */ export function getActiveSlide(){ return nullOrSlide(getState().activeSection.activeSlide); }