@24i/bigscreen-sdk 1.0.8-alpha.2171 → 1.0.8-alpha.2177

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": "@24i/bigscreen-sdk",
3
- "version": "1.0.8-alpha.2171",
3
+ "version": "1.0.8-alpha.2177",
4
4
  "description": "SmartApps BIGscreen SDK monorepo",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -61,6 +61,8 @@ export class FirstOnlyGrid<T extends Item<U>, U>
61
61
  const linesDiff = Math.floor(grid.index / itemsInGroup) - oldLine;
62
62
  if (linesDiff > 0) {
63
63
  this.scrollForward(linesDiff);
64
+ } else if (linesDiff < 0) {
65
+ this.scrollBackward(Math.abs(linesDiff));
64
66
  }
65
67
  };
66
68
 
@@ -77,8 +79,8 @@ export class FirstOnlyGrid<T extends Item<U>, U>
77
79
  this.controller.scroll(targetScrollIndex);
78
80
  }
79
81
 
80
- scrollBackward() {
81
- const targetScrollIndex = this.controller.scrollIndex - 1;
82
+ scrollBackward(diff = 1) {
83
+ const targetScrollIndex = this.controller.scrollIndex - diff;
82
84
  this.controller.scroll(targetScrollIndex);
83
85
  }
84
86
 
@@ -1,6 +1,6 @@
1
1
  import { Component, createRef, DeclareProps } from '@24i/bigscreen-sdk/jsx';
2
2
  import { PlayerBase } from '@24i/player-base';
3
- import { switchByKey } from '@24i/bigscreen-sdk/device/keymap';
3
+ import { FF, REW, switchByKey } from '@24i/bigscreen-sdk/device/keymap';
4
4
  import { stopEvent } from '@24i/bigscreen-sdk/utils/stopEvent';
5
5
  import {
6
6
  IDisplayToggler, getDisplayToggler, DISPLAY_NONE,
@@ -22,6 +22,7 @@ type Props = {
22
22
  hidden?: boolean,
23
23
  onClose?: () => void,
24
24
  onHide?: () => void,
25
+ isPauseAllowed?: () => boolean,
25
26
  };
26
27
 
27
28
  export class PlayerUI extends Component<Props>
@@ -47,6 +48,7 @@ export class PlayerUI extends Component<Props>
47
48
  hidden: false,
48
49
  onClose: noop,
49
50
  onHide: noop,
51
+ isPauseAllowed: () => true,
50
52
  };
51
53
 
52
54
  declare props: DeclareProps<Props, typeof PlayerUI.defaultProps>;
@@ -83,7 +85,7 @@ export class PlayerUI extends Component<Props>
83
85
  FF: this.onKeyForward,
84
86
  REW: this.onKeyRewind,
85
87
  });
86
- if (processed) stopEvent(event);
88
+ if (processed && !FF.is(event) && !REW.is(event)) stopEvent(event);
87
89
  };
88
90
 
89
91
  onKeyPlay = () => {
@@ -101,6 +103,7 @@ export class PlayerUI extends Component<Props>
101
103
  };
102
104
 
103
105
  onKeyPause = () => {
106
+ if (!this.props.isPauseAllowed()) return false;
104
107
  if (this.seeking.isAutomaticallySeeking()) {
105
108
  this.seeking.stopAutomaticSeek();
106
109
  if (this.isPlaying()) this.trigger(PlayerAction.PAUSE);
@@ -115,6 +118,7 @@ export class PlayerUI extends Component<Props>
115
118
  };
116
119
 
117
120
  onKeyPlayPause = () => {
121
+ if (!this.props.isPauseAllowed()) return false;
118
122
  if (this.seeking.isSeeking()) {
119
123
  this.seeking.confirmSeek();
120
124
  if (!this.isPlaying()) this.trigger(PlayerAction.PLAY);
@@ -51,6 +51,7 @@ export class Seekbar extends Component<Props> implements IFocusable {
51
51
  document.addEventListener('mouseup', this.onMouseUp);
52
52
  document.addEventListener('mousemove', this.onMouseMove);
53
53
  ui.seeking.addEventListener('seektimeupdate', this.onSeekTimeUpdate);
54
+ ui.seeking.addEventListener('stopautomaticseek', this.onStopAutomaticSeek);
54
55
  ui.getPlayer().addEventListener('timeupdate', this.onTimeUpdate);
55
56
  ui.getPlayer().addEventListener('durationchange', this.onDurationUpdate);
56
57
  }
@@ -60,6 +61,7 @@ export class Seekbar extends Component<Props> implements IFocusable {
60
61
  document.removeEventListener('mouseup', this.onMouseUp);
61
62
  document.removeEventListener('mousemove', this.onMouseMove);
62
63
  ui.seeking.removeEventListener('seektimeupdate', this.onSeekTimeUpdate);
64
+ ui.seeking.removeEventListener('stopautomaticseek', this.onStopAutomaticSeek);
63
65
  ui.getPlayer().removeEventListener('timeupdate', this.onTimeUpdate);
64
66
  ui.getPlayer().removeEventListener('durationchange', this.onDurationUpdate);
65
67
  }
@@ -163,6 +165,8 @@ export class Seekbar extends Component<Props> implements IFocusable {
163
165
  this.updateSeekBar();
164
166
  };
165
167
 
168
+ onStopAutomaticSeek = () => this.props.ui.enableHiding();
169
+
166
170
  onTimeUpdate = ({ currentTime }: ITimeUpdateEvent) => {
167
171
  const { ui } = this.props;
168
172
  this.currentTime = currentTime;
@@ -95,6 +95,7 @@ export class Seeking implements IEvents<SeekingEventsMap> {
95
95
  }
96
96
 
97
97
  stopAutomaticSeek() {
98
+ if (this.isAutomaticallySeeking()) this.triggerEvent('stopautomaticseek');
98
99
  this.automaticSeekInterval.clear();
99
100
  this.isAutomaticallySeekingForward = false;
100
101
  this.isAutomaticallySeekingBackward = false;
@@ -1,25 +1,59 @@
1
1
  const ELLIPSIS = '...';
2
2
 
3
- export const trimWithLeadingEllipsis = (row: HTMLSpanElement, requestedNumberOfLines: number) => {
4
- if (row && row.textContent != null) {
5
- row.style.visibility = 'hidden';
6
- const lineHeightString = window.getComputedStyle(row, null).getPropertyValue('line-height');
7
- const lineHeight = parseInt(lineHeightString, 10);
8
- let numberOfLines = row.offsetHeight / lineHeight;
9
- if (numberOfLines > requestedNumberOfLines) {
10
- const originalTextContent = row.textContent;
11
- row.textContent = ELLIPSIS;
12
- let stringBuffer = '';
3
+ const trimWithEllipsis = (
4
+ row: HTMLSpanElement | HTMLDivElement,
5
+ requestedNumberOfLines: number,
6
+ ellipsis = ELLIPSIS,
7
+ ending = false
8
+ ) : void => {
9
+ if (!row.textContent) {
10
+ return;
11
+ }
12
+ row.style.visibility = 'hidden';
13
+ const lineHeightString = window.getComputedStyle(row, null).getPropertyValue('line-height');
14
+ const lineHeight = parseInt(lineHeightString, 10);
15
+ let numberOfLines = row.offsetHeight / lineHeight;
16
+ if (numberOfLines > requestedNumberOfLines) {
17
+ const originalTextContent = row.textContent!;
18
+ row.textContent = ellipsis;
19
+ let stringBuffer = '';
20
+ if (ending) {
21
+ let currentPosition = 0;
22
+ do {
23
+ stringBuffer += originalTextContent.charAt(currentPosition);
24
+ row.textContent = stringBuffer + ellipsis;
25
+ currentPosition += 1;
26
+ numberOfLines = row.offsetHeight / lineHeight;
27
+ } while (numberOfLines <= requestedNumberOfLines
28
+ && currentPosition < originalTextContent.length);
29
+ row.textContent = stringBuffer.substring(0, stringBuffer.length - 1) + ellipsis;
30
+ } else {
13
31
  let currentPosition = originalTextContent.length - 1;
14
32
  do {
15
33
  const charToAdd = originalTextContent.at(currentPosition);
16
34
  stringBuffer = `${charToAdd}${stringBuffer}`;
17
- row.textContent = `${ELLIPSIS}${stringBuffer}`;
35
+ row.textContent = `${ellipsis}${stringBuffer}`;
18
36
  currentPosition -= 1;
19
37
  numberOfLines = Math.floor(row.offsetHeight / lineHeight);
20
38
  } while (numberOfLines <= requestedNumberOfLines && currentPosition >= 0);
21
- row.textContent = `${ELLIPSIS}${stringBuffer.substring(1)}`;
39
+ row.textContent = `${ellipsis}${stringBuffer.substring(1)}`;
22
40
  }
23
- row.style.visibility = '';
24
41
  }
42
+ row.style.visibility = '';
43
+ };
44
+
45
+ export const trimWithLeadingEllipsis = (
46
+ row: HTMLSpanElement | HTMLDivElement,
47
+ requestedNumberOfLines: number,
48
+ ellipsis = ELLIPSIS,
49
+ ) => {
50
+ return trimWithEllipsis(row, requestedNumberOfLines, ellipsis, false);
51
+ };
52
+
53
+ export const trimWithEndingEllipsis = (
54
+ row: HTMLSpanElement | HTMLDivElement,
55
+ requestedNumberOfLines: number,
56
+ ellipsis = ELLIPSIS,
57
+ ) => {
58
+ return trimWithEllipsis(row, requestedNumberOfLines, ellipsis, true);
25
59
  };