anima-yocto-touch
Advanced tools
Comparing version 1.0.3 to 1.0.4
@@ -19,1 +19,6 @@ # History | ||
+ fix bug && optimize | ||
## 1.0.3 && 1.0.4 | ||
+ 不再全局代理click事件,改为只有监听了tap或click事件的元素才会触发该逻辑 | ||
+ fix bug && optimize |
{ | ||
"name": "anima-yocto-touch", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "the touch from yocto", | ||
@@ -24,3 +24,3 @@ "keywords": [], | ||
"dependencies": { | ||
"anima-yocto-lite": "1.1.0" | ||
"anima-yocto-lite": "1.1.1" | ||
}, | ||
@@ -27,0 +27,0 @@ "devDependencies": { |
@@ -13,5 +13,5 @@ var $ = Yocto = require('anima-yocto-lite'); | ||
$el.data(name, 1); | ||
element.forEach(function(el){ | ||
$el | ||
.data(name, 1) | ||
.forEach(function(el){ | ||
el.addEventListener("touchstart", function(event){ | ||
@@ -18,0 +18,0 @@ gesture.handler.touchstart(event); |
@@ -24,8 +24,2 @@ var $ = require('anima-yocto-lite'); | ||
// if(yoctoTouch.isDouleTap){ | ||
// $(targetElement).trigger('doubleTap'); | ||
// yoctoTouch.isDouleTap = false; | ||
// delete yoctoTouch.last; | ||
// } | ||
var clickEvent, touch; | ||
@@ -67,2 +61,3 @@ | ||
case 'label': | ||
case 'iframe': | ||
case 'video': | ||
@@ -315,39 +310,13 @@ return true; | ||
if(deviceIsAndroid){ //解决安卓preventDefault失效的问题 | ||
var oldInitEvent = Event.prototype.initEvent | ||
// 重写initEvent事件,确保模拟出来的click事件带有animaClick标识 | ||
var oldInitEvent = Event.prototype.initEvent; | ||
Event.prototype.initEvent = function(){ | ||
oldInitEvent.apply(this, Array.prototype.slice.call(arguments)) | ||
this.animaClick = true | ||
} | ||
Event.prototype.initEvent = function(){ | ||
var args = Array.prototype.slice.call(arguments); | ||
// document.addEventListener('click', function(event) { | ||
// if (!event.animaClick) {//阻止浏览器自己触发的点击事件 | ||
// if (event.stopImmediatePropagation) { | ||
// event.stopImmediatePropagation(); | ||
// } else { | ||
// event.propagationStopped = true; | ||
// } | ||
oldInitEvent.apply(this, args) | ||
// event.stopPropagation() | ||
// event.preventDefault() | ||
// return false | ||
// } | ||
// }, true) | ||
$(document).on('click', function(event){ | ||
if (!event.animaClick) {//阻止浏览器自己触发的点击事件 | ||
if (event.stopImmediatePropagation) { | ||
event.stopImmediatePropagation(); | ||
} else { | ||
event.propagationStopped = true; | ||
} | ||
event.stopPropagation() | ||
event.preventDefault() | ||
return false | ||
if(args[0] === 'click'){ | ||
this.animaClick = true | ||
} | ||
}) | ||
} | ||
@@ -354,0 +323,0 @@ |
@@ -32,3 +32,4 @@ var expect = require('spm-expect.js'); | ||
'<div id="JS_prevenDefault" class="normaltap red" style="margin-top:20px;">normal tap</div>' + | ||
'</div>' | ||
'</div>'+ | ||
'<div id="JS_log" class="normaltap red" style="position: fixed; top: 10px; left: 10px; background-color: gray;">log区域<p></p></div>' | ||
).prependTo('body'); | ||
@@ -41,3 +42,3 @@ | ||
'<br/>' + | ||
'<select name="">' + | ||
'<select id="J_select" name="">' + | ||
'<option value="1">等额本息6月</option>' + | ||
@@ -181,5 +182,7 @@ '<option value="2">等额本金12个月</option>' + | ||
var l = 0; | ||
$('#JS_checkbox').click(function(){ | ||
$('#JS_checkbox').on('click', function(){ | ||
l ++; | ||
$('#JS_Log').text(l); | ||
}).on('click', function(){ | ||
$('#JS_log p').append('click') | ||
}); | ||
@@ -200,7 +203,9 @@ | ||
// var ev = document.createEvent('HTMLEvents'); | ||
// ev.initEvent('click', false, true) | ||
// $('#J_initEvent').get(0).dispatchEvent(ev) | ||
var ev = document.createEvent('HTMLEvents'); | ||
ev.initEvent('click', false, true); | ||
$('#JS_checkbox').get(0).dispatchEvent(ev) | ||
}); | ||
}); | ||
22887
494
+ Addedanima-yocto-event@1.0.2(transitive)
+ Addedanima-yocto-lite@1.1.1(transitive)
- Removedanima-yocto-event@1.0.1(transitive)
- Removedanima-yocto-lite@1.1.0(transitive)
Updatedanima-yocto-lite@1.1.1