当前位置:网站首页>Simulate long press event of mobile device

Simulate long press event of mobile device

2022-06-21 07:19:00 Glow rabbit

         Pure click event monitoring results in the mobile device , For a long time, it is impossible to collect data according to behavior events , Resulting in incomplete data . Therefore, it is necessary to determine whether the visitor has a long press action to copy the copy in the element , At the same time, obtain the behavior data .
        

// Add a long press event on the mobile terminal touch Judge , Avoid inaccurate event collection data 
		$(".pt_off_event").on({
            touchstart: function(e) {
                var eleTarget = e.srcElement || e.target;
                //  Long press event triggers   
                timeOutEvent = setTimeout(function() {
                    timeOutEvent = 0;
                    ptengine.track(eleTarget.textContent, {}, {
                        transport: 'beacon'
                    });
                }, 500);
                // Long press 500 millisecond    
                // e.preventDefault();    
            },
            touchmove: function() {
                clearTimeout(timeOutEvent);
                timeOutEvent = 0;
            },
            touchend: function() {
                clearTimeout(timeOutEvent);
                if (timeOutEvent != 0) {
                    console.log(' You click on the ');
                }
                return false;
            }
        })

 

原网站

版权声明
本文为[Glow rabbit]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/172/202206210711522820.html