mirror of
https://github.com/mediacms-io/mediacms.git
synced 2025-11-06 15:38:53 -05:00
Improve icon size calculation for AutoplayToggleButton
Icon size is now calculated in pixels based on em units from PlayerConfig, with scaling and sensible defaults. Added defensive checks to ensure iconSize is always a valid number, improving reliability across device types.
This commit is contained in:
parent
06baf6b1e6
commit
48e632c17f
@ -23,7 +23,9 @@ class AutoplayToggleButton extends Button {
|
|||||||
} */
|
} */
|
||||||
|
|
||||||
// Store the appropriate font size based on device type
|
// Store the appropriate font size based on device type
|
||||||
this.iconSize = isTouchDevice ? PlayerConfig.controlBar.mobileFontSize : PlayerConfig.controlBar.fontSize;
|
// PlayerConfig values are in em units, convert to pixels for SVG dimensions
|
||||||
|
const baseFontSize = isTouchDevice ? PlayerConfig.controlBar.mobileFontSize : PlayerConfig.controlBar.fontSize;
|
||||||
|
this.iconSize = Math.round((baseFontSize || 14) * 1.2); // Scale and default to 14em if undefined
|
||||||
|
|
||||||
this.userPreferences = options.userPreferences;
|
this.userPreferences = options.userPreferences;
|
||||||
// Get autoplay preference from localStorage, default to false if not set
|
// Get autoplay preference from localStorage, default to false if not set
|
||||||
@ -72,6 +74,11 @@ class AutoplayToggleButton extends Button {
|
|||||||
}
|
}
|
||||||
|
|
||||||
updateIconClass() {
|
updateIconClass() {
|
||||||
|
// Ensure iconSize is a valid number (defensive check)
|
||||||
|
if (!this.iconSize || isNaN(this.iconSize)) {
|
||||||
|
this.iconSize = 16; // Default to 16px if undefined or NaN
|
||||||
|
}
|
||||||
|
|
||||||
// Remove existing icon classes
|
// Remove existing icon classes
|
||||||
this.iconSpan.className = 'vjs-icon-placeholder vjs-svg-icon vjs-autoplay-icon__OFFF';
|
this.iconSpan.className = 'vjs-icon-placeholder vjs-svg-icon vjs-autoplay-icon__OFFF';
|
||||||
this.iconSpan.style.position = 'relative';
|
this.iconSpan.style.position = 'relative';
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user