zoukankan      html  css  js  c++  java
  • iOS端点击输入框键盘抬起不灵敏

    混合App开发,input触发焦点后,键盘抬起缓慢,百度了一下说是fastclick插件引起的,试了一下加了一行代码,果然生效了。

    • 在node_module里找到fastClick文件,然后找到focus方法
      /**
        * @param {EventTarget|Element} targetElement
        */
       FastClick.prototype.focus = function(targetElement) {
           var length;
      
           // Issue #160: on iOS 7, some input elements (e.g. date datetime month) 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 && targetElement.setSelectionRange && targetElement.type.indexOf('date') !== 0 && targetElement.type !== 'time' && targetElement.type !== 'month' && targetElement.type !== 'email') {
               length = targetElement.value.length;
               targetElement.focus();//加入这一句话就OK了
               targetElement.setSelectionRange(length, length);
           } else {
               targetElement.focus();
           }
       };
      

        

  • 相关阅读:
    [BZOJ] 3191 [JLOI2013]卡牌游戏
    [LUOGU] P1466 集合 Subset Sums
    [LUOGU] P1113 杂物
    [BZOJ] 1003 [ZJOI2006]物流运输
    poj 2479 最大连续子段和
    C#学习第九弹之委托
    C#学习第八弹之线程基础理解
    C#学习第七弹之WPF
    hdu 2030 汉字的编码方式
    hdu 1559 暴力
  • 原文地址:https://www.cnblogs.com/tw6668/p/11098138.html
Copyright © 2011-2022 走看看