jQuery Mobile Swipe事件导致输入中的文本不可拖动 [英] Jquery Mobile Swipe Events Causes Text In Inputs To Not Be Draggable

查看:75
本文介绍了jQuery Mobile Swipe事件导致输入中的文本不可拖动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不是特别想使用Jquery Mobile,因为我只将其用于swipeleft和swiperight ....但是它是我可以找到的唯一可与类一起使用并用于动态添加内容的触摸事件库.我确实使用下载程序来抓取当时只需要的内容(不记得是什么),但是那是一段时间之前的事,现在下载程序已损坏,因此我最近在这里找到了带有触摸事件的注释.而且它仍然导致此问题. https://stackoverflow.com/a/51800929/11773633

I don't particularly want to use Jquery Mobile, because I only use it for swipeleft and swiperight....but it is the only touch event library I could find that works with classes and on for dynamically added content. I did use the downloader to grab what I only needed at the time (can't remember what), but that was a while ago and the downloader is broken now, so I recently found a comment on here with just the touch events. And it is still causing this issue. https://stackoverflow.com/a/51800929/11773633

我遇到的问题是,如果我至少在任何地方声明一次swipeleft和swiperight,无论它是否影响页面上的内容...它都会导致输入和textareas不仅无法从中拖动选择的文本字段中的任何地方,但也不允许在文本本身上拖动...它仅选择3个字符.

The problem I am having is that if I declare swipeleft and swiperight anywhere at least once, whether it affects content that is on the page or not...it causes inputs and textareas to not only be unable to drag select text from anywhere inside the field, but also to not allow drag on the text itself... it only selects 3 characters.

这是一个带有示例的jsfiddle.我将html部分中的touch事件链接到了Jquery Mobile v1.4.5的副本.我也使用Jquery 2.2.4,因此已设置.

This is a jsfiddle with an example. I am linking that copy of of Jquery Mobile v1.4.5 with just touch events in the html section. I use Jquery 2.2.4 also, so that is set.

http://jsfiddle.net/fLxb3dcr/

$(document).on('touchstart touchmove touchend tap taphold swipe swipeleft swiperight scrollstart scrollstop','textarea', function(event) {
        return false;
    });

我只想为输入字段的拖动选择文本问题找到一个解决方法...看来我无法阻止此脚本执行的任何操作似乎都改变了输入字段中拖动的工作方式.只要使用滑动,就会导致此问题.

I just want to find a fix for this drag select text issue for input fields... And it seems I can't prevent whatever this script does that seems to change the way drag in input fields works. As long as swipe is used, it causes this issue.

推荐答案

我不确定这可能会如何影响事情……但是经过大量挖掘之后的罪魁祸首……竟然是scrollSupressionThreshold.设置为30,由于某种原因,无论是否将其作为目标,它都会影响所有元素.我不确定这个阈值在宏伟的事物中意味着什么,但是通过将其设置为一个非常高的数字(在本例中为指数符号1e9),它将完全消除输入字段的所有问题.我相信这可能会再次咬我,但是刷卡仍然有效,而这正是我真正想要的.

I am not sure how this might affect things exactly... but the culprit after extensive digging... turns out to be scrollSupressionThreshold. It is set to 30, which for some reason affects all elements whether they are being targeted or not. I am not sure what this threshold is meant to do in the grand scheme of things, but by setting it to a really high number, in this case exponential notation 1e9, it completely removes all issues for input fields. I am sure this might come back to bite me, but swiping still works and that is all I wanted really.

e.event.special.swipe = {
            scrollSupressionThreshold: **(change from 30 to 1e9)**,
            durationThreshold: 1e3,
            horizontalDistanceThreshold: 30,
            verticalDistanceThreshold: 30,

这篇关于jQuery Mobile Swipe事件导致输入中的文本不可拖动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆