/
githubmirror
/
fullPage.js
Обзор
Документация
Войти
/
githubmirror
/
fullPage.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/js/anchors/setPageStatus.js
65 строк
2 KB
Alvaro Trigo López
- Fixed bug: destroy('all') will keep empty anchor # on the URL #4729
12 дек 2025, 19:10
12 дек 2025, 19:10
3985128
Код
Авторство
О чём код?
import { win } from "../common/constants.js"; import { getOptions } from "../common/options.js"; import { setState } from "../common/state.js"; import { setBodyClass } from "../stateClasses.js"; import { EventEmitter } from '../common/eventEmitter.js'; import { events } from '../common/events.js'; EventEmitter.on(events.onDestroyAll, onDestroyAll); function onDestroyAll(){ // removing hash + # symbol from the URL win.history.replaceState(null, '', win.location.pathname + window.location.search); } /** * Sets the state of the website depending on the active section/slide. * It changes the URL hash when needed and updates the body class. */ export function setPageStatus(slideIndex, slideAnchor, anchorLink){ var sectionHash = ''; if(getOptions().anchors.length && !getOptions().lockAnchors){ //isn't it the first slide? if(slideIndex){ if(anchorLink != null){ sectionHash = anchorLink; } //slide without anchor link? We take the index instead. if(slideAnchor == null){ slideAnchor = slideIndex; } setState({lastScrolledSlide: slideAnchor}); setUrlHash(sectionHash + '/' + slideAnchor); //first slide won't have slide anchor, just the section one }else if(slideIndex != null){ setState({lastScrolledSlide: slideAnchor}); setUrlHash(anchorLink); } //section without slides else{ setUrlHash(anchorLink); } } setBodyClass(); } /** * Sets the URL hash. */ function setUrlHash(url){ if(getOptions().recordHistory){ location.hash = url; } else{ win.history.replaceState(undefined, undefined, '#' + url); } }