|
1 | | -// @flow |
2 | 1 | import { default as React, Fragment } from 'react'; |
3 | | -import type { Node } from 'react'; |
4 | | -import { SMContext } from './SMController'; |
5 | 2 | import { default as ScrollMagic } from 'scrollmagic'; |
6 | 3 | import { TimelineMax as Timeline, TweenMax as Tween } from 'gsap/TweenMax'; |
7 | 4 | import 'gsap/TextPlugin'; |
8 | 5 | import animationGsap from './animation.gsap.js'; |
9 | 6 | import debugAddIndicators from './debug.addIndicators.js'; |
| 7 | +import { SMContext } from './SMController'; |
10 | 8 |
|
11 | 9 | animationGsap(ScrollMagic, Timeline, Tween); |
12 | 10 | debugAddIndicators(ScrollMagic); |
13 | 11 |
|
14 | | -type TweenType = { |
15 | | - target?: any, |
16 | | - duration?: number, |
17 | | - from?: any, |
18 | | - to?: any, |
19 | | - staggerFrom?: any, |
20 | | - staggerTo?: any, |
21 | | - stagger?: number, |
22 | | - onCompleteAll?: Function, |
23 | | - position?: number | string, |
24 | | -} |
25 | | - |
26 | | -type Props = { |
27 | | - children: Node | Function, |
28 | | - |
29 | | - // scene parameters |
30 | | - duration?: number | string, |
31 | | - offset?: number | string, |
32 | | - triggerElement?: any, |
33 | | - triggerHook?: any, |
34 | | - reverse?: boolean, |
35 | | - loglevel?: number, |
36 | | - indicators?: boolean, |
37 | | - enabled?: boolean, |
38 | | - |
39 | | - /* setClassToggle */ |
40 | | - classToggle?: string | Array<string>, |
41 | | - |
42 | | - /* setPin */ |
43 | | - pin?: boolean | string, |
44 | | - pinSettings?: { |
45 | | - pushFollowers?: boolean, |
46 | | - spacerClass?: string |
47 | | - }, |
48 | | - |
49 | | - /* setTween */ |
50 | | - tween?: TweenType, |
51 | | - |
52 | | - timeline?: { |
53 | | - tweens: Array<TweenType>, |
54 | | - delay?: number, |
55 | | - stagger?: number, |
56 | | - align?: 'sequence' | 'start' | 'normal', |
57 | | - repeat?: number, |
58 | | - repeatDelay?: number, |
59 | | - yoyo?: boolean, |
60 | | - |
61 | | - }, |
62 | | - |
63 | | -} |
64 | | - |
65 | | -type PropsBase = Props & { |
66 | | - context: any, |
67 | | -} |
68 | | - |
69 | | -type State = { |
70 | | - event: string, |
71 | | - progress: number, |
72 | | -} |
73 | | - |
74 | 12 | const getTweenFunction = (element, tween) => { |
75 | 13 | const { |
76 | 14 | target, |
@@ -112,10 +50,10 @@ const getTweenFunction = (element, tween) => { |
112 | 50 | return tweenFunction; |
113 | 51 | }; |
114 | 52 |
|
115 | | -class SMSceneBase extends React.PureComponent<PropsBase, State> { |
| 53 | +class SMSceneBase extends React.PureComponent<SMSceneBaseProps, SMSceneBaseState> { |
116 | 54 | ref: HTMLElement; |
117 | 55 | scene: any; |
118 | | - state = { |
| 56 | + state: SMSceneBaseState = { |
119 | 57 | event: 'init', |
120 | 58 | progress: 0, |
121 | 59 | } |
@@ -303,7 +241,7 @@ class SMSceneBase extends React.PureComponent<PropsBase, State> { |
303 | 241 | } |
304 | 242 | } |
305 | 243 |
|
306 | | -class SMScene extends React.PureComponent<Props, {}> { |
| 244 | +class SMScene extends React.PureComponent<SMSceneProps, {}> { |
307 | 245 | static displayName = 'SMScene'; |
308 | 246 |
|
309 | 247 | render() { |
|
0 commit comments