Skip to content

fix:update isSupported check to expand detection of mobile devices#26

Open
jayk293 wants to merge 2 commits intolochie:mainfrom
jayk293:fix/is-supported-ios
Open

fix:update isSupported check to expand detection of mobile devices#26
jayk293 wants to merge 2 commits intolochie:mainfrom
jayk293:fix/is-supported-ios

Conversation

@jayk293
Copy link
Copy Markdown

@jayk293 jayk293 commented Mar 7, 2026

isSupported is now expanded to handle all mobile devices with navigator.maxTouchPoints > 0 instead of just detection of the VibrationApi.

create supportsVibrationAPI internal check for to replace isSupported to detect VibrationApi
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 7, 2026

@jayk293 is attempting to deploy a commit to the Lochie's projects Team on Vercel.

A member of the Team first needs to authorize it.

@jayk293 jayk293 changed the title update isSupported check to expand detection of mobile devices fix:update isSupported check to expand detection of mobile devices Mar 13, 2026
@vercel
Copy link
Copy Markdown

vercel bot commented Mar 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
web-haptics Ready Ready Preview, Comment Mar 15, 2026 2:25pm

Request Review

static readonly isSupported: boolean =
typeof navigator !== "undefined" &&
(typeof navigator.vibrate === "function" ||
navigator.maxTouchPoints > 0);
Copy link
Copy Markdown
Owner

@lochie lochie Mar 15, 2026

Choose a reason for hiding this comment

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

after doing some research i dont think maxTouchPoints actually is accurate for when haptics are truly supported? i believe this would be true on touch enabled laptops 🤔

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Good spot. I did add some updates to ensure to validate the device is actually a mobile device.
iPads are not supported like iPhones in Web haptics, so made sure to not capture them as well.

Let me know what you think

…ce and not just a touch enabled device such as touch laptops or iPads
): Promise<void> {

if (!WebHaptics.isSupported && !this.debug) {
console.warn(`[web-haptics] Haptics not supported on this device.`,);
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Not sure if this would get too verbose for your liking. Happy to remove

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.

2 participants