我尝试使用触发事件。如果我用手独立触发事件,我就没有问题,并且事件参数包含我需要的所有字段。如果我使用 jQuerytrigger()
一切正常,但事件参数几乎一无所获。
<div id="dragDiv">
<button id='dragButton' >tap</button>
</div>
$("#dragButton")
.hammer({
// options...
})
.bind("drag", doCall);
function doCall(ev){
console.log(ev);
}
$('#dragButton').trigger("drag");
结果
v.Event {type: "drag", timeStamp: 1357286124612, jQuery18306904058358632028: true, isTrigger: true, exclusive: undefined…}
currentTarget: <button>
data: null
delegateTarget: <button>
exclusive: undefined
handleObj: Object
isTrigger: true
jQuery18306904058358632028: true
namespace: ""
namespace_re: null
result: undefined
target: <button>
timeStamp: 1357286124612
type: "drag"
__proto__: Object
但是我需要:
v.Event {type: "drag", originalEvent: MouseEvent, position: Object, direction: "right", distance: 22.825424421026653…}
angle: -28.810793742973058
currentTarget: <button>
data: null
delegateTarget: <button>
direction: "right"
distance: 22.825424421026653
distanceX: 20
distanceY: -11
exclusive: undefined
handleObj: Object
isTrigger: true
jQuery18306904058358632028: true
namespace: ""
namespace_re: null
originalEvent: MouseEvent
position: Object
result: undefined
target: <button>
timeStamp: 1357286139160
touches: Array[1]
type: "drag"
__proto__: Object