Skip to content

Commit 66b3ec2

Browse files
authored
Merge pull request #112 from back4app/add_database_browser_video_events
feat: Dispatch database browser video events
2 parents 40339d2 + 4186040 commit 66b3ec2

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/components/VideoTutorialButton/VideoTutorialButton.react.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,32 @@ export default class VideoTutorialButton extends Component {
1313
this.state = {
1414
videoTutorialModal: null
1515
};
16+
this.dispatchOnStartEvent = this.dispatchOnStartEvent.bind(this);
17+
this.dispatchOnProgressEvent = this.dispatchOnProgressEvent.bind(this);
18+
}
19+
20+
dispatchOnStartEvent() {
21+
back4AppNavigation && back4AppNavigation.onStartDatabaseBrowserVideoEvent();
22+
this.dispatched = {};
23+
}
24+
25+
dispatchOnFinishEvent() {
26+
back4AppNavigation && back4AppNavigation.onFinishDatabaseBrowserVideoEvent();
27+
}
28+
29+
dispatchOnProgressEvent({ played }) {
30+
if (this.dispatched) {
31+
if (!this.dispatched[75] && played >= 0.75) {
32+
back4AppNavigation && back4AppNavigation.onThreeQuartersDatabaseBrowserVideoEvent();
33+
this.dispatched[75] = true;
34+
} else if (!this.dispatched[50] && played >= 0.5) {
35+
back4AppNavigation && back4AppNavigation.onHalfDatabaseBrowserVideoEvent();
36+
this.dispatched[50] = true;
37+
} else if (!this.dispatched[25] && played >= 0.25) {
38+
back4AppNavigation && back4AppNavigation.onQuarterDatabaseBrowserVideoEvent();
39+
this.dispatched[25] = true;
40+
}
41+
}
1642
}
1743

1844
componentWillMount() {
@@ -38,6 +64,9 @@ export default class VideoTutorialButton extends Component {
3864
controls
3965
width="100%"
4066
height="100%"
67+
onStart={this.dispatchOnStartEvent}
68+
onEnded={this.dispatchOnFinishEvent}
69+
onProgress={this.dispatchOnProgressEvent}
4170
/>
4271
</div>
4372
</Popover>

0 commit comments

Comments
 (0)