Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[A11Y] - playing videos in hover mode only when current hover on the item #1357

Merged
merged 4 commits into from
Feb 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions packages/gallery/src/components/helpers/videoScrollHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ class VideoScrollHelper {
//case VIDEO_EVENTS.hovered:
this.itemHovered(eventData);
break;
case GALLERY_CONSTS.events.HOVER_UNSET:
this.itemHoveredUnset(eventData);
break;
case GALLERY_CONSTS.events.VIDEO_ENDED:
//case VIDEO_EVENTS.ended:
this.videoEnded(eventData.idx);
Expand Down Expand Up @@ -121,6 +124,15 @@ class VideoScrollHelper {
}
}

itemHoveredUnset(idx) {
if (this.videoPlay !== 'hover') return;
if (this.IdxExistsInVideoItems(idx)) {
if (this.currentPlayingIdx === idx) {
this.stop(idx);
}
}
}

itemClicked(idx) {
if (this.videoPlay !== 'onClick') return;
// if (this.itemClick !== 'nothing') return;
Expand Down
8 changes: 8 additions & 0 deletions packages/gallery/src/components/item/itemView.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@ class ItemView extends React.Component {
onMouseLeave() {
if (!utils.isMobile()) {
this.props.actions.eventsListener(GALLERY_CONSTS.events.HOVER_SET, -1);
this.props.actions.eventsListener(
GALLERY_CONSTS.events.HOVER_UNSET,
this.props.idx
);
}
}

Expand All @@ -125,6 +129,10 @@ class ItemView extends React.Component {
onBlur() {
if (this.props.settings?.isAccessible) {
this.props.actions.eventsListener(GALLERY_CONSTS.events.HOVER_SET, -1);
this.props.actions.eventsListener(
GALLERY_CONSTS.events.HOVER_UNSET,
this.props.idx
);
}
this.props.actions.eventsListener(
GALLERY_CONSTS.events.ITEM_LOST_FOCUS,
Expand Down
1 change: 1 addition & 0 deletions packages/lib/src/common/constants/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const EVENTS = {
VIDEO_PAUSED: 'VIDEO_PAUSED',
VIDEO_PLAYED: 'VIDEO_PLAYED',
HOVER_SET: 'HOVER_SET',
HOVER_UNSET: 'HOVER_UNSET',
LOAD_MORE_CLICKED: 'LOAD_MORE_CLICKED',
ITEM_CLICKED: 'ITEM_CLICKED',
THUMBNAIL_CLICKED: 'THUMBNAIL_CLICKED',
Expand Down
Loading