New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

fitbit-gestures

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fitbit-gestures

Library to detect gestures on Fitbit devices

  • 0.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Gestures for Fitbit

This library allows you to detect different gestures in Fitbit apps. Tested only on Fitbit SDK 5.0

Installation

Install the library with npm i fitbit-gestures or yarn add fitbit-gestures

Gestures

Swipe, Double Tap, Slide (More gestures soon)

Usage

You must provide an Element or the ID of an existing element.

Warning

Keep in mind that only one listener can be attached to each element. Attaching multiple detectors to the same element will overwrite the previous ones.

Gesture Detector

For each gesture, you can customize the detectors. View Single Gesture examples below.

import { GestureDetector, SlideData, SWIPE_DIR } from 'fitbit-gestures';

// Get the element. You can also pass the element ID
const element = document.getElementById('some_element'); 

const detector = new GestureDetector(element)
    .onSwipe((dir: SWIPE_DIR) => {
      //Do something
    })
    .onDoubleTap(() => {
      //Do something
    })
    .onSlide((data: SlideData) => {
      //Do something
    });
Single gesture detectors

If you only need one type of gesture, it will be slightly faster to use a dedicated class.

Swipe only
import { SwipeDetector, SWIPE_DIR, SwipeConfig } from 'fitbit-gestures';

// Get the element. You can also pass the element ID as string
const element = document.getElementById('some_element');

//Optional configuration
const swipeConfig: SwipeConfig = {
  threshold: 100
};

const detector = new SwipeDetector(element, onSwipe.bind(this), swipeConfig);

function onSwipe(direction: SWIPE_DIR) {
  if(SWIPE_DIR.DOWN) {
    //Do something
  }
}
Swipe configuration (Optional)
AttributeDescriptionDefault
thresholdDistance (in pixels) required to trigger the event100px
DoubleTap only
import { DoubleTapDetector, DoubleTapConfig } from 'fitbit-gestures';

// Get the element. You can also pass the element ID as string
const element = document.getElementById('some_element'); 

//Optional configuration
const doubleTapConfig: DoubleTapConfig = {
  interval: 250
}

const detector = new DoubleTapDetector(element, onDoubleTap.bind(this), doubleTapConfig);

function onDoubleTap() {
  //Do something
}
DoubleTap configuration (Optional)
AttributeDescriptionDefault
intervalTime (in ms) required to trigger the event250ms
Slide only
import { SlideDetector, SlideData } from 'fitbit-gestures';

// Get the element. You can also pass the element ID as string
const element = document.getElementById('some_element');

const detector = new SlideDetector(element, onSlide.bind(this));

function onSlide(data: SlideData) {
  //Do something
}

Keywords

FAQs

Package last updated on 07 Jan 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc