码迷,mamicode.com
首页 > Web开发 > 详细

HTML5 touche vents drag to move & AF actionsheet by longTap

时间:2015-02-16 01:38:51      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:

 $(‘img‘).on("touchstart",function(E){
                            //E.preventDefault();E.stopPropagation();
                            var el=this;var me=$(this);$("#tip").text("in touchstart");
                            var t=E.touches[0];
                            console.log("touchstart!,mx,my=(",t.pageX,",",t.pageY,") ,el.x,y=(",el.offsetLeft,",",el.offsetTop,")" );
                                    me.data("mx",t.pageX);me.data("my",t.pageY);
                                    me.data("ex",el.offsetLeft);me.data("ey",el.offsetTop);

                        })
                        .on(‘touchmove‘,function(E){E.preventDefault();E.stopPropagation();
                            console.log("touchmove");var el=this;var me=$(this);
                            var t=E.touches[0];
                            var mx=parseInt(me.data("mx")),my=parseInt(me.data("my"));
                            var ex=parseInt(me.data("ex")),ey=parseInt(me.data("ey"));
                            console.log("or mx,my, new mx,my or ex,ey=",mx,my,t.pageX,t.pageY,ex,ey)
                            var nx=ex+t.pageX - mx , ny=ey+t.pageY-my
                            console.log("dest x,y=",nx,",",ny)
                            $("#tip").text("in touch move : "+"or mx,my, new mx,my or ex,ey="+mx+","+my+","+t.pageX+","+t.pageY+","+ex+","+ey+" dest x,y="+nx+","+ny);
                            me.css({"left":nx+"px","top":ny+"px"}) ;

                        })
                        .on(‘touchend‘,function(E){
                            //E.preventDefault();E.stopPropagation();
                             console.log(‘touchend‘);var el=this;var me=$(this);
                        });
                        
                        $(‘img‘).on(‘longTap‘,function(){$.ui.actionsheet(
                            [{
                                text: ‘back‘,
                                cssClasses: ‘red‘,
                                handler: function () {
                                    alert("Clicked Back")
                                }
                            }, {
                                text: ‘Alert Hi‘,
                                cssClasses: ‘blue‘,
                                handler: function () {
                                    alert("Hi");
                                }
                            }, {
                                text: ‘Alert Goodbye‘,
                                cssClasses: ‘‘,
                                handler: function () {
                                    alert("Goodbye");
                                }
                            }]
                        );
                        });

 

HTML5 touche vents drag to move & AF actionsheet by longTap

标签:

原文地址:http://www.cnblogs.com/dajianshi/p/4293622.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!