-
Notifications
You must be signed in to change notification settings - Fork 7.3k
/
prepareDom.js
74 lines (61 loc) · 2.4 KB
/
prepareDom.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
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 { scrollOverflowHandler } from '../scrolloverflow.js';
import {
WRAPPER,
ENABLED,
DESTROYED
} from '../common/selectors.js';
import { addInternalSelectors } from './addInternalSelectors.js';
/**
* Works over the DOM structure to set it up for the current fullpage getOptions().
*/
export function prepareDom(){
utils.css(getContainer(), {
'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')
section.item.setAttribute('data-fp-styles', utils.getAttr(section.item, 'style'));
styleSection(section);
styleMenu(section);
// if there's any slide
if (slides.length > 0) {
styleSlides(section);
}else{
addTableClass(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();
}