Skip to content

Commit a9406ba

Browse files
committed
add index.js.flow
1 parent 3ce741c commit a9406ba

File tree

11 files changed

+167
-103
lines changed

11 files changed

+167
-103
lines changed

example/.eslintrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"root": true,
3+
"extends": "react-app"
4+
}

example/.flowconfig

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
[ignore]
2+
3+
[include]
4+
5+
[libs]
6+
7+
[lints]
8+
9+
[options]
10+
11+
[strict]

example/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"license": "MIT",
66
"private": true,
77
"dependencies": {
8+
"flow-bin": "^0.81.0",
89
"react": "^16.4.1",
910
"react-dom": "^16.4.1",
1011
"react-router-dom": "^4.3.1",

example/yarn.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2795,6 +2795,10 @@ flatten@^1.0.2:
27952795
version "1.0.2"
27962796
resolved "https://registry.yarnpkg.com/flatten/-/flatten-1.0.2.tgz#dae46a9d78fbe25292258cc1e780a41d95c03782"
27972797

2798+
flow-bin@^0.81.0:
2799+
version "0.81.0"
2800+
resolved "https://registry.yarnpkg.com/flow-bin/-/flow-bin-0.81.0.tgz#7f0a733dce1dad3cb1447c692639292dc3d60bf5"
2801+
27982802
follow-redirects@^1.0.0:
27992803
version "1.5.8"
28002804
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.8.tgz#1dbfe13e45ad969f813e86c00e5296f525c885a1"

package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-scrollmagic",
3-
"version": "1.0.5",
3+
"version": "1.0.6",
44
"description": "React declarative component for ScrollMagic",
55
"author": "bitworking",
66
"license": "MIT",
@@ -37,21 +37,20 @@
3737
"eslint-config-react-app": "^2.1.0",
3838
"eslint-config-standard": "^11.0.0",
3939
"eslint-config-standard-react": "^6.0.0",
40-
"eslint-plugin-flowtype": "2.34.1",
4140
"eslint-plugin-import": "2.6.0",
4241
"eslint-plugin-jsx-a11y": "5.1.1",
4342
"eslint-plugin-node": "^7.0.1",
4443
"eslint-plugin-promise": "^4.0.0",
4544
"eslint-plugin-react": "7.1.0",
4645
"eslint-plugin-standard": "^3.1.0",
47-
"flow-bin": "^0.81.0",
4846
"gh-pages": "2.0.0",
4947
"react": "^16.4.1",
5048
"react-dom": "^16.4.1",
5149
"react-scripts": "^1.1.4",
5250
"rollup": "^0.64.1",
5351
"rollup-plugin-babel": "^3.0.7",
5452
"rollup-plugin-commonjs": "^9.1.3",
53+
"rollup-plugin-cpy": "^1.0.0",
5554
"rollup-plugin-node-resolve": "^3.3.0",
5655
"rollup-plugin-peer-deps-external": "^2.2.0",
5756
"rollup-plugin-postcss": "^1.6.2",

rollup.config.js

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import external from 'rollup-plugin-peer-deps-external'
44
import postcss from 'rollup-plugin-postcss'
55
import resolve from 'rollup-plugin-node-resolve'
66
import url from 'rollup-plugin-url'
7+
import copy from 'rollup-plugin-cpy'
78

89
import pkg from './package.json'
910

@@ -32,6 +33,13 @@ export default {
3233
plugins: [ 'external-helpers' ]
3334
}),
3435
resolve(),
35-
commonjs()
36+
commonjs(),
37+
copy({
38+
files: 'src/index.js.flow',
39+
dest: 'dist',
40+
options: {
41+
verbose: true
42+
}
43+
})
3644
]
3745
}

src/SMController.js

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,12 @@
1-
// @flow
21
import { default as React } from 'react';
3-
import type { Node } from 'react';
42
import { default as ScrollMagic } from 'scrollmagic';
53

6-
type Props = {
7-
children: Node,
8-
container?: any,
9-
vertical?: boolean,
10-
globalSceneOptions?: any,
11-
loglevel?: number,
12-
refreshInterval?: number,
4+
export const SMContext = React.createContext();
135

14-
}
15-
16-
type State = {
17-
controller: ?any,
18-
}
19-
20-
export const SMContext = React.createContext('scrollMagic');
21-
22-
class SMController extends React.Component<Props, State> {
6+
class SMController extends React.Component<SMControllerProps, SMControllerState> {
237
controller: any;
248

25-
state: State = {
9+
state: SMControllerState = {
2610
controller: null,
2711
}
2812

src/SMScene.js

Lines changed: 4 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,14 @@
1-
// @flow
21
import { default as React, Fragment } from 'react';
3-
import type { Node } from 'react';
4-
import { SMContext } from './SMController';
52
import { default as ScrollMagic } from 'scrollmagic';
63
import { TimelineMax as Timeline, TweenMax as Tween } from 'gsap/TweenMax';
74
import 'gsap/TextPlugin';
85
import animationGsap from './animation.gsap.js';
96
import debugAddIndicators from './debug.addIndicators.js';
7+
import { SMContext } from './SMController';
108

119
animationGsap(ScrollMagic, Timeline, Tween);
1210
debugAddIndicators(ScrollMagic);
1311

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-
7412
const getTweenFunction = (element, tween) => {
7513
const {
7614
target,
@@ -112,10 +50,10 @@ const getTweenFunction = (element, tween) => {
11250
return tweenFunction;
11351
};
11452

115-
class SMSceneBase extends React.PureComponent<PropsBase, State> {
53+
class SMSceneBase extends React.PureComponent<SMSceneBaseProps, SMSceneBaseState> {
11654
ref: HTMLElement;
11755
scene: any;
118-
state = {
56+
state: SMSceneBaseState = {
11957
event: 'init',
12058
progress: 0,
12159
}
@@ -303,7 +241,7 @@ class SMSceneBase extends React.PureComponent<PropsBase, State> {
303241
}
304242
}
305243

306-
class SMScene extends React.PureComponent<Props, {}> {
244+
class SMScene extends React.PureComponent<SMSceneProps, {}> {
307245
static displayName = 'SMScene';
308246

309247
render() {

src/index.js.flow

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
import { default as React } from 'react';
2+
import type { Node } from 'react';
3+
4+
export type SMControllerProps = {
5+
children: Node,
6+
container?: any,
7+
vertical?: boolean,
8+
globalSceneOptions?: any,
9+
loglevel?: number,
10+
refreshInterval?: number,
11+
12+
}
13+
14+
export type SMControllerState = {
15+
controller: ?any,
16+
}
17+
18+
declare class SMController extends React.Component<SMControllerProps, SMControllerState> {}
19+
20+
export { SMController };
21+
22+
export type Tween = {
23+
target?: any,
24+
duration?: number,
25+
from?: any,
26+
to?: any,
27+
staggerFrom?: any,
28+
staggerTo?: any,
29+
stagger?: number,
30+
onCompleteAll?: Function,
31+
position?: number | string,
32+
}
33+
34+
export type PinSettings = {
35+
pushFollowers?: boolean,
36+
spacerClass?: string,
37+
}
38+
39+
export type Timeline = {
40+
tweens: Array<Tween>,
41+
delay?: number,
42+
stagger?: number,
43+
align?: 'sequence' | 'start' | 'normal',
44+
repeat?: number,
45+
repeatDelay?: number,
46+
yoyo?: boolean,
47+
}
48+
49+
export type SMSceneProps = {
50+
children: Node | Function,
51+
52+
// scene parameters
53+
duration?: number | string,
54+
offset?: number | string,
55+
triggerElement?: any,
56+
triggerHook?: any,
57+
reverse?: boolean,
58+
loglevel?: number,
59+
indicators?: boolean,
60+
enabled?: boolean,
61+
62+
/* setClassToggle */
63+
classToggle?: string | Array<string>,
64+
65+
/* setPin */
66+
pin?: boolean | string,
67+
pinSettings?: PinSettings,
68+
69+
/* setTween */
70+
tween?: Tween,
71+
72+
timeline?: Timeline,
73+
74+
}
75+
76+
export type SMSceneBaseProps = SMSceneProps & {
77+
context: any,
78+
}
79+
80+
export type SMSceneBaseState = {
81+
event: string,
82+
progress: number,
83+
}
84+
85+
declare class SMSceneBase extends React.PureComponent<SMSceneBaseProps, SMSceneBaseState> {}
86+
87+
declare class SMScene extends React.PureComponent<SMSceneProps, {}> {}
88+
89+
export { SMScene };

src/test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import SMController from './';
2-
import SMScene from './';
1+
import { SMController } from './';
2+
import { SMScene } from './';
33

44
describe('SMController', () => {
55
it('is truthy', () => {

0 commit comments

Comments
 (0)