Code Monkey home page Code Monkey logo

touchjs's Introduction

touchjs

页面上元素的滑动事件和移动端设备的默认滑动事件冲突?

为超初级选手提供的超级简单的移动端滑动事件监听代码片段(请注意是片段...)

何所谓炒鸡简单,就是不知道该怎么组织成一个功能完善的插件所以直接把最low的代码片段贴上去... 大家自行根据业务逻辑增加touchmove时,touchleft时,以及touchright时的代码,扩展功能极其强大...

  • e.preventDefault()阻止浏览器默认的滑动事件
  • 点击事件由touchend事件来判断,避免移动端300毫秒延迟对点击事件的影响,当然你可以用FastClick.js消除该影响来激发子元素上注册的点击事件
  • 关于这个10位置的偏移来判断是否为点击还是滑动,可任性改写
  • 当判定为点击时,e.target可以获取到实际点击的页面元素,然后可以获取该元素上的数据(data-*),想干嘛干嘛

有时候我们只需要能够判断向左向右向上向下的判断而已,而已...其他什么都不想要...

touchjs's People

Contributors

godengine avatar

Stargazers

 avatar

Watchers

 avatar  avatar

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.