Skip to content

Commit 0835d4b

Browse files
committed
fix: minor changes
1 parent 7d124c1 commit 0835d4b

File tree

2 files changed

+61
-50
lines changed

2 files changed

+61
-50
lines changed

src/assets/styles/main.scss

Lines changed: 21 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -226,48 +226,39 @@ $icon-font-path: '../icon-font' !default;
226226
&.vjs-using-native-controls .vjs-big-play-button,
227227
&.vjs-error .vjs-big-play-button {
228228
transition:
229-
visibility 0.2s,
230-
opacity 0.2s;
229+
visibility 0.25s,
230+
opacity 0.25s;
231231
display: block;
232232
visibility: hidden;
233233
opacity: 0;
234234
}
235235

236236
// Mobile touch interaction - show big play button when tapped (must come after hiding rules above)
237237
&.cld-mobile-touch-active .vjs-big-play-button {
238-
display: block !important;
239-
opacity: 1 !important;
240-
visibility: visible !important;
238+
display: block;
239+
opacity: 1;
240+
visibility: visible;
241241
}
242242

243-
// Mobile touch - ONLY style the pause icon during mobile touch interactions
243+
// Mobile touch pause icon - only shown during mobile interactions
244244
&.cld-mobile-touch-playing .vjs-big-play-button .vjs-icon-placeholder:before {
245-
// Reset the CSS triangle properties completely
246-
border: none !important;
247-
border-left: none !important;
248-
border-top: none !important;
249-
border-bottom: none !important;
250-
margin: 0 !important;
251-
252-
// Create perfectly centered pause icon with CSS
253-
content: '' !important;
254-
position: absolute !important;
255-
256-
// Perfect mathematical centering for both lines
257-
top: 50% !important;
258-
left: 50% !important;
259-
transform: translate(-50%, -50%) translate(-5.5px, 0) !important; // Center the 11px total width (4px + 3px + 4px)
260-
261-
// Identical pause lines - clean and proportioned
262-
width: 4px !important;
263-
height: 22px !important;
264-
background: currentColor !important;
265-
border-radius: 2px !important;
245+
// Reset default triangle and create pause icon
246+
content: '';
247+
position: absolute;
248+
border: none;
249+
margin: 0;
266250

267-
// Create identical second line with perfect 3px spacing
268-
box-shadow: 7px 0 0 0 currentColor !important; // 4px line + 3px gap = 7px offset
251+
// Center the pause icon (11px total width: 4px + 3px + 4px)
252+
top: 50%;
253+
left: 50%;
254+
transform: translate(-50%, -50%) translate(-5.5px, 0);
269255

270-
display: block !important;
256+
// Two vertical lines for pause icon
257+
width: 4px;
258+
height: 22px;
259+
background: currentColor;
260+
border-radius: 2px;
261+
box-shadow: 7px 0 0 0 currentColor; // Second line with 3px gap
271262
}
272263

273264
&.vjs-controls-enabled::before {

src/video-player.js

Lines changed: 40 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -455,19 +455,8 @@ class VideoPlayer extends Utils.mixin(Eventable) {
455455
// Update mobile touch state based on current playback
456456
this._updateMobileTouchState();
457457

458-
// Remove the overlay after timeout
459-
this.videojs.clearTimeout(this._mobileTouchTimeout);
460-
this._mobileTouchTimeout = this.videojs.setTimeout(() => {
461-
// First remove the visibility class to start fade-out
462-
this.videojs.removeClass('cld-mobile-touch-active');
463-
464-
// Wait for CSS transition to complete before removing pause icon class
465-
setTimeout(() => {
466-
this.videojs.removeClass('cld-mobile-touch-playing');
467-
this._removeMobileBigPlayButtonHandler();
468-
this._mobileInteractionActive = false; // End mobile interaction session
469-
}, 250); // Wait slightly longer than the 0.2s CSS transition
470-
}, 3000);
458+
// Set up listener for VideoJS user activity events to sync with controls
459+
this._setupMobileInactivityHandler();
471460
}
472461
};
473462

@@ -492,8 +481,14 @@ class VideoPlayer extends Utils.mixin(Eventable) {
492481
// Clean up on dispose
493482
this.videojs.on('dispose', () => {
494483
playerElement.removeEventListener('touchend', handleMobileTouch);
495-
this.videojs.clearTimeout(this._mobileTouchTimeout);
496484
this._removeMobileBigPlayButtonHandler();
485+
486+
// Clean up inactivity handler
487+
if (this._mobileInactivityHandler) {
488+
this.videojs.off('userinactive', this._mobileInactivityHandler);
489+
this._mobileInactivityHandler = null;
490+
}
491+
497492
this._mobileTouchHandlerSetup = false;
498493
this._mobileInteractionActive = false;
499494
});
@@ -509,23 +504,48 @@ class VideoPlayer extends Utils.mixin(Eventable) {
509504
}
510505
}
511506

507+
_setupMobileInactivityHandler() {
508+
// Remove any existing inactivity handler
509+
if (this._mobileInactivityHandler) {
510+
this.videojs.off('userinactive', this._mobileInactivityHandler);
511+
}
512+
513+
// Create handler that syncs with VideoJS control bar timing
514+
this._mobileInactivityHandler = () => {
515+
// Start fade-out when VideoJS controls fade out
516+
this.videojs.removeClass('cld-mobile-touch-active');
517+
518+
// Wait for CSS transition to complete before cleanup
519+
setTimeout(() => {
520+
this.videojs.removeClass('cld-mobile-touch-playing');
521+
this._removeMobileBigPlayButtonHandler();
522+
this._mobileInteractionActive = false; // End mobile interaction session
523+
524+
// Remove the inactivity handler since this touch session is done
525+
if (this._mobileInactivityHandler) {
526+
this.videojs.off('userinactive', this._mobileInactivityHandler);
527+
this._mobileInactivityHandler = null;
528+
}
529+
}, 250); // Wait slightly longer than the 0.2s CSS transition
530+
};
531+
532+
// Listen for VideoJS user inactivity (when controls fade out)
533+
this.videojs.one('userinactive', this._mobileInactivityHandler);
534+
}
535+
512536
_updateMobileTouchState() {
513537
const isPlaying = !this.videojs.paused();
514538

515539
if (isPlaying) {
516540
this.videojs.addClass('cld-mobile-touch-playing');
517-
this._setupMobileBigPlayButtonHandler(true);
541+
this._setupMobileBigPlayButtonHandler();
518542
} else {
519543
this.videojs.removeClass('cld-mobile-touch-playing');
520544
this._removeMobileBigPlayButtonHandler();
521545
}
522546
}
523547

524-
_setupMobileBigPlayButtonHandler(isPlaying) {
525-
if (!isPlaying) {
526-
return; // Use default play behavior when paused
527-
}
528-
548+
_setupMobileBigPlayButtonHandler() {
529549
// Remove any existing handler first
530550
this._removeMobileBigPlayButtonHandler();
531551

0 commit comments

Comments
 (0)