How to end the slide event APP compatible PC side?

Scene: In the development of APP end, a common touch event in the PC how to convert it?

Measures: code is as follows:

        var pcFlag=true;
        //pc端的touch事件转换成mouse事件
        var touchEvents = {
            touchstart:"touchstart",
            touchmove:"touchmove",
            touchend:"touchend",
            initTouchEvents:function () {
                var self = this;
                if (self.isPC()) {
                    self.touchstart = "mousedown";
                    self.touchmove = "mousemove";
                    self.touchEnd= "MouseUp" ; 
                } 
            }, 
            Ispc: function () {   // Analyzing the pc with a mobile terminal 
                var userAgentInfo = the navigator.userAgent;
                 var Agents = new new the Array ( "the Android", "the iPhone", "SymbianOS", "the Windows Phone "," the iPad "," the iPod ");   // Analyzing user-agent header information 
                for ( var V = 0; V <Agents.length; V ++ ) {
                     IF (userAgentInfo.indexOf (agents [V])! = -1) pcFlag = { to false ; BREAK ;} 
                } 
                return pcFlag;   //pc side is true, false non-pc- 
            } 
        }; 
        touchEvents.initTouchEvents ();

When the binding event, the original on ( 'touchstart', function ( ) {}), replaced ON ( ' touchEvents. Touchstart ', function () {}).

 

Guess you like

Origin www.cnblogs.com/juicy-initial/p/11526180.html