起步软件技术论坛
搜索
 找回密码
 注册

QQ登录

只需一步,快速开始

查看: 3181|回复: 4

[分享] IOS11 input输入框很难点中问题处理

[复制链接]

18

主题

113

帖子

525

积分

高级会员

Rank: 4

积分
525
QQ
发表于 2018-5-4 21:03:15 | 显示全部楼层 |阅读模式
本帖最后由 442724344 于 2018-5-4 21:39 编辑

最近发现应用在苹果上输入框Input 非常难点中,要点多次或者点的时间要长(大于100ms)才可以点中,关于焦点问题,首先考虑是fastclick.js的问题(当然也不完全是他的错,手机系统升级后,旧的fastclick.js就有可能有没有考虑到的问题);测试发现可能解决办法如下(是否完美还不知道)
最新IOS和fastclick冲突,最新IOS已处理延迟问题,故无需再要fastclick.js,故先修改如下,
找到\model\UI2\system\components\justep\lib\fastclick.js


新增代码=====
var deviceIsIOSVer = 0;
if(deviceIsIOS)
        deviceIsIOSVer = parseFloat(navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?) like mac os/)[1].replace(/_/g,"."));

修改代码======
/**
* @param {EventTarget|Element} targetElement
*/
FastClick.prototype.focus = function(targetElement) {
        'use strict';
        var length;
        // Issue #160: on iOS 7, some input elements (e.g. date datetime) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
        if (deviceIsIOS && deviceIsIOSVer < 11 && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'number' && targetElement.type !== 'time' && targetElement.type !== 'month' && targetElement.type !== 'range') {
                length = targetElement.value.length;
                targetElement.setSelectionRange(length, length);
        } else {
                targetElement.focus();
        }
};

最后,要合并js,必要的,记住。



105

主题

390

帖子

698

积分

高级会员

Rank: 4

积分
698
QQ
发表于 2018-5-25 16:27:17 | 显示全部楼层
有没有人试过,请问效果如何
回复 支持 反对

使用道具 举报

105

主题

390

帖子

698

积分

高级会员

Rank: 4

积分
698
QQ
发表于 2018-5-25 16:32:12 | 显示全部楼层
var deviceIsIOSVer = 0;
if(deviceIsIOS)
        deviceIsIOSVer = parseFloat(navigator.userAgent.toLowerCase().match(/cpu iphone os (.*?) like mac os/)[1].replace(/_/g,"."));

请问这个代码在哪新增
回复 支持 反对

使用道具 举报

10

主题

89

帖子

313

积分

中级会员

Rank: 3Rank: 3

积分
313
QQ
发表于 2018-9-7 00:49:56 | 显示全部楼层
我试过了,没效果.页执行了dist合并操作
回复 支持 反对

使用道具 举报

22

主题

93

帖子

520

积分

高级会员

Rank: 4

积分
520
QQ
发表于 2018-10-17 08:18:11 | 显示全部楼层
是因为点击是焦点依然在 body上,消息没有传下来。
可以增加input 点击事件, alert(document.activeElement) 看看焦点在哪里。
比较笨的办法就是,在input点击事件里面赋予当前input的 focus焦点。
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|X3技术论坛|Justep Inc.    

GMT+8, 2024-5-2 19:54 , Processed in 0.052798 second(s), 23 queries .

Powered by Discuz! X3.4

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表