Code Monkey home page Code Monkey logo

touchswipe-zepto-plugin's Introduction

最近做webAPP应用用到一些touch事件,找了很多touch的库(包括zepto的touch模块),在手机上测试都是有各种各样的问题,要么就滑不动,要么只能左右滑动不能上下滑动等,终于找到一个好用强大的touch库,但是只有jquery版本的,然后我就把它改成了也兼容zepto的版本放到了这里。

github项目地址:https://github.com/mattbryson/TouchSwipe-Jquery-Plugin

本改装是基于官网的1.6.9,只需要zepto的核心模块:zepto,event,data(可选)

Demos

Basic swipe

events: swipe,swipeLeft, swipeRight, swipeUp, swipeDown

$("#test").swipe( {
	swipe:function(event, direction, distance, duration, fingerCount, fingerData) {
		$("#test").text("You swiped " + direction + " with " + fingerCount + " fingers");
	},
	threshold:0,
	fingers:'all'
});

threshold

Default is 75px, set to 0 for demo so any distance triggers swipe

fingers

By setting the number of fingers to 'all', any number of fingers will trigger the swipe.

Single swipe

events: swipeLeft, swipeRight, swipeUp, swipeDown, swipe

  $("#test").swipe({
	swipeLeft:function(event, direction, distance, duration, fingerCount) {
      $(this).text("You swiped " + direction + " " + ++count + " times " );  
    },
    threshold:0
  });

Finger swipe

 $("#test").swipe({
	swipeStatus:function(event, phase, direction, distance, duration, fingers, fingerData) {
		if(phase==$.fn.swipe.phases.PHASE_START) {
      		$(this).text("moving...");
    	} 
    	if(phase==$.fn.swipe.phases.PHASE_CANCEL) {
      		$(this).text("swipe cancelled (due to finger count) "  );
    	}   
    },
    swipe:function(event, direction, distance, duration, fingerCount, fingerData) {
      $(this).text("You swiped " + direction + " with " + fingerCount + " fingers");
    },
    threshold:0,
    fingers:2
  });

Pinch

....

功能很强大,可以看example

touchswipe-zepto-plugin's People

Contributors

huanz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

touchswipe-zepto-plugin's Issues

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.