-
Notifications
You must be signed in to change notification settings - Fork 7.3k
/
state.js
45 lines (40 loc) · 1000 Bytes
/
state.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
import * as utils from './utils.js';
export const state = {
numSections: 0,
numSlides: 0,
slides: [],
sections: [],
activeSection: null,
scrollTrigger: null,
isBeyondFullpage: false,
aboutToScrollToFullPage: false,
slideMoving: false,
isResizing: false,
isScrolling: false,
lastScrolledDestiny: undefined,
lastScrolledSlide: undefined,
activeAnimation: false,
canScroll: true,
touchDirection: 'none',
direction: 'none',
isGrabbing: false,
isWindowFocused: true,
previousDestTop: 0,
windowsHeight: utils.getWindowHeight(),
isDoingContinousVertical: false
};
// @ts-ignore
window.state = state;
export function setState(props){
Object.assign(state, props);
}
export function getState(){
return state;
}
export function getActiveDefaultSection(sections){
var section = sections.filter(section => section.isActive);
if(!section.length){
return sections[0];
}
return section[0];
}