关于zepto.js的移动端拖拽写法
2016-07-21 16:56
405 查看
<!doctype html> <html> <head> <meta charset="utf-8"> <meta name="author" content="和派孔明" /> <meta name="copyright" content="和派孔明" /> <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/> <title>关于zepto.js的移动端拖拽写法</title> <style> #div1{ position:absolute;left:0;top:0;width:200px; height:200px; background:#ccc;} </style> <script src="zepto.min.js"></script> <script> $(function(){ var disX = ev.targetTouches[0].pageX - $(this).position().left; var disY = ev.targetTouches[0].pageY - $(this).position().top; $(this).on("touchmove",function(ev){ $(this).css({ left:ev.targetTouches[0].pageX - disX + "px", top:ev.targetTouches[0].pageY - disY + "px" }); }); $(this).on("touchend",function(){ $(this).off('touchstart','touchmove'); }); }); }); </script> </head> <body> <div id="div1"></div> </body> </html>
相关文章推荐
- android AsyncTask
- dylibs/frameworks are only supported on iOS 8.0 and later
- ios 从一个tabBar跳转另一个tabBar
- 我所理解的Cocos2d-x 应用程序架构
- 41.You have recently collected statistics on certain objects of a schema in your database. But you o
- android 将开源项目发布到JCenter及问题总结
- Android冷启动白屏解析,带你一步步分析和解决问题
- iOS中 视频直播功能-流媒体的使用(详解)
- Android API之Drag&Drop
- android 黑名单中电话拦截
- Android wifi无线调试App新玩法ADB WIF,very cool!!
- android TextView中文字通过SpannableString设置属性
- Unity实现绘制线断二-----用GL画矩形线框
- Android studio基本使用(1)
- iOS 事件响应
- 使用PHAsset获取相册中特定的图片
- Android Studio 使用的快捷键
- android基础(四)
- Android4.4 Sensor APP-->HAL代码流程
- 使用Jenkins自动化构建Android和iOS应用