Giter VIP home page Giter VIP logo

multitouchgestures's Introduction

Multi-Touch Gestures

Multi-Touch Gestures(Java) for detecting custom gestures

alt text

Add to your project

Add the jitpack maven repository

allprojects {
  repositories {
    ...
    maven { url 'https://jitpack.io' }
  }
}

Add the dependency

dependencies {
  implementation 'com.github.slaviboy:MultiTouchGestures:v0.1.0'
}

Documentation

Examples

Set up your view(it can be whatever view type you want) using xml

<View
  android:id="@+id/gesture_view"
  android:layout_width="match_parent"
  android:layout_height="match_parent"/>

Create your gesture detector object using java

// init multi finger gesture detector
GestureDetector detector = new GestureDetector();

// attach gesture detector listener to your view
View view = findViewById(R.id.gesture_view);
view.setOnTouchListener(detector);

Add Listener

detector.setOnGestureListener(new GestureDetector.OnGestureListener() {
  @Override
  public void onStateChange(Finger[] fingers, int fingerIndex) {

  }
});

Supported finger states

At any moment in time, each finger has a current state. Using those states for multiple fingers, you can form multi-touch gesture.

  • NONE
  • SWIPE UP
  • SWIPE DOWN
  • SWIPE LEFT
  • SWIPE RIGHT
  • HOLD_DOWN
  • DOWN
  • UP
  • MOVE UP
  • MOVE DOWN
  • MOVE LEFT
  • MOVE RIGHT
  • DOUBLE TAP

GestureDetector Object Properties

  • holdDownDelay - (default:100) delay time(ms) after which if finger is -hold down, state will be changed to HOLD_DOWN
  • upDelay - (default:50) delay time(ms), after which if finger is -swiped, state will be changed to UP
  • consumeTouchEvents - (default:true) whether to consume touch event after handling
  • numberOfFingers - (default:2) number of allowed fingers, that will be detected

Finger Object Properties

  • minDistanceSwipe - (default:10) minimum distance finger must travel, before swipe can be detected
  • maxDurationSwipe - (default:400) maximum time after which swipe WILL NOT be detected (ms)
  • minDistanceMove - (default:30) minimum distance finger must travel, before move can be detected
  • maxDurationDoubleTap - (default:250) maximum delay time between the two -down events for the double tap (ms)
  • maxDownDoubleTap - (default:100) maximum time the finger can be hold down for the two -down events (ms)
  • slopeIntolerance - (default:1) slope intolerance for swipe and move

multitouchgestures's People

Contributors

slaviboy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

multitouchgestures's Issues

Can't add custom view on touch with multiple fingers

I am using this lib and quite good.
But i want to add custom view on touch on my layout. I need to add multiple views on touch of fingers.

But in your code i can't understand how to use that because onStateChanged method i can't get x,y coordinates as i want to add views at random positions.

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.