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

WIP: Add Reflex.Dom.Event to expose addEventListener options #402

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

3noch
Copy link
Member

@3noch 3noch commented Jul 16, 2020

Some events like touchstart and touchmove behave differently (by default) on different browsers. However, changing the default settings in addEventHandler is not at all straightforward. This PR attempts to solve two problems:

  1. Make it easy to customize options for addEventHandler.
  2. Offer a version of on for DOM events that always normalizes the behavior between browers so there is no discrepancy.

The changes are added in a new Reflex.Dom.Event module. Bikeshed away. Many things in Immediate.hs should probably be moved to this module as well.

@3noch 3noch force-pushed the eac@expose-addEventListener-options branch from d1f7535 to 1dd4cf8 Compare July 16, 2020 22:15
@3noch
Copy link
Member Author

3noch commented Jul 16, 2020

These changes could all go in ghcjs-dom and jsaddle-dom TBH except for the normalization bit.

-- for differences.
normalizedDefaultEventListenerOptions :: EventName t e -> EventListenerOptions
normalizedDefaultEventListenerOptions e = case eventNameString e of
name | name == "touchstart" || name == "touchmove" -> defaultEventListenerOptions { _eventListenerOptions_passive = True }
Copy link
Member Author

Choose a reason for hiding this comment

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

Downside to this approach is that it's a perf hit to every usage of on

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant