時隔已久,沒有寫技術博客了。對于過去的2016年,總的來說是迷茫、掙扎、痛苦的。2017年,開端貌似不錯,可能正視了自己的挫折,也稍微擺正了自己的態度吧
進入主題:Android 4.x touchmove事件兼容問題。
在開發 hybridApp 中,Android開發同事說在4.x的lg手機上,有滑不動的情況,看了之后發現是touchmove事件的問題。在4.x中,touchmove滑動只會動一下,所以無法得到準確的滑動距離,而我的代碼中是要獲取到這段move的距離的。
在touchmove中:
if(_t.data.clientType == 'Android'){ var ua = window.navigator.userAgent; if(parseInt(ua.split('Android ')[1].split(';')[0]) < 5){ e.preventDefault(); }}//計算距離代碼var touch = e.touches[0];maintouch_x_end = touch.pageX;maintouch = maintouch_x_end - maintouch_x;maintouch_y_end = touch.pageY;mainy = maintouch_y_end - maintouch_y;// 計算滾動代碼if(_t.data.clientType == 'Android'){ var ua = window.navigator.userAgent; if(parseInt(ua.split('Android ')[1].split(';')[0]) < 5){ _t.dom.main.find('.mainwrap').scrollTop(startTop - mainy*1.2) }}寫的代碼有點蠢,特別是判斷版本那段
新聞熱點
疑難解答