Super tiny size multi-touch gestures library for the web.    You can touch this →

Overview

Preview

You can touch this → http://alloyteam.github.io/AlloyFinger/

Install

You can install it via npm:

npm install alloyfinger

Usage

var af = new AlloyFinger(element, {
    touchStart: function () { },
    touchMove: function () { },
    touchEnd:  function () { },
    touchCancel: function () { },
    multipointStart: function () { },
    multipointEnd: function () { },
    tap: function () { },
    doubleTap: function () { },
    longTap: function () { },
    singleTap: function () { },
    rotate: function (evt) {
        console.log(evt.angle);
    },
    pinch: function (evt) {
        console.log(evt.zoom);
    },
    pressMove: function (evt) {
        console.log(evt.deltaX);
        console.log(evt.deltaY);
    },
    swipe: function (evt) {
        console.log("swipe" + evt.direction);
    }
});

/**
 * this method can also add or remove the event handler
 */
var onTap = function() {};

af.on('tap', onTap);
af.on('touchStart', function() {});

af.off('tap', onTap);

/**
 * this method can destroy the instance
 */
af = af.destroy();

Omi Version:

import { render, tag, WeElement } from 'omi'
import 'omi-finger'

@tag('my-app')
class MyApp extends WeElement {
  install() {
    this.data.wording = 'Tap or Swipe Me!'
  }

  handleTap = (evt) => {
    this.data.wording += '\r\nTap'
    this.update()
  }

  handleSwipe = (evt) => {
    this.data.wording += '\r\nSwipe-' + evt.direction
    this.update()
  }

  render() {
    return (
      <div>
        <omi-finger onTap={this.handleTap} abc={{a:1}} onSwipe={this.handleSwipe}>
          <div class="touchArea" >
            {this.data.wording}
          </div>
        </omi-finger>
      </div>
    )
  }

  css() {
    return `.touchArea{
                  background-color: green;
                  width: 200px;
                  min-height: 200px;
                  text-align: center;
                  color:white;
                  height:auto;
                  white-space: pre-line;
              }`
  }
}

render(<my-app></my-app>, 'body')

Others

License

This content is released under the MIT License.

Comments
  • 请问怎么在vue-cli里面最方便的引入?

    请问怎么在vue-cli里面最方便的引入?

    Vue.use(AlloyFingerVue)这种在main.js里面根本无法引入,

    import AlloyFinger from './lib/alloy_finger'
    import AlloyFingerVue from './lib/af'
    //上面的就是那个为vue专门配置的js文件
    Vue.use(AlloyFingerVue)
    

    这是报错

    Uncaught Error: you need include the AlloyFinger!
        at Object.install (eval at <anonymous> (app.js:1099), <anonymous>:15:15)
        at Function.Vue.use (eval at <anonymous> (app.js:1047), <anonymous>:3433:22)
        at eval (eval at <anonymous> (app.js:812), <anonymous>:23:45)
        at Object.<anonymous> (app.js:812)
        at __webpack_require__ (app.js:654)
        at fn (app.js:84)
        at Object.<anonymous> (app.js:1133)
        at __webpack_require__ (app.js:654)
        at app.js:701
    
    opened by ToPeas 6
  • 文档不健全,各种报错,无语了

    文档不健全,各种报错,无语了

    导入报错

    • import导入报错
    import Vue from 'vue'
    import AlloyFinger from 'alloyfinger'
    import AlloyFingerPlugin from 'alloyfinger/vue/alloy_finger.vue'
    Vue.use(AlloyFingerPlugin, {
        AlloyFinger
    })
    
    • require还是报错
    import Vue from 'vue'
    import AlloyFinger from 'alloyfinger'
    const AlloyFingerPlugin =  require('alloyfinger/vue/alloy_finger.vue.js')
    Vue.use(AlloyFingerPlugin, {
      AlloyFinger
    })
    

    导入报错原因截图

    jietu20190103-142238

    控制台报错信息

    vue.runtime.esm.js?2b0e:587 [Vue warn]: Failed to resolve directive: finger
    

    结论

    vue导出有问题

    opened by youcanping 4
  • 在pinch的手势的响应问题。

    在pinch的手势的响应问题。

    感谢团队的分享,AlloyFinger非常好用,但是我发现一个关于pinch的问题。 我在vue中通过v-finger:pinch添加了手势,但是发现pinch的手势在第一次也就是两根手指按下的时候就已经触发了,这导致了当图片比较大的时候,缩小变得困难(两根手指刚触摸到手机时已经触发了一次pinch的事件,导致图片又变大),理想的情况应该是手指移动的时候才会触发。

    希望给予解决的思路,谢谢。

    opened by mikelrmb 4
  • 为 react 版本增加 prepare 脚本和 babel 编译后的文件

    为 react 版本增加 prepare 脚本和 babel 编译后的文件

    现在 npm 社区的主流实践是:源代码可以用 es6 来开发,但发布到 npm 的时候,一定要同时提供 babel 编译后的版本(用 prepare 钩子脚本的方式),确保能被绝大部分项目直接使用,而无需在这些项目中去编译

    原因是:1. 很多服务器端项目使用的 node.js 版本不支持原生 es6。2. 很多客户端项目是基于 webpack + babel-loader 的,最佳实践是在编译时忽略 node_modules 的文件:

    https://github.com/babel/babel-loader#babel-loader-is-slow

    opened by dexteryy 4
  • Does it make sense to spawn > 10 empty functions?

    Does it make sense to spawn > 10 empty functions?

    see title.

    Maybe a function to call functions would solve the issue:

    call: function (method) {
    return typeof this[method] === 'function' ? this[method]() : false;
    }
    
    opened by kurtextrem 4
  • add moved condition

    add moved condition

    If somebody ever moved his finger somewhere and (maybe not intended)back to the first place, in this condition, I think he will not want to dispatch the tap event.So, I added the ever moved condition. Hope to take my advice. 如果某人把手指移动到了某个地方后又(可能无意识的)移动回了初始触摸点附近,在这种情况下,他可能并不想触发tap事件,所以我添加了对这种情况的判断。代码中以10px为临界点,是因为觉得30px有点大。希望能合并我的代码。

    opened by zsusyt 2
  • Vue里如何像原生的@click事件一样的传参数

    Vue里如何像原生的@click事件一样的传参数

    vue2的传参问题

    当我给事件绑定了

    <div 
        v-finger:tap="tap('我是参数')"
    </div>
    
    methods: {
    	tap: function(e) { console.log(e)}
     }
    

    那么这样的这个tap事件当我一进入页面的时候就会被触发(在chrome模拟的移动端设备)。再点击的话,j就再也触发不了tap事件了。

    opened by ToPeas 2
  • destroy need to check if not null

    destroy need to check if not null

    when you do something like: this.rotate.del(); sometimes this.rotate can be null

    I think it should check for existence before try to delete anything like:

               if (this.rotate) this.rotate.del();
               if (this.touchStart) this.touchStart.del();
               if (this.multipointStart) this.multipointStart.del();
               if (this.multipointEnd) this.multipointEnd.del();
               if (this.pinch) this.pinch.del();
               if (this.swipe) this.swipe.del();
               if (this.tap) this.tap.del();
               if (this.doubleTap) this.doubleTap.del();
               if (this.longTap) this.longTap.del();
               if (this.singleTap) this.singleTap.del();
               if (this.pressMove) this.pressMove.del();
               if (this.touchMove) this.touchMove.del();
               if (this.touchEnd) this.touchEnd.del();
               if (this.touchCancel) this.touchCancel.del();
    
    opened by boynet 2
  • vue动态组件component:is和v-finger:swipe

    vue动态组件component:is和v-finger:swipe

    一个绑定了v-finger:swipe的router-view有一个动态子组件:

    <router-view v-finger:swipe="handleSwipe">
        <component :is="componentName"></component>
    </router-view>
    

    (这部分代码只表示<router-view><component>的嵌套关系,当然实际上不是这么写的)

    当v-bind:is的组件名改变之后,swipe就失效了。 不仅如此我还试着用v-finger:touch-move代替(简单代替)swipe,也失效了。

    我发现到,当component:is发生改变时,这个router-view所指向的元素的touch事件都丢失了

    image ↑ before

    image ↑ after

    实际上,我也不知道是不是动态组建变更造成这个问题。 🤦‍♂️

    opened by shaopei-xie 1
  • Provide trigger `v-finger` guides in render function using `createElement`

    Provide trigger `v-finger` guides in render function using `createElement`

    In template we can use v-finger:tap="handleTap"

    In render function using createElement

    {
     directives: [
           {
             name: 'finger',
             expression: 'handleTap',
             arg: 'tap',
           }
       ]
    }
    

    is not working...

    opened by even-today 1
  • remove scroll 事件疑问

    remove scroll 事件疑问

    近来在学习该项目的源码,有一个地方不太理解。 为什么 AlloyFinger 在初始化的时候

    window.removeEventListener('scroll', this._cancelAllHandler); // 这里为什么要 remove 呢?有其他情况会引起重复定义吗?
    window.addEventListener('scroll', this._cancelAllHandler);
    
    opened by henrycjchen 1
  • reedit 的 react 版 alloyFinger 有 bug

    reedit 的 react 版 alloyFinger 有 bug

    原版在页面滚动时(scroll)取消了 touch 相关事件的监听 ` this._cancelAllHandler = this.cancelAll.bind(this); window.addEventListener('scroll', this._cancelAllHandler);

    cancelAll: function () { this._preventTap = true clearTimeout(this.singleTapTimeout); clearTimeout(this.tapTimeout); clearTimeout(this.longTapTimeout); clearTimeout(this.swipeTimeout); }, `

    react 版里没有做同样的事情 ` _handleTouchCancel(evt) { this._emitEvent('onTouchCancel', evt); clearInterval(this.singleTapTimeout); clearInterval(this.tapTimeout); clearInterval(this.longTapTimeout); clearInterval(this.swipeTimeout); }

    render() { return React.cloneElement(React.Children.only(this.props.children), { onTouchStart: this._handleTouchStart.bind(this), onTouchMove: this._handleTouchMove.bind(this), onTouchCancel: this._handleTouchCancel.bind(this), onTouchEnd: this._handleTouchEnd.bind(this) }); }

    `

    opened by Ragon2019 0
👇 Bread n butter utility for component-tied mouse/touch gestures in Solid.

solid-gesture solid-gesture is a port of @use-gesture/react which lets you bind richer mouse and touch events to any component or view. With the data

Robert Soriano 8 Sep 30, 2022
App that allows you to control and watch YouTube videos using hand gestures. Additionally, app that allows you to search for videos, playlists, and channels.

YouTube Alternative Interaction App An app I made with Edward Wu that allows you to search and watch videos from YouTube. Leverages Google's YouTube D

Aaron Lam 2 Dec 28, 2021
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till människor på flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
Pressure is a JavaScript library for handling both Force Touch and 3D Touch on the web

Pressure is a JavaScript library for handling both Force Touch and 3D Touch on the web, bundled under one library with a simple API that makes working with them painless.

Stuart Yamartino 2.9k Dec 29, 2022
Conveyer adds Drag gestures to your Native Scroll.

Conveyer Demo / Documentation / Other components Conveyer adds Drag gestures to your Native Scroll. ?? ?? ?? ✨ Features You can use Native Scroll-like

NAVER 70 Dec 15, 2022
A super tiny Javascript library to make DOM elements draggable and movable. ~500 bytes and no dependencies.

dragmove.js A super tiny Javascript library to make DOM elements draggable and movable. Has touch screen support. Zero dependencies and 500 bytes Gzip

Kailash Nadh 814 Dec 29, 2022
FortBlog adds a nice UI where you can manage a publication of any size with posts, pages, tags, and authors

FortBlog adds a nice UI where you can manage a publication of any size with posts, pages, tags, and authors. You can add photos, code blocks, featured images, social media & SEO attributes, embedded HTML (YouTube Videos, Embedded Podcasts Episodes, Tweets, ...), and markdown! Dark & Light modes available so everyone is happy

Haseeb Ahmad 11 Jan 2, 2023
proxy 🦄 yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner

proxy ?? yxorp is your Web Proxy as a Service (SAAS) Multi-tenant, Multi-Threaded, with Cache & Article Spinner. Batteries are included, Content Spinning and Caching Engine, all housed within a stunning web GUI. A unique high-performance, plug-and-play, multi-threaded website mirror and article spinner

4D/ҵ.com Dashboards 13 Dec 30, 2022
This is a project that is used to execute python codes in the web page. You can install and use it in django projects, You can do any operations that can be performed in python shell with this package.

Django execute code This is a project that is used to execute python codes in the web page. You can install and use it in django projects, You can do

Shinu 5 Nov 12, 2022
A refined tool for exploring open-source projects on GitHub with a file tree, rich Markdown and image previews, multi-pane multi-tab layouts and first-class support for Ink syntax highlighting.

Ink codebase browser, "Kin" ?? The Ink codebase browser is a tool to explore open-source code on GitHub, especially my side projects written in the In

Linus Lee 20 Oct 30, 2022
一个运行在浏览器内的提词器,可翻页,可变速,可自定义字体、大小、颜色等多种选项 A teleprompter in web browser, page down, speed up , custom font family/size/color and more.

Introduction 一个运行在浏览器内的提词器,可翻页,可变速,可自定义字体、大小、颜色等多种选项 A teleprompter in web browser, page down, speed up , custom font family/size/color and more. inst

Daniel Liu 19 Aug 17, 2021
The website which can help you to organize your daily or weekly activities and review them when you need them. you can add, remove and delete an activity

To Do list To do project is webpack project that list activities someone can do at a specific time In this TO-DO list, you can add or remove you activ

Joffrey NKESHIMANA 5 Jul 21, 2022
This is a simple web application of a To-do List in which you can add, remove and edit all your tasks and also you can mark each task as completed and delete all completed ones.

To-Do List A simple web application of a to do list Built With HTML, CSS, JS, ES6 & Webpack Getting Started In this repository I created To-Do List SP

Juan Sebastian Sotomayor 12 Apr 11, 2022
This package will help parse OData strings (only the Microsoft Dataverse subset). It can be used as a validator, or you can build some javascript library which consumes the output of this library.

@albanian-xrm/dataverse-odata This package will help parse OData strings (only the Microsoft Dataverse subset). It can be used as a validator, or you

AlbanianXrm 3 Oct 22, 2022
Smart Auto Move learns the size and position of your application windows and restores them to the correct place on subsequent launches. Supports GNOME Wayland.

smart-auto-move smart-auto-move is a Gnome Shell extension which keeps track of all application windows and restores them to the previous position, si

khimaros 40 Dec 23, 2022