Skip to content

Commit 240bfbb

Browse files
authored
fix(SUP-46685): Multiple Chapters in Quiz Break the Timeline
**Issue:** Timing issue: in some cases the delay in the setTimeOut in SeekBar.tsx file is not enough, and the bottomBarClientRect in BottomBar.tsx being updated too late, just after the set time out scope is being executed. This affects the seekBar width, which creates a problem with position the cue-points on the seekBar. **Fix:** Add an event that will update the seekBar every time the bottomBarClientRect is being updated. The seekBar.tsx will always get the most updated width. solved-[SUP-46685](https://kaltura.atlassian.net/browse/SUP-46685) [SUP-46685]: https://kaltura.atlassian.net/browse/SUP-46685?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ
1 parent 3f40e26 commit 240bfbb

File tree

4 files changed

+35
-13
lines changed

4 files changed

+35
-13
lines changed

src/components/bottom-bar/bottom-bar.tsx

+3
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {withEventManager} from '../../event';
1010
import {withPlayer} from '../player';
1111
import {filterControlsByPriority} from './bottom-bar-utils';
1212
import {BottomBarRegistryManager, bottomBarRegistryManager} from './bottom-bar-registry-manager';
13+
import {BottomBarClientRectEvent} from '../../event/events/bottom-bar-client-rect-event';
1314

1415
const LOWER_PRIORITY_CONTROLS: string[][] = [
1516
['PictureInPicture'],
@@ -99,6 +100,8 @@ class BottomBar extends Component<any, any> {
99100
const currentControlsWidth = this._getControlsWidth(resizeObserverEntry.target as HTMLElement);
100101
this._maxControlsWidth = Math.max(this._maxControlsWidth, currentControlsWidth);
101102
if (barWidth !== this.currentBarWidth) {
103+
const {player} = this.props;
104+
player.dispatchEvent(new BottomBarClientRectEvent());
102105
this.currentBarWidth = barWidth;
103106
const currCrlWidth = this.props.guiClientRect.width <= PLAYER_BREAK_POINTS.SMALL ? CRL_WIDTH + CRL_MARGIN / 2 : CRL_WIDTH + CRL_MARGIN;
104107
const lowerPriorityControls = LOWER_PRIORITY_CONTROLS.filter(c => this.state.activeControls[c[0]]);

src/components/seekbar/seekbar.tsx

+10-12
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ class SeekBar extends Component<any, any> {
9898
}
9999
];
100100

101+
handleUpdateSeekBarClientRect = () => {
102+
const clientRect = this._seekBarElement.getBoundingClientRect();
103+
this.props.updateSeekbarClientRect(clientRect);
104+
};
105+
101106
/**
102107
* on component mount, bind mouseup and mousemove events to top player element
103108
*
@@ -108,14 +113,7 @@ class SeekBar extends Component<any, any> {
108113
const {player, eventManager} = this.props;
109114
const clientRect = this._seekBarElement.getBoundingClientRect();
110115
this.props.updateSeekbarClientRect(clientRect);
111-
eventManager.listen(player, EventType.GUI_RESIZE, () => {
112-
this.setState({resizing: true});
113-
setTimeout(() => {
114-
const clientRect = this._seekBarElement.getBoundingClientRect();
115-
this.props.updateSeekbarClientRect(clientRect);
116-
this.setState({resizing: false});
117-
}, Number(style.defaultTransitionTime));
118-
});
116+
119117
const smallSizes = [PLAYER_SIZE.TINY, PLAYER_SIZE.EXTRA_SMALL, PLAYER_SIZE.SMALL];
120118
eventManager.listenOnce(player, player.Event.UI.USER_CLICKED_PLAY, () => {
121119
eventManager.listenOnce(player, player.Event.Core.FIRST_PLAY, () => {
@@ -124,6 +122,8 @@ class SeekBar extends Component<any, any> {
124122
}
125123
});
126124
});
125+
126+
eventManager.listen(player, EventType.BOTTOM_BAR_CLIENT_RECT_CHANGED, this.handleUpdateSeekBarClientRect);
127127
document.addEventListener('mouseup', this.onPlayerMouseUp);
128128
document.addEventListener('mousemove', this.onPlayerMouseMove);
129129
this.props.registerKeyboardEvents(this._keyboardEventHandlers);
@@ -519,8 +519,7 @@ class SeekBar extends Component<any, any> {
519519
<div
520520
className={this.props.hidePreview ? [style.framePreview, style.hideFramePreview].join(' ') : style.framePreview}
521521
style={this._getFramePreviewStyle()}
522-
ref={c => (c ? (this._framePreviewElement = c) : undefined)}
523-
>
522+
ref={c => (c ? (this._framePreviewElement = c) : undefined)}>
524523
<SeekBarPreview virtualTime={this.props.virtualTime} />
525524
</div>
526525
);
@@ -591,8 +590,7 @@ class SeekBar extends Component<any, any> {
591590
onTouchStart={this.onSeekbarTouchStart}
592591
onTouchMove={this.onSeekbarTouchMove}
593592
onTouchEnd={this.onSeekbarTouchEnd}
594-
onKeyDown={this.onKeyDown}
595-
>
593+
onKeyDown={this.onKeyDown}>
596594
<div className={style.progressBar}>
597595
<PlayerArea name={'SeekBar'} shouldUpdate={true}>
598596
{this.renderFramePreview()}

src/event/event-type.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ const EventType = {
3737
USER_SELECTED_CAPTIONS_FONT_STYLE: `${namespace}-userselectedcaptionsfontstyle`,
3838
USER_SELECTED_CAPTIONS_FONT_OPACITY: `${namespace}-userselectedcaptionsfontopacity`,
3939
USER_SELECTED_CAPTIONS_BACKGROUND_COLOR: `${namespace}-userselectedcaptionsbackgroundcolor`,
40-
USER_SELECTED_CAPTIONS_BACKGROUND_OPACITY: `${namespace}-userselectedcaptionsbackgroundopacity`
40+
USER_SELECTED_CAPTIONS_BACKGROUND_OPACITY: `${namespace}-userselectedcaptionsbackgroundopacity`,
41+
BOTTOM_BAR_CLIENT_RECT_CHANGED: `${namespace}-bottombarclientrectchanged`
4142
} as const;
4243

4344
export {EventType};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import {FakeEvent} from '@playkit-js/playkit-js';
2+
import {EventType} from '../event-type';
3+
4+
/**
5+
* BottomBarClientRectEvent event
6+
*
7+
* @class BottomBarClientRectEvent
8+
* @extends {FakeEvent}
9+
*/
10+
class BottomBarClientRectEvent extends FakeEvent {
11+
/**
12+
* @constructor
13+
*
14+
*/
15+
constructor() {
16+
super(EventType.BOTTOM_BAR_CLIENT_RECT_CHANGED);
17+
}
18+
}
19+
20+
export {BottomBarClientRectEvent};

0 commit comments

Comments
 (0)