Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
tower1229 committed Jan 17, 2018
1 parent 9899d94 commit 29b52d4
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 16 deletions.
8 changes: 7 additions & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -356,7 +356,7 @@ <h5>方法</h5>
<tr>
<td>$(selector, [context])</td>
<td>
<p>使用css选择器获取HTML元素,返回元素对象,并支持以下扩展方法:</p>
<p>元素选择器,<code>selector</code>参数支持css选择器和原生DOM元素,用于获取DOM元素并返回元素对象,并支持以下扩展方法:</p>
<table class="table">
<tr>
<td>each</td>
Expand All @@ -370,6 +370,12 @@ <h5>方法</h5>
<p>事件绑定/委托,<code>$ele.on(eventType, [child], handle)</code></p>
</td>
</tr>
<tr>
<td>tap</td>
<td>
<p>点击事件,<code>$ele.tap([child], handle)</code></p>
</td>
</tr>
<tr>
<td>trigger</td>
<td>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
21 changes: 10 additions & 11 deletions sdk/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
}
}
});
Expand Down
28 changes: 25 additions & 3 deletions sdk/core.js
Original file line number Diff line number Diff line change
@@ -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 */
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 29b52d4

Please sign in to comment.