diff --git a/docs/index.html b/docs/index.html index d5073aa..cb5ba0e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -356,7 +356,7 @@
使用css选择器获取HTML元素,返回元素对象,并支持以下扩展方法:
+元素选择器,selector
参数支持css选择器和原生DOM元素,用于获取DOM元素并返回元素对象,并支持以下扩展方法:
each | @@ -370,6 +370,12 @@|
tap | +
+ 点击事件, |
+
trigger | diff --git a/package.json b/package.json index c7d7197..26c9105 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "hybridstart", - "version": "1.0.0", + "version": "1.0.1", "description": "A hybrid application development framework", "main": "lib/index.js", "directories": { diff --git a/sdk/common.js b/sdk/common.js index e15ebea..2da39f0 100644 --- a/sdk/common.js +++ b/sdk/common.js @@ -42,14 +42,10 @@ define(function(require, exports, module) { activeHandle.style.top = targetOffset.clientY - eleOffset.top - 200 + 'px'; target.normalize(); var lastNode = target.lastChild; - if(lastNode){ - if(lastNode.nodeName==='#text' && !lastNode.nodeValue.trim()){ - lastNode = lastNode.previousSibling; - } - target.insertBefore(activeHandle, lastNode); - }else{ - target.appendChild(activeHandle); + if(lastNode.nodeName==='#text' && !lastNode.nodeValue.trim()){ + lastNode = lastNode.previousSibling; } + target.insertBefore(activeHandle, lastNode); setTimeout(function(){ target.classList.add('active'); },0); @@ -76,12 +72,15 @@ define(function(require, exports, module) { target = v = null; }, appcfg.set.animateDuration * 2); if (v) { - v = v.split(','); if (target.getAttribute('data-touch')) { target.removeAttribute('data-touch'); - app.openView({ - anim: ['none', 'push', 'movein', 'fade', 'reveal'][v[0]] - }, v[1], v[2]); + var openParam = v.split(','); + try{ + openParam[0] = JSON.parse(openParam[0]); + }catch(e){ + throw e; + } + app.openView.apply(app, openParam); } } }); diff --git a/sdk/core.js b/sdk/core.js index 810da06..ea9b428 100644 --- a/sdk/core.js +++ b/sdk/core.js @@ -1,8 +1,8 @@ /* app JS SDK -Version:2.2.4 -update: slidBackEnabled默认false -date:2017-08-30 +Version:2.3.0 +update: 增加$.tap() +date:2018-01-17 * /*! Sea.js 2.2.1 | seajs.org/LICENSE.md */ @@ -311,6 +311,28 @@ var apputil = (function(document, undefined) { }); return this; }, + tap: function(child, handle) { + [].every.call(this, function(el, idx) { + var target; + $(el).on('touchstart', child, function(e) { + target = $.isFunction(child) ? el : e.target; + target.setAttribute('data-touch', 1); + }).on('touchcancel', child, function(e) { + target = $.isFunction(child) ? el : e.target; + target.removeAttribute('data-touch'); + }).on('touchmove', child, function(e) { + target = $.isFunction(child) ? el : e.target; + target.removeAttribute('data-touch'); + }).on('touchend', child, function(e) { + target = $.isFunction(child) ? el : e.target; + if (target.getAttribute('data-touch')) { + target.removeAttribute('data-touch'); + handle.call(target, e); + } + }); + }); + return this; + }, trigger: function(eventType, data) { [].every.call(this, function(el, idx) { return $.trigger(el, eventType, data); |