/
githubmirror
/
fullPage.js
Обзор
Документация
Войти
/
githubmirror
/
fullPage.js
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/js/dom/prepareDom.js
80 строк
3 KB
Alvaro Trigo López
- Fixed bug: destroy("all") not removing all styles #4537
29 май 2023, 17:24
29 май 2023, 17:24
8ee9e41
Код
Авторство
О чём код?
import * as utils from '../common/utils.js'; import { $html, $body } from '../common/cache.js'; import { addTableClass } from '../common/addTableClass.js'; import { getState, setState } from '../common/state.js'; import { getOptions, getContainer } from '../common/options.js'; import { styleSection } from '../sections.js'; import { styleSlides } from '../slides/styleSlides.js'; import { styleMenu } from '../menu/styleMenu.js'; import { addVerticalNavigation } from '../nav/sections.js'; import { enableYoutubeAPI } from '../media.js'; import { WRAPPER, ENABLED, DESTROYED } from '../common/selectors.js'; import { addInternalSelectors } from './addInternalSelectors.js'; import { scrollOverflowHandler } from '../scrolloverflow.js'; /** * Works over the DOM structure to set it up for the current fullpage getOptions(). */ export function prepareDom(){ utils.css(utils.getParentsUntil(getContainer(), 'body'), { 'height': '100%', 'position': 'relative' }); //adding a class to recognize the container internally in the code utils.addClass(getContainer(), WRAPPER); utils.addClass($html, ENABLED); //due to https://github.com/alvarotrigo/fullPage.js/issues/1502 setState({windowsHeight: utils.getWindowHeight()}); utils.removeClass(getContainer(), DESTROYED); //in case it was destroyed before initializing it again addInternalSelectors(); var sections = getState().sectionsIncludingHidden; //styling the sections / slides / menu for(var i = 0; i<sections.length; i++){ var sectionIndex = i; var section = sections[i]; var slides = section.allSlidesItems; //caching the original styles to add them back on destroy('all') var originalStyles = utils.getAttr(section.item, 'style'); if(originalStyles){ section.item.setAttribute('data-fp-styles', originalStyles); } styleSection(section); styleMenu(section); // if there's any slide if (slides.length > 0) { styleSlides(section); } } //fixed elements need to be moved out of the plugin container due to problems with CSS3. if(getOptions().fixedElements && getOptions().css3){ utils.$(getOptions().fixedElements).forEach(function(item){ $body.appendChild(item); }); } //vertical centered of the navigation + active bullet if(getOptions().navigation){ addVerticalNavigation(); } enableYoutubeAPI(); if(getOptions().scrollOverflow){ scrollOverflowHandler.makeScrollable(); } }