Git Product home page Git Product logo

toucher's Introduction

#toucher是什么 toucher是一个面向移动端web开发,通过监听原生事件模拟手势事件的库。

####使用案例demo/图像预览实现原理

#目前支持哪些事件 基本事件

  • singleTap:轻击
  • doubleTap:双击
  • longTap:长按
  • swipeUp:上划
  • swipeRight:右划
  • swipeDown:下划
  • swipeleft:左划

高级事件

  • swipeStart:滑动开始
  • swipe:滑动(阻止浏览器默认事件,滑动过程效果更佳)
  • swipeEnd:滑动结束

#说明 目前尚不支持双指操作的事件,此类事件可能会在下次大的更新之后作为补充加入进来。

事件触发时不阻止浏览器默认事件,若要用于拖动操作,或滑动更为细腻,可在swipe事件中使用“return false;”阻止浏览器默认事件!

#DEMO 请使用移动设备或使用调试工具模拟移动设备查看 demo/案例demo/图像预览

#如何使用 接口提供了链式调用的实现,及事件委托(仅支持class)。

var myTouch = util.toucher(document.getElementById('touchBox'));

myTouch.on('singleTap',function(e){
    //
}).on('longTap',function(e){
	//
}).on('singleTap','.checkA',function(e){
	console.log(this,e);
	return false
});

toucher's People

Contributors

bh-lay avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

toucher's Issues

为什么不用这种方式进行委托

var box = document.getElementById("box");
    box.addEventListener('click',function(e) {
        var target = e.target;
        if(e.target.className = "item") {
            console.log('ok');
        }
        })

touch事件中用eventMark缓存e会使阻止冒泡失效

在touchend这个函数中你说到的 //touchend中,拿不到坐标位置信息,故使用全局保存下的事件因为这个而弃用了touchend中的event,而是使用了touchstart或touchmove中保存的event,这样会导致touchen中触发的事件无法使用阻止冒泡和阻止默认行为。建议可以在touchend中可以使用changedTouches代替touches来取坐标位置信息

以上反馈来自于:@DMQ

有报错呢

x1 = e.touches[0].pageX;

Uncaught TypeError: Cannot read property '0' of undefined
at HTMLDivElement.touchStart (toucher_2cb1d8f.js:174)

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.