Skip to content

Commit da5de05

Browse files
committed
fix(player): avoid double controls on iphone
closes #964
1 parent b1c26c5 commit da5de05

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

packages/vidstack/src/components/ui/controls.ts

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Component, effect } from 'maverick.js';
2-
import { DOMEvent, setStyle } from 'maverick.js/std';
2+
import { DOMEvent, setAttribute, setStyle } from 'maverick.js/std';
33

44
import { useMediaContext, type MediaContext } from '../../core/api/media-context';
55
import { setAttributeIfEmpty } from '../../utils/dom';
@@ -40,6 +40,8 @@ export class Controls extends Component<ControlsProps, {}, ControlsEvents> {
4040
this.dispatch('change', { detail: this._isShowing() });
4141
});
4242

43+
effect(this._hideControls.bind(this));
44+
4345
effect(() => {
4446
const isFullscreen = fullscreen();
4547
for (const side of ['top', 'right', 'bottom', 'left']) {
@@ -48,6 +50,16 @@ export class Controls extends Component<ControlsProps, {}, ControlsEvents> {
4850
});
4951
}
5052

53+
private _hideControls() {
54+
if (!this.el) return;
55+
56+
const { controls } = this._media.$state,
57+
isHidden = controls() || this._media.$iosControls();
58+
59+
setAttribute(this.el, 'aria-hidden', isHidden ? 'true' : null);
60+
setStyle(this.el, 'display', isHidden ? 'none' : null);
61+
}
62+
5163
private _watchHideDelay() {
5264
const { controls } = this._media.player,
5365
{ hideDelay } = this.$props;

0 commit comments

Comments
 (0)