maykar / lovelace-swipe-navigation

↔️ Swipe through Lovelace views on mobile.
MIT License
205 stars 72 forks source link

Ignores not working in Safari / Firefox #60

Open kmikiy opened 2 years ago

kmikiy commented 2 years ago

This line is never true in Safari or Firefox https://github.com/maykar/lovelace-swipe-navigation/blob/e7f4c98c09f628d7a5376afd1ae8d01a004e4f79/swipe-navigation.js#L71

I tried this in Safari and Firefox and these ignores won't work. Everything works fine in Chrome

System Health

version core-2021.9.4
installation_type Home Assistant OS
dev false
hassio true
docker true
user root
virtualenv false
python_version 3.9.6
os_name Linux
os_version 5.10.17-v7l
arch armv7l
timezone Europe/Budapest
Home Assistant Community Store GitHub API | ok -- | -- Github API Calls Remaining | 4981 Installed Version | 1.15.2 Stage | running Available Repositories | 879 Installed Repositories | 10
AccuWeather can_reach_server | ok -- | -- remaining_requests | 11
Home Assistant Cloud logged_in | false -- | -- can_reach_cert_server | ok can_reach_cloud_auth | ok can_reach_cloud | ok
Home Assistant Supervisor host_os | Home Assistant OS 6.3 -- | -- update_channel | stable supervisor_version | supervisor-2021.09.0 docker_version | 20.10.7 disk_total | 57.8 GB disk_used | 3.2 GB healthy | true supported | true board | rpi4 supervisor_api | ok version_api | ok installed_addons | Home Assistant Google Drive Backup (0.104.3), File editor (5.3.3), Terminal & SSH (9.1.3), Duck DNS (1.13.0), Z-Wave JS (0.1.38)
Lovelace dashboards | 2 -- | -- resources | 6 views | 7 mode | storage
kmikiy commented 2 years ago

Using event.composedPath() instead of path solved the issue for me. ~Apparently, it won't work in Edge though, but should work in Safari / Firefox / Chrome.~ It should be supported in all popular browsers except Internet Explorer

   ...
    if (typeof event.composedPath() == "object") {
      for (let element of event.composedPath()) {
        if (element.nodeName == "HUI-VIEW") break;
        else if (ignored.indexOf(element.nodeName) > -1) return;
      }
    }
  ...

Source: https://stackoverflow.com/questions/36845515/mouseevent-path-equivalent-in-firefox-safari