GithubHelp home page GithubHelp logo

davidisaaclee / capacitor-haptics Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 111 KB

Non-monorepo fork of @capacitor/haptics

License: Other

Ruby 3.05% Swift 30.62% Java 39.29% JavaScript 2.13% TypeScript 24.92%

capacitor-haptics's Introduction

@capacitor/haptics

The Haptics API provides physical feedback to the user through touch or vibration.

On devices that don't have Taptic Engine or Vibrator, the API calls will resolve without performing any action.

Install

npm install @capacitor/haptics
npx cap sync

Example

import { Haptics, ImpactStyle } from '@capacitor/haptics';

const hapticsImpactMedium = async () => {
  await Haptics.impact({ style: ImpactStyle.Medium });
};

const hapticsImpactLight = async () => {
  await Haptics.impact({ style: ImpactStyle.Light });
};

const hapticsVibrate = async () => {
  await Haptics.vibrate();
};

const hapticsSelectionStart = async () => {
  await Haptics.selectionStart();
};

const hapticsSelectionChanged = async () => {
  await Haptics.selectionChanged();
};

const hapticsSelectionEnd = async () => {
  await Haptics.selectionEnd();
};

API

impact(...)

impact(options?: ImpactOptions | undefined) => Promise<void>

Trigger a haptics "impact" feedback

Param Type
options ImpactOptions

Since: 1.0.0


notification(...)

notification(options?: NotificationOptions | undefined) => Promise<void>

Trigger a haptics "notification" feedback

Param Type
options NotificationOptions

Since: 1.0.0


vibrate(...)

vibrate(options?: VibrateOptions | undefined) => Promise<void>

Vibrate the device

Param Type
options VibrateOptions

Since: 1.0.0


selectionStart()

selectionStart() => Promise<void>

Trigger a selection started haptic hint

Since: 1.0.0


selectionChanged()

selectionChanged() => Promise<void>

Trigger a selection changed haptic hint. If a selection was started already, this will cause the device to provide haptic feedback

Since: 1.0.0


selectionEnd()

selectionEnd() => Promise<void>

If selectionStart() was called, selectionEnd() ends the selection. For example, call this when a user has lifted their finger from a control

Since: 1.0.0


Interfaces

ImpactOptions

Prop Type Description Default Since
style ImpactStyle Impact Feedback Style The mass of the objects in the collision simulated by a UIImpactFeedbackGenerator object. ImpactStyle.Heavy 1.0.0

NotificationOptions

Prop Type Description Default Since
type NotificationType Notification Feedback Type The type of notification feedback generated by a UINotificationFeedbackGenerator object. NotificationType.SUCCESS 1.0.0

VibrateOptions

Prop Type Description Default Since
duration number Duration of the vibration in milliseconds. 300 1.0.0

Enums

ImpactStyle

Members Value Description Since
Heavy 'HEAVY' A collision between large, heavy user interface elements 1.0.0
Medium 'MEDIUM' A collision between moderately sized user interface elements 1.0.0
Light 'LIGHT' A collision between small, light user interface elements 1.0.0

NotificationType

Members Value Description Since
Success 'SUCCESS' A notification feedback type indicating that a task has completed successfully 1.0.0
Warning 'WARNING' A notification feedback type indicating that a task has produced a warning 1.0.0
Error 'ERROR' A notification feedback type indicating that a task has failed 1.0.0

capacitor-haptics's People

Contributors

davidisaaclee avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.