This repository was archived by the owner on Feb 14, 2020. It is now read-only.
swipe-card: Prevent touchend from reaching cards#41
Open
postlund wants to merge 1 commit into
Open
Conversation
This change prevents touchend events from reaching the cards by turning the event propagation order around (from bubbling to capture). It probably does not cover all uses-cases, but should work find with all cards utilizing the "longpress" implementation in lovelace (the @ha-click attribute for instance).
Owner
|
Thanks for the PR, I have to dive into this, and don't have the time at the moment. Will get back asap! |
Author
|
No worries! One thing that you could argue is missing is a check it touch is supported. In the end it doesn't matter, but it would be nice. |
Owner
|
OK, sorry for the wait. Will look into this this week. Have you experienced any problems or all good? |
Author
|
No worries! I've been using it a lot on my phone and it works very good in my particular use cases. You cannot, however, place other touch components (like an |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The main purpose of this PR is to "fix" the unwanted clicking of cards during swiping on mobile devices, that has been pointed out quite a few times in https://community.home-assistant.io/t/lovelace-swiper-card/72447. It does so by turning the event propagation order around for
touchend(used to identify clicks in most cases) from bubbling to capture. This way the event can be stopped from reaching the cards in case swiping was performed. Before, thetouchendwould start at the cards and propagate back to this component, so the click action would always be performed.This is probably not the best way of doing things (I am by no means a web developer) and it is not very well tested (my only use case is with some button cards). So I'm throwing this out there to get some feedback, would be very nice to see this issue fixed.