首页 > 移动平台 > 详细

移动端长按效果实现

时间:2017-12-06 17:21:33      阅读:223      评论:0      收藏:0      [点我收藏+]

移动端长按效果实现

基本实现原理:监听touchstart事件,使用setTimeout延时,如果松开则清除该定时器

举个例子

    var pressTimer = null;
    $(‘.circle-tip‘).on(‘touchstart‘,function (e) {
        e.preventDefault();
        e.stopPropagation();
        pressTimer = setTimeout(function () {
                        $(‘.package-pop‘).addClass(‘active‘);
                    },600)
    }).on(‘touchend‘,function(e){
        e.preventDefault();
        e.stopPropagation();
        clearTimeout(pressTimer);
        $(‘.package-pop‘).removeClass(‘active‘);
    })

 

移动端长按效果实现

原文:http://www.cnblogs.com/lw5116/p/7993290.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!