我有一个混合:
DragEvents = Ember.Mixin.create( {
attributeBindings: 'draggable',
draggable: 'true',
dragStart: function(event) {
controller.onDragStartEvent(this);
},
drag: function(event) {
// this is called for each 'movement' of the object being dragged
// want to collect information about the events and fire a callback
// once every 100 ms
},
dragEnd: function(event) {
// want to fire one last callback with the remaining drag event coordinates
}
});
在拖动功能中,我对鼠标的坐标感兴趣,由下式给出
event.originalEvent.pageX, event.originalEvent.pageY
我想不通的是如何在每次调用拖动时收集该信息,并在拖动期间每 100 毫秒触发一次回调,参数是我收集的坐标数组。当调用 dragEnd 函数时,我想用剩余的拖动事件(那些已收集但未在前一个回调中发送的事件)触发回调。
回调是
controller.onDragEvent(coordinatesArray);