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

[Capacitor] Haptic feedback #2392

Open
raineorshine opened this issue Sep 12, 2024 · 7 comments
Open

[Capacitor] Haptic feedback #2392

raineorshine opened this issue Sep 12, 2024 · 7 comments
Assignees
Labels
feature New feature or request

Comments

@raineorshine
Copy link
Contributor

raineorshine commented Sep 12, 2024

Use the Capacitor Haptics API to provide physical feedback to the user.

https://capacitorjs.com/docs/apis/haptics

Haptic options:

Haptic requirements:

  • Gesture
    • start: selectionStart
    • swipe: selectionChanged
    • end: selectionEnd
      • except Back/Forward: impact (light)
      • except Delete: notification (warning)
      • except Delete permanently: notification (warning)
    • cancel: notification (warning)
  • Scroll
    • Continuous impact? Like old iPod or Nest wheel.
  • Long tap
    • start: selectionStart
  • Drag-and-drop
    • start: selectionStart
    • drop target changes: selectionChanged
    • end: selectionEnd
    • cancel: notification (warning)
  • Hamburger menu
    • toggle: impact (light)
  • Link
    • click: impact (light)
  • Button
    • click: impact (light)

Plan for 1–2 iterations of tweaks once initial implementation can be physically tested.

@raineorshine raineorshine added the feature New feature or request label Sep 12, 2024
@raineorshine raineorshine changed the title Capacitor: Haptic feedback [Capacitor] Haptic feedback Oct 30, 2024
@raineorshine raineorshine added this to the 🖲️ Capacitor milestone Oct 30, 2024
@msdewitt
Copy link
Collaborator

@raineorshine I've been looking into this issue for a bit now and I have a few questions we can discuss about it. The majority of these Haptrics changes involve impact (light) and I found that we can make it uniform by adding it during the fastClick.ts file which is used throughout the app.

Is this something you are interested in? It adds a light vibration at almost every 'button action' throughout the app, including links, when you tap the screen anywhere to scroll when you open the hamburger menu, and in most other places.

The selectionStart and selectionEnd probably can't be handled in a generic way like this, but its still nice to find this. Tell me what you think.

@msdewitt msdewitt mentioned this issue Nov 22, 2024
@raineorshine
Copy link
Contributor Author

raineorshine commented Nov 23, 2024

Yes, agreed!

The only one that I'm unsure of is "when you tap the screen anywhere to scroll". Do you mean when you tap the scroll zone on the right?

We can easily add an option to fastClick to preventHaptic for the few exceptions.

@msdewitt
Copy link
Collaborator

msdewitt commented Nov 24, 2024

@raineorshine, I added selectionChanged to the MultiGesture feature when a user swipes the canvas, but I saw that it triggers each time the canvas is updated. Was this what you considered when you listed it on this ticket? Or were you thinking it would be just a selectionStart and selectionEnd event after the user finishes drawing?

Screenshot 2024-11-24 at 10 18 53 AM

@raineorshine
Copy link
Contributor Author

raineorshine commented Nov 24, 2024

The gesture should trigger haptics at the start, at the end, and once for each swipe. So →↓→ would trigger:

→ selectionStart
↓ selectionChanged
→ selectionChanged
[release] selectionEnd

@msdewitt
Copy link
Collaborator

@raineorshine Got it. I got that worked out in the new pr.

I had another question about the drag-and-drop feature. I tried adding Haptics to it, but I can't seem to replicate the drag and drop feature. Is there a bug here that I don't know about?

Simulator.Screen.Recording.-.iPhone.15.Pro.-.2024-11-25.at.11.56.44.mp4

@raineorshine
Copy link
Contributor Author

Ah yes, drag-and-drop currently has some issues that were introduced in #950. This is being tracked in #2474. The developer responsible is currently held up with some other work. We will have to wait till that is fixed before we can add drag-and-drop haptics.

I won't hold up the milestone if #2474 is still stalled.

@msdewitt
Copy link
Collaborator

Alright, thanks for the quick response.

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

No branches or pull requests

2 participants