Skip to content

Commit 3ddcf5d

Browse files
committed
BL-15721 show bubbles on top of videos
1 parent 78d01c6 commit 3ddcf5d

4 files changed

Lines changed: 43 additions & 19 deletions

File tree

src/BloomBrowserUI/bookEdit/css/editMode.less

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1640,21 +1640,34 @@ svg.bloom-videoControl {
16401640
}
16411641
}
16421642

1643+
// Detector above the canvas so we can detect hover and clicks of playback controls
1644+
.bloom-videoMouseDetector {
1645+
height: 100%;
1646+
width: 100%;
1647+
position: absolute;
1648+
top: 0;
1649+
z-index: @canvasElementCanvasZIndex + 1;
1650+
}
1651+
16431652
// Show pause and replay when playing and hovered.
1644-
.bloom-videoContainer.playing:hover {
1645-
.bloom-videoControlContainer {
1646-
&.bloom-videoPauseIcon,
1647-
&.bloom-videoReplayIcon {
1648-
display: flex;
1653+
.bloom-videoContainer.playing {
1654+
.bloom-videoMouseDetector:hover {
1655+
.bloom-videoControlContainer {
1656+
&.bloom-videoPauseIcon,
1657+
&.bloom-videoReplayIcon {
1658+
display: flex;
1659+
}
16491660
}
16501661
}
16511662
}
16521663

16531664
// Show play, centered, when hovering a video that is not paused or playing
1654-
.bloom-videoContainer:not(.paused):not(.playing):hover {
1655-
.bloom-videoPlayIcon {
1656-
display: flex;
1657-
left: calc(50% - @videoIconSize / 2);
1665+
.bloom-videoContainer:not(.paused):not(.playing) {
1666+
.bloom-videoMouseDetector:hover {
1667+
.bloom-videoPlayIcon {
1668+
display: flex;
1669+
left: calc(50% - @videoIconSize / 2);
1670+
}
16581671
}
16591672
}
16601673

src/BloomBrowserUI/bookEdit/js/CanvasElementManager.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6426,7 +6426,8 @@ export class CanvasElementManager {
64266426
.find(".bloom-ui")
64276427
.filter(
64286428
(_, x) =>
6429-
!x.classList.contains("bloom-videoControlContainer"),
6429+
!x.classList.contains("bloom-videoControlContainer") &&
6430+
!x.classList.contains("bloom-videoMouseDetector"),
64306431
)
64316432
.remove();
64326433
thisCanvasElement.find(".bloom-dragHandleTOP").remove(); // BL-7903 remove any left over drag handles (this was the class used in 4.7 alpha)

src/BloomBrowserUI/bookEdit/js/bloomVideo.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,14 @@ export function SetupVideoEditing(container) {
3030
// debugging, and just might prevent a problem in normal operation.
3131
videoElement.parentElement?.classList.remove("playing");
3232
videoElement.parentElement?.classList.remove("paused");
33-
videoElement.addEventListener("click", handleVideoClick);
33+
const mouseDetector =
34+
videoElement.ownerDocument.createElement("div");
35+
mouseDetector.classList.add("bloom-videoMouseDetector");
36+
mouseDetector.classList.add("bloom-ui"); // don't save as part of document
37+
mouseDetector.addEventListener("click", handleVideoClick);
38+
videoElement.parentElement?.appendChild(mouseDetector);
3439
const playButton = wrapVideoIcon(
35-
videoElement,
40+
mouseDetector,
3641
// Alternatively, we could import the Material UI icon, make this file a TSX, and use
3742
// ReactDom.render to render the icon into the div. But just creating the SVG
3843
// ourselves (as these methods do) seems more natural to me. We would not be using
@@ -43,13 +48,13 @@ export function SetupVideoEditing(container) {
4348
);
4449
playButton.addEventListener("click", handlePlayClick);
4550
const pauseButton = wrapVideoIcon(
46-
videoElement,
51+
mouseDetector,
4752
getPauseIcon("#ffffff", videoElement),
4853
"bloom-videoPauseIcon",
4954
);
5055
pauseButton.addEventListener("click", handlePauseClick);
5156
const replayButton = wrapVideoIcon(
52-
videoElement,
57+
mouseDetector,
5358
getReplayIcon("#ffffff", videoElement),
5459
"bloom-videoReplayIcon",
5560
);
@@ -296,17 +301,17 @@ export function updateVideoInContainer(container: Element, url: string): void {
296301
// configure one of the icons we display over videos. We put a div around it and apply
297302
// various classes and append it to the parent of the video.
298303
function wrapVideoIcon(
299-
videoElement: HTMLVideoElement,
304+
parent: HTMLElement,
300305
icon: HTMLElement,
301306
iconClass: string,
302307
): HTMLElement {
303-
const wrapper = videoElement.ownerDocument.createElement("div");
308+
const wrapper = parent.ownerDocument.createElement("div");
304309
wrapper.classList.add("bloom-videoControlContainer");
305310
wrapper.classList.add("bloom-ui"); // don't save as part of document
306311
wrapper.appendChild(icon);
307312
wrapper.classList.add(iconClass);
308313
icon.classList.add("bloom-videoControl");
309-
videoElement.parentElement?.appendChild(wrapper);
314+
parent.appendChild(wrapper);
310315
return icon;
311316
}
312317

src/content/bookLayout/basePage.less

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,8 +323,13 @@ books may contain divs with box-header-off, so we need a rule to hide them.*/
323323
background-size: contain;
324324
}
325325

326-
// above canvas so we can click playback controls
327-
z-index: @canvasElementCanvasZIndex + 1;
326+
// When the book is viewed in an older version of BloomPlayer, we want to set z-index to make the video controls
327+
// clickable like we used to do before BL-15721, even that means any speech bubbles will be behind the video.
328+
// Newer versions of BloomPlayer will add a .videoMouseDetector element to detect clicks so that in that case
329+
// we can avoid setting z-index here and so allow speech bubbles to be in front of the video.
330+
&:not(:has(.bloom-videoMouseDetector)):not(:has(.videoMouseDetector)) {
331+
z-index: @canvasElementCanvasZIndex + 1;
332+
}
328333

329334
video {
330335
// I don't know exactly why this works, but it makes the video shrink to fit,

0 commit comments

Comments
 (0)