博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Extjs 3 ipad drag drop
阅读量:5750 次
发布时间:2019-06-18

本文共 2544 字,大约阅读时间需要 8 分钟。

window.document.body.addEventListener("touchstart", Application.Main.touchStart, false);

window.document.body.addEventListener("touchmove", Application.Main.touchMove, false);
window.document.body.addEventListener("touchend", Application.Main.touchEnd, false);

 

touchStart: function(event) {

Application.Main.dragDropMouseDown = isDefined(Application.Main.dragDropMouseDown)?Application.Main.dragDropMouseDown:false;

Application.Main.dragDropMouseDown = Application.Main.activeMouseDown(event);

if(Application.Main.dragDropMouseDown){

            if (event.touches.length==1){
                var touch = event.touches[0];
                if (!touch) { event.preventDefault(); return (false); }
                var mousedownE = document.createEvent("MouseEvents");
                mousedownE.initMouseEvent('mousedown',true,true,window,
                    1,
                    touch.screenX,
                    touch.screenY,
                    touch.clientX,
                    touch.clientY,
                    false,false,false,false,
                    0,
                    null
                );
                touch.target.dispatchEvent(mousedownE);
                //event.preventDefault();
                //Application.Main.counting(event);
            }
        }
    } catch (exc) { }
},

touchMove: function(event) {

    try {
        if(Application.Main.dragDropMouseDown){
            if (event.touches.length==1){
                var touch = event.touches[0];
                if (!touch) { event.preventDefault(); return (false); }
                var mousemoveE = document.createEvent("MouseEvents");
                mousemoveE.initMouseEvent('mousemove',true,true,window,
                    1,
                    touch.screenX,
                    touch.screenY,
                    touch.clientX,
                    touch.clientY,
                    false,false,false,false,
                    0,
                    null
                );
                touch.target.dispatchEvent(mousemoveE);
            }
            //Application.Main.counting(event);
            event.preventDefault();
        }
        window.clearInterval(Application.Main.d);
    } catch (exc) { }
},
touchEnd: function(event) {
    try {
        if(Application.Main.dragDropMouseDown && event.touches.length==0){
            var touch = event.changedTouches[0];
            if (!touch) { event.preventDefault(); return (false); }
            var mouseupE = document.createEvent("MouseEvents");
            mouseupE.initMouseEvent('mouseup',true,true,window,
                1,
                touch.screenX,
                touch.screenY,
                touch.clientX,
                touch.clientY,
                false,false,false,false,
                0,
                null
            );
            touch.target.dispatchEvent(mouseupE);
            Application.Main.dragDropMouseDown = false;
        }
        window.clearInterval(Application.Main.d);
    } catch (exc) { }
},

activeMouseDown: function(event) {

    if(Application.Main.dragDropMouseDown){
        return true;
    }else{
        var result = false;
        if(event.touches.length==1){
            var targetTouches = event.targetTouches;
            var target = targetTouches[0].target;
            var className = target.className;
            var patten = new RegExp("(x-panel-header|x-window-header|drag)");
            result = patten.test(className);
        }
        return result;
    }
}

 

 

 

 

 

转载于:https://www.cnblogs.com/yubuaishui/archive/2012/03/27/2419759.html

你可能感兴趣的文章
学习进度表 04
查看>>
谈谈javascript中的prototype与继承
查看>>
时序约束优先级_Vivado工程经验与各种时序约束技巧分享
查看>>
minio 并发数_MinIO 参数解析与限制
查看>>
flash back mysql_mysqlbinlog flashback 使用最佳实践
查看>>
mysql存储引擎模式_MySQL存储引擎
查看>>
java 重写system.out_重写System.out.println(String x)方法
查看>>
配置ORACLE 11g绿色版客户端和PLSQL远程连接环境
查看>>
ASP.NET中 DataList(数据列表)的使用前台绑定
查看>>
Linux学习之CentOS(八)--Linux系统的分区概念
查看>>
System.Func<>与System.Action<>
查看>>
asp.net开源CMS推荐
查看>>
csharp skype send message in winform
查看>>
MMORPG 游戏服务器端设计--转载
查看>>
HDFS dfsclient写文件过程 源码分析
查看>>
ubuntu下安装libxml2
查看>>
nginx_lua_waf安装测试
查看>>
WinForm窗体缩放动画
查看>>
JQuery入门(2)
查看>>
linux文件描述符
查看>>