@playkit-js/hotspots 3.1.13 → 3.2.0-canary.0-dd7c4af

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@playkit-js/hotspots",
3
- "version": "3.1.13",
3
+ "version": "3.2.0-canary.0-dd7c4af",
4
4
  "private": false,
5
5
  "bugs": {
6
6
  "url": "https://github.com/kaltura/playkit-js-hotspots/issues"
@@ -2,6 +2,7 @@ import {h, Component} from 'preact';
2
2
  import {A11yWrapper} from '@playkit-js/common';
3
3
  import {LayoutHotspot} from '../utils/hotspot';
4
4
  import {AnalyticsEvents} from '../utils/analyticsEvents';
5
+ import {HotspotsEvents} from '../events/events';
5
6
 
6
7
  const defaultContainerStyles = {
7
8
  position: 'absolute',
@@ -33,6 +34,7 @@ type Props = {
33
34
  pauseVideo(): void;
34
35
  seekTo(time: number): void;
35
36
  sendAnalytics(event: AnalyticsEvents): void;
37
+ dispatcher(name: string, payload?: any): void
36
38
  };
37
39
 
38
40
  type State = {
@@ -65,7 +67,7 @@ export default class Hotspot extends Component<Props, State> {
65
67
  };
66
68
 
67
69
  componentDidMount() {
68
- const {hotspot} = this.props;
70
+ const {hotspot, dispatcher} = this.props;
69
71
 
70
72
  if (!hotspot || !hotspot.onClick) {
71
73
  this.setState({
@@ -78,6 +80,9 @@ export default class Hotspot extends Component<Props, State> {
78
80
  isReady: true,
79
81
  disableClick: !this.isClickable()
80
82
  });
83
+
84
+ const {id, label} = hotspot;
85
+ dispatcher(HotspotsEvents.HOTSPOT_DISPLAYED, {id, label});
81
86
  }
82
87
 
83
88
  isClickable = (): boolean => {
@@ -101,9 +106,12 @@ export default class Hotspot extends Component<Props, State> {
101
106
  };
102
107
 
103
108
  handleClick = () => {
104
- const {hotspot} = this.props;
109
+ const {hotspot, dispatcher} = this.props;
105
110
  const {disableClick} = this.state;
106
111
 
112
+ const {id, label} = hotspot;
113
+ dispatcher(HotspotsEvents.HOTSPOT_CLICK, {id, label});
114
+
107
115
  if (!hotspot.onClick || disableClick) {
108
116
  return;
109
117
  }
@@ -18,6 +18,7 @@ export interface Props {
18
18
  pauseVideo(): void;
19
19
  seekTo(time: number): void;
20
20
  sendAnalytics(event: AnalyticsEvents): void;
21
+ dispatcher(name: string, payload?: any): void
21
22
  }
22
23
 
23
24
  export default class HotspotWrapper extends Component<Props> {
@@ -30,9 +31,9 @@ export default class HotspotWrapper extends Component<Props> {
30
31
  return null;
31
32
  }
32
33
 
33
- const {seekTo, pauseVideo, sendAnalytics} = this.props;
34
+ const {seekTo, pauseVideo, sendAnalytics, dispatcher} = this.props;
34
35
  return visualHotspot.map(hotspotData => (
35
- <Hotspot pauseVideo={pauseVideo} seekTo={seekTo} key={hotspotData.id} visible={true} hotspot={hotspotData} sendAnalytics={sendAnalytics} />
36
+ <Hotspot dispatcher={dispatcher} pauseVideo={pauseVideo} seekTo={seekTo} key={hotspotData.id} visible={true} hotspot={hotspotData} sendAnalytics={sendAnalytics} />
36
37
  ));
37
38
  };
38
39
 
@@ -0,0 +1,4 @@
1
+ export const HotspotsEvents = {
2
+ HOTSPOT_CLICK: 'hotspot_click',
3
+ HOTSPOT_DISPLAYED: 'hotspot_displayed',
4
+ }
@@ -142,6 +142,7 @@ export class HotspotsPlugin extends KalturaPlayer.core.BasePlugin {
142
142
  };
143
143
 
144
144
  private _addHotspotsContainer(): void {
145
+ // TODO - fire on click
145
146
  this._floatingItem = this.floatingManager.add({
146
147
  label: 'Hotspots',
147
148
  mode: 'MediaLoaded',
@@ -189,8 +190,7 @@ export class HotspotsPlugin extends KalturaPlayer.core.BasePlugin {
189
190
  this._hotspots = this._recalculateCuepointLayout(this._hotspots);
190
191
  }
191
192
  return (
192
- // TODO: add 'sendAnalytics' method
193
- <HotspotWrapper key={'hotspotWrapper'} hotspots={this._hotspots} pauseVideo={this._pauseVideo} seekTo={this._seekTo} sendAnalytics={() => {}} />
193
+ <HotspotWrapper dispatcher={(eventType, payload) => this.dispatchEvent(eventType, payload)} key={'hotspotWrapper'} hotspots={this._hotspots} pauseVideo={this._pauseVideo} seekTo={this._seekTo} sendAnalytics={() => {}} />
194
194
  );
195
195
  };
196
196
 
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ const NAME = __NAME__;
8
8
 
9
9
  export {HotspotsPlugin as Plugin};
10
10
  export {VERSION, NAME};
11
+ export {HotspotsEvents} from './events/events';
11
12
 
12
13
  const pluginName: string = 'playkit-js-hotspots';
13
14
  KalturaPlayer.core.registerPlugin(pluginName, HotspotsPlugin);