Skip to content

Commit dda8aa8

Browse files
authored
Merge pull request #32 from signal-noise/progress-silencer
Silence Progress Events
2 parents 597f40c + 9ffd15a commit dda8aa8

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,7 @@ classToggle | string or string[2] | yes | undefined | [link](http://scrollmagic.
8787
pin | boolean or string | yes | undefined | [link](http://scrollmagic.io/docs/ScrollMagic.Scene.html#setPin)
8888
pinSettings | PinSettings | yes | undefined | See Types and [link](http://scrollmagic.io/docs/ScrollMagic.Scene.html#setPin)
8989
enabled | boolean | yes | true | Can be changed on-the-fly
90+
progressEvents | boolean | yes | true | Ability to silence progress events reducing redraws
9091

9192
## Types
9293

src/Scene.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ export type SceneProps = {
2323
loglevel?: number,
2424
indicators?: boolean,
2525
enabled?: boolean,
26+
progressEvents?: boolean,
2627

2728
/* setClassToggle */
2829
classToggle?: string | Array<string>,
@@ -198,7 +199,7 @@ class SceneBase extends React.PureComponent<SceneBaseProps, SceneBaseState> {
198199
}
199200

200201
initEventHandlers() {
201-
let { children } = this.props;
202+
let { children, progressEvents = true } = this.props;
202203

203204
if (typeof children !== 'function' && !isGSAP(callChildFunction(children, 0, 'init'))) {
204205
return;
@@ -210,11 +211,13 @@ class SceneBase extends React.PureComponent<SceneBaseProps, SceneBaseState> {
210211
});
211212
});
212213

213-
this.scene.on('progress', (event) => {
214-
this.setState({
215-
progress: event.progress
214+
if(progressEvents){
215+
this.scene.on('progress', (event) => {
216+
this.setState({
217+
progress: event.progress
218+
});
216219
});
217-
});
220+
}
218221
}
219222

220223
render() {

src/index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ declare module 'react-scrollmagic' {
3434
loglevel?: number,
3535
indicators?: boolean,
3636
enabled?: boolean,
37+
progressEvents?: boolean,
3738

3839
/* setClassToggle */
3940
classToggle?: string | string[],

0 commit comments

Comments
 (0)