Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Track how far the user travels before dismissing their user settings #2183

Merged
merged 1 commit into from
Oct 4, 2018

Conversation

turt2live
Copy link
Member

Fixes element-hq/element-web#7158

Because the onClick was on a fullpage div, the browser was firing it regardless of how far the mouse moved. The onClick event itself doesn't give us any sort of travel distance, or a start point we can use to determine if they clicked a scrollbar or something. This means we have to rely on good ol' fashioned mouse down and up events to see if the user moved their mouse during their click.

If the user's click starts in a valid container, we record the coordinates. This is so we can easily identify when the user clicks inside something like the settings container itself. When the user releases their mouse, we determine how far they moved their mouse - if the distance is within some threshold (~5 pixels in this case) then we can count it as a click. Because we've already filtered on the component they started their click in, we can safely rely on the presence of coordinates as a flag that they are in the right container, combined with the fact that they can't stray too far before their click not counting anyways.

Fixes element-hq/element-web#7158

Because the onClick was on a fullpage div, the browser was firing it regardless of how far the mouse moved. The onClick event itself doesn't give us any sort of travel distance, or a start point we can use to determine if they clicked a scrollbar or something. This means we have to rely on good ol' fashioned mouse down and up events to see if the user moved their mouse during their click. 

If the user's click starts in a valid container, we record the coordinates. This is so we can easily identify when the user clicks inside something like the settings container itself. When the user releases their mouse, we determine how far they moved their mouse - if the distance is within some threshold (~5 pixels in this case) then we can count it as a click. Because we've already filtered on the component they started their click in, we can safely rely on the presence of coordinates as a flag that they are in the right container, combined with the fact that they can't stray too far before their click not counting anyways.
@turt2live turt2live requested a review from a team September 27, 2018 22:14
Copy link
Member

@dbkr dbkr left a comment

Choose a reason for hiding this comment

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

ew, but ok, if there's no better way to do this :/

@turt2live
Copy link
Member Author

Short of moving the click detection to the layers we want to detect on (multiplying the code in places), not really. It is not great though :(

@turt2live turt2live merged commit 93d32f9 into develop Oct 4, 2018
@turt2live turt2live deleted the travis/settings-no-sniping branch October 4, 2018 19:29
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants