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

Improve click handling on touch devices #683

Merged
Show file tree
Hide file tree
Changes from 2 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
8 changes: 7 additions & 1 deletion src/scss/components/settings/_settingspanelitem.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@
cursor: pointer;
}

&:hover {
@media (hover: hover) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This only adds the hover style on devices where hover is supported.

&:hover {
background-color: transparentize($color-item-hover, .15);
}
}

&:active {
background-color: transparentize($color-item-hover, .15);
}

Expand Down
3 changes: 2 additions & 1 deletion src/ts/components/buttons/Button.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ export class Button<Config extends ButtonConfig> extends Component<Config> {
}).html(i18n.performLocalization(this.config.text)));

// Listen for the click event on the button element and trigger the corresponding event on the button component
buttonElement.on('click', (e) => {
buttonElement.on('click touchend', (e) => {
e.preventDefault();
e.stopPropagation();
this.onClickEvent();
});
Expand Down
3 changes: 2 additions & 1 deletion src/ts/components/settings/DynamicSettingsPanelItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,8 @@ export class DynamicSettingsPanelItem extends SettingsPanelItem<DynamicSettingsP
const handleItemClick = () => {
this.displayItemsSubPage();
};
this.getDomElement().on('click', (e) => {
this.getDomElement().on('click touchend', (e) => {
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dweinber found an issue with this approach. The touchend triggers and opens the sub menu when releasing the touch after scrolling within the settings panel.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is fixed again by removing the touchend listeners again in: d596dbf

Note: The touchend listeners were a solution for an issue that the click event did not trigger every time on non button components. However, this was only observed in combination with the iOS Player SDK. This issue is already known and the rootcause is within the Player SDK where we call the native code from the Javascript context. This is not performant enough and blocks the Javascript execution. We will tackle this in the iOS Player SDK.

e.preventDefault();
e.stopPropagation();
handleItemClick();
});
Expand Down
6 changes: 5 additions & 1 deletion src/ts/components/settings/SettingsPanelSelectOption.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,11 @@ export class SettingsPanelSelectOption extends SettingsPanelItem<SettingsPanelSe
const handleItemClick = () => {
this.settingComponent.selectItem(this.settingsValue);
};
this.getDomElement().on('click', () => handleItemClick());
this.getDomElement().on('click touchend', (e) => {
e.preventDefault();
e.stopPropagation();
handleItemClick();
});

// Initial state
handleSelectedOptionChanged();
Expand Down
Loading