评论:jquery拖动滑块验证,兼容各个浏览器  [查看原文]

所属分类:输入-验证,拖和放

 40565  389  40
当前第1页 / 共2页
    7640
    2023/3/30 16:16:47
    āìō0
    2022/5/24 12:46:58
    我想去浪0
    2021/10/18 11:25:38
    体验不是很好,不小心移出了验证框外,就会跳回原点,客户还以为你的功能不行
        我想去浪3
        2021/10/18 17:05:23

        我自己调整了一下,把SliderUnlock.prototype.init这个方法改了如下:

        SliderUnlock.prototype.init = function() {
            var me = this;
            me.updateView();
            var btn = $('#label')[0];
            var btnWidth = btn.offsetWidth;
        
            btn.ondragstart = function() {
                alert("ondragstart");
                return false;
            };
            btn.onselectstart = function() {
                alert("onselectstart");
                return false;
            };
            //pc端
            btn.onmousedown = function(e) {
                var disX = e.clientX - btn.offsetLeft;
                var e = e || window.event;
                me.lableIndex = e.clientX - btn.offsetLeft;
                me.handerIn();
                document.onmousemove = function(event) {
                    me.handerMove(event);
                };
                document.onmouseup = function(event) {
                    if (!me.isOk) {
                        me.handerOut();
                    }
                };
                document.mouseout = function(event) {
                    me.handerOut();
                };
            };
        
            //移动端
            var cont = $("#label");
            cont.on({ //绑定事件
                touchstart: function(event) {
                    var e = event || window.event;
                    me.lableIndex = e.originalEvent.touches[0].pageX - this.offsetLeft;
                    me.handerIn();
                },
                touchmove: function(event) {
                    me.handerMove(event, "mobile");
                },
                touchend: function(event) {
                    me.handerOut();
                }
            });
        };
    回复
    korb0
    2019/8/30 10:08:52
    没法用? 我无法拖动这个按钮呀 回复
    nature0
    2019/5/18 18:20:30
    不错,很好用。 回复
    小小苦瓜0
    2019/4/17 6:00:43
    Awesome洁盈0
    2019/3/29 14:18:23
    默小兮O(∩_∩)O~0
    2019/1/15 9:33:17
    ie浏览器没有呢兼容啊+ 回复
    A-Margin0
    2018/9/4 18:48:33
    请问这个滑块一旦拖快了,就会回到原点,如何去掉这个速度限制呢,具体代码写在了哪里啊。
        阴霾的记忆0
        2018/9/11 9:53:05
        改为绑定 document.onmousemove 就可以了。
        lifuhai0
        2019/8/13 18:53:56
        改为绑定 document.onmousemove是什么意思啊,在哪里改呀
    回复
    吕欣琪0
    2018/8/13 17:30:06
    杨康卫0
    2018/3/5 15:36:55
    怎么初始化
        yangyuanlife1
        2018/7/4 10:47:55
        new SliderUnlock 这个就是初始化的呀
    回复
    川蜀黍0
    2018/1/31 18:58:05

    厉害了,爬走了

    回复
    郑艺欣0
    2017/12/23 11:23:18

    请问兼容移动端吗?而且安全问题有没有做处理?

        吕欣琪0
        2018/8/13 17:30:40
        安全问题需要后台处理
    回复
    '等不到天亮等时光。0
    2017/12/16 16:50:47
    不错,离开焦点处就会松开 回复
    roach10
    2017/12/7 16:19:03

    比另外一个实惠多了

    回复

讨论这个项目(40)回答他人问题或分享插件使用方法奖励jQ币 评论用户自律公约

取消回复