如何將觸摸事件設置爲可拖動的類,以便它可以在iOS(iPad,iPhone等)上使用?我已閱讀How can I make a jQuery UI 'draggable()' div draggable for touchscreen?,它有許多jQuery選項,但不知道如何將其應用於Scriptaculous。任何幫助,將不勝感激。謝謝。iOS上可以拖動的文字
在拖拽元素:
register: function(draggable) {
if(this.drags.length == 0) {
this.eventMouseUp = this.endDrag.bindAsEventListener(this);
this.eventMouseMove = this.updateDrag.bindAsEventListener(this);
this.eventKeypress = this.keyPress.bindAsEventListener(this);
Event.observe(document, "mouseup", this.eventMouseUp);
Event.observe(document, "mousemove", this.eventMouseMove);
Event.observe(document, "keypress", this.eventKeypress);
Event.observe(document, "touchstart", this.eventKeypress);
Event.observe(document, "touchmove", this.eventMouseMove);
Event.observe(document, "touchend", this.eventMouseUp);
}
this.drags.push(draggable);
},
unregister: function(draggable) {
this.drags = this.drags.reject(function(d) { return d==draggable });
if(this.drags.length == 0) {
Event.stopObserving(document, "touchstart", this.eventKeypress);
Event.stopObserving(document, "touchmove", this.eventMouseMove);
Event.stopObserving(document, "touchend", this.eventMouseUp);
Event.stopObserving(document, "mouseup", this.eventMouseUp);
Event.stopObserving(document, "mousemove", this.eventMouseMove);
Event.stopObserving(document, "keypress", this.eventKeypress);
}
},
在可拖動:
initialize:
...
this.eventMouseDown = this.initDrag.bindAsEventListener(this);
Event.observe(this.handle, "mousedown", this.eventMouseDown);
Event.observe(this.handle, "touchstart", this.eventMouseDown);
Draggables.register(this);
},
destroy: function() {
Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
Event.stopObserving(this.handle, "touchstart", this.eventMouseDown);
Draggables.unregister(this);
},
...
initDrag: function(event) {
if(!Object.isUndefined(Draggable._dragging[this.element]) &&
Draggable._dragging[this.element]) return;
if(Event.isLeftClick(event) || event.type == "touchstart") {
隨着編輯的prototype.js:
值得投票。對不起,但是如果你願意的話,不得不直接操縱這些方法,但是這不會被認爲是編輯核心功能嗎?如果你能幫助我做出決定,我可能會轉換到另一個應用程序的原型,這是我能找到的人談論它的唯一地方。如果工作好生病,就讓它旋轉一下,看看我有多高可以把它推到中央明星身上。 :-) – blamb