Matchstic / libwidgetinfo

Provides a bridge for iOS private frameworks to JavaScript (WKWebView)
GNU Affero General Public License v3.0
7 stars 1 forks source link

Vibration/Taptic/Haptic motor provider #47

Open 0neGal opened 3 years ago

0neGal commented 3 years ago

This'd allow widgets to give the user feedback when clicking things, which could be very useful to give the widgets a more native feel.

0neGal commented 3 years ago

Furthermore the API could look like this:

api.vibrate({
    type: "medium", // or heavy, light etc, this'd only be available for taptic engine devices
    duration: 300, // self explanatory, how long the vibration will last (in ms) not sure what iOS uses by default but properly some very low number
})

// in simpler form
api.vibrate({type "medium", duration: 300})

// or perhaps just normal arguments
// however in my opinion this is a bad idea.
api.vibrate("medium", 300) 
Matchstic commented 3 years ago

I’m fairly sure the JS specification already supports this. See: https://developer.mozilla.org/en-US/docs/Web/API/Navigator/vibrate

On 19 Feb 2021, at 18:51, 0neGal notifications@github.com wrote:

 Furthermore the API could look like this:

api.vibrate({ type: "medium", // or heavy, light etc, this'd only be available for taptic engine devices duration: 300, // self explanatory, how long the vibration will last (in ms) not sure what iOS uses by default but properly some very low number }) — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub, or unsubscribe.

0neGal commented 3 years ago

Didn't even know this existed! Quickly testing it, it doesn't seem to work?

window.navigator.vibrate(200)

At least it does nothing for me.