@playkit-js/hotspots 3.2.8 → 3.2.9-canary.0-2522f13
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.2.
|
|
3
|
+
"version": "3.2.9-canary.0-2522f13",
|
|
4
4
|
"private": false,
|
|
5
5
|
"bugs": {
|
|
6
6
|
"url": "https://github.com/kaltura/playkit-js-hotspots/issues"
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"conventional-github-releaser": "3.1.3",
|
|
20
20
|
"cross-env": "^7.0.3",
|
|
21
21
|
"css-loader": "^6.7.1",
|
|
22
|
-
"cypress": "
|
|
22
|
+
"cypress": "13.13.1",
|
|
23
23
|
"playwright-webkit": "^1.33.0",
|
|
24
24
|
"prettier": "^2.6.2",
|
|
25
25
|
"sass": "^1.52.3",
|
|
@@ -13,18 +13,20 @@ const defaultContainerStyles = {
|
|
|
13
13
|
const defaultButtonsStyles = {
|
|
14
14
|
position: 'relative',
|
|
15
15
|
width: '100%',
|
|
16
|
-
height: '
|
|
16
|
+
height: 'inherit',
|
|
17
17
|
appearance: 'none',
|
|
18
18
|
border: 'none',
|
|
19
|
-
display: '
|
|
20
|
-
verticalAlign: 'middle',
|
|
21
|
-
textAlign: 'center',
|
|
19
|
+
display: 'flex',
|
|
22
20
|
cursor: 'pointer',
|
|
23
21
|
wordBreak: 'break-all',
|
|
24
22
|
textRendering: 'geometricPrecision',
|
|
25
23
|
overflow: 'hidden',
|
|
26
24
|
textOverflow: 'ellipsis',
|
|
27
|
-
|
|
25
|
+
padding: '3px',
|
|
26
|
+
alignItems: 'center',
|
|
27
|
+
justifyContent: 'center',
|
|
28
|
+
outline: 0,
|
|
29
|
+
lineHeight: 'normal'
|
|
28
30
|
};
|
|
29
31
|
|
|
30
32
|
type Props = {
|
|
@@ -164,42 +166,6 @@ export default class Hotspot extends Component<Props, State> {
|
|
|
164
166
|
}
|
|
165
167
|
};
|
|
166
168
|
|
|
167
|
-
getFontSize = (layout: any, hotspot: any, label: string): number => {
|
|
168
|
-
let textEl = this.createDivElement();
|
|
169
|
-
textEl.style.top = `${layout.y}px`;
|
|
170
|
-
textEl.style.fontSize = `${hotspot.styles['font-size']}px`;
|
|
171
|
-
textEl.style.fontFamily = `${hotspot.styles['font-family']}`;
|
|
172
|
-
textEl.textContent = label || '';
|
|
173
|
-
document.body.appendChild(textEl);
|
|
174
|
-
|
|
175
|
-
const textWidth = textEl.clientWidth;
|
|
176
|
-
let initialFontSize = parseInt(hotspot.styles['font-size']);
|
|
177
|
-
let fontSizeToUse = initialFontSize;
|
|
178
|
-
if (textWidth > layout.width) {
|
|
179
|
-
for (fontSizeToUse = initialFontSize - 1; fontSizeToUse >= MINIMAL_FONT_SIZE; fontSizeToUse--) {
|
|
180
|
-
textEl.style.fontSize = `${fontSizeToUse}px`;
|
|
181
|
-
const newTextWidth = textEl.clientWidth;
|
|
182
|
-
if (newTextWidth <= layout.width) {
|
|
183
|
-
break;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
document.body.removeChild(textEl);
|
|
189
|
-
return fontSizeToUse;
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
createDivElement = (): HTMLDivElement => {
|
|
193
|
-
let divEl = document.createElement('div');
|
|
194
|
-
divEl.id = 'textDivTest';
|
|
195
|
-
divEl.style.position = 'absolute';
|
|
196
|
-
divEl.style.display = 'table-cell';
|
|
197
|
-
divEl.style.textAlign = 'center';
|
|
198
|
-
divEl.style.wordBreak = 'break-all';
|
|
199
|
-
divEl.style.textRendering = 'geometricPrecision';
|
|
200
|
-
return divEl;
|
|
201
|
-
};
|
|
202
|
-
|
|
203
169
|
render() {
|
|
204
170
|
const {hotspot} = this.props;
|
|
205
171
|
const {layout, label} = hotspot;
|
|
@@ -217,14 +183,13 @@ export default class Hotspot extends Component<Props, State> {
|
|
|
217
183
|
width: layout.width
|
|
218
184
|
};
|
|
219
185
|
|
|
220
|
-
const fontSizeToUse = `${this.getFontSize(layout, hotspot, label || '')}px`;
|
|
221
|
-
|
|
222
186
|
const buttonStyles = {
|
|
223
187
|
...defaultButtonsStyles,
|
|
224
188
|
...hotspot.styles,
|
|
225
189
|
cursor: disableClick ? 'default' : 'pointer',
|
|
226
190
|
maxWidth: `${layout.width}px`,
|
|
227
|
-
fontSize:
|
|
191
|
+
fontSize: `${hotspot.relativeStyle.fontSize}px`,
|
|
192
|
+
borderRadius: `${hotspot.relativeStyle.radiusBorder}px`,
|
|
228
193
|
};
|
|
229
194
|
|
|
230
195
|
return (
|
package/src/hotspots-plugin.tsx
CHANGED
|
@@ -2,7 +2,14 @@ import {h, ComponentChildren} from 'preact';
|
|
|
2
2
|
import {FloatingItem, FloatingManager, FloatingItemProps} from '@playkit-js/ui-managers';
|
|
3
3
|
|
|
4
4
|
import {ContribServices, CuePoint, TimedMetadataEvent} from '@playkit-js/common';
|
|
5
|
-
import {
|
|
5
|
+
import {
|
|
6
|
+
RawLayoutHotspot,
|
|
7
|
+
LayoutHotspot,
|
|
8
|
+
Canvas,
|
|
9
|
+
RawFloatingCuepoint,
|
|
10
|
+
Layout,
|
|
11
|
+
Style
|
|
12
|
+
} from './utils/hotspot';
|
|
6
13
|
import HotspotWrapper from './components/HotspotWrapper';
|
|
7
14
|
import {ScaleCalculation, scaleVideo} from './utils/scale-video';
|
|
8
15
|
|
|
@@ -105,6 +112,14 @@ export class HotspotsPlugin extends KalturaPlayer.core.BasePlugin {
|
|
|
105
112
|
};
|
|
106
113
|
}
|
|
107
114
|
|
|
115
|
+
private _calculateStyle(cuepoint: LayoutHotspot, scaleCalculation: ScaleCalculation): Style {
|
|
116
|
+
const {rawLayout, styles} = cuepoint;
|
|
117
|
+
return {
|
|
118
|
+
fontSize: parseInt(styles['font-size'])/ rawLayout.stageWidth * scaleCalculation.width,
|
|
119
|
+
radiusBorder: parseInt(styles['border-radius'])/ rawLayout.stageWidth * scaleCalculation.width,
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
108
123
|
private _recalculateCuepointLayout = (hotspots: RawLayoutHotspot[] | LayoutHotspot[]): LayoutHotspot[] => {
|
|
109
124
|
this.logger.debug('calculating cuepoint layout based on video/player sizes');
|
|
110
125
|
|
|
@@ -127,7 +142,8 @@ export class HotspotsPlugin extends KalturaPlayer.core.BasePlugin {
|
|
|
127
142
|
this.logger.debug('recalculate cuepoint layout based on new sizes');
|
|
128
143
|
return hotspots.map(cuepoint => ({
|
|
129
144
|
...cuepoint,
|
|
130
|
-
layout: this._calculateLayout(cuepoint as any, scaleCalculation)
|
|
145
|
+
layout: this._calculateLayout(cuepoint as any, scaleCalculation),
|
|
146
|
+
relativeStyle: this._calculateStyle(cuepoint as any, scaleCalculation)
|
|
131
147
|
}));
|
|
132
148
|
};
|
|
133
149
|
|
package/src/utils/hotspot.ts
CHANGED
|
@@ -5,6 +5,11 @@ export interface Layout {
|
|
|
5
5
|
height: number;
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
+
export interface Style {
|
|
9
|
+
radiusBorder: number;
|
|
10
|
+
fontSize: number;
|
|
11
|
+
}
|
|
12
|
+
|
|
8
13
|
export interface RawFloatingCuepoint {
|
|
9
14
|
id: string;
|
|
10
15
|
startTime: number;
|
|
@@ -21,6 +26,7 @@ export interface RawFloatingCuepoint {
|
|
|
21
26
|
|
|
22
27
|
export interface FloatingCuepoint extends RawFloatingCuepoint {
|
|
23
28
|
layout: Layout;
|
|
29
|
+
relativeStyle : Style;
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
export interface OpenUrl {
|