क्या सफारी मोबाइल पर mootools class "drag" को काम करने का कोई तरीका है? कृपया मुझे अन्य ढांचे से लिंक न करें।मोबाइल पर mootools के साथ खींचें
उत्तर
क्या आप https://github.com/kamicane/mootools-touch आज़मा सकते हैं?
मैंने इसे स्वयं ठीक कर दिया है। घटनाओं को छूने के लिए माउस इवेंट मैप करना उतना ही आसान है।
mousedown -> touchstart
mouseup -> touchend
mousemove -> touchmove
यहाँ Mootools खींचें समर्थन स्पर्श इवेंट बनाने के लिए अपने समाधान था:
तो समाधान खोज करने के लिए & की जगह है। इस विधि मुझे आवश्यकता नहीं किया था mootools अधिक फ़ाइल को संपादित करने के बाद से मैं Class.refactor इस्तेमाल किया (यह केवल Mootools v.1.3.1 के साथ परीक्षण किया जाता है) - यह भी नष्ट नहीं होती है सामान्य क्लिक ईवेंट
Class.refactor(Drag,
{
attach: function(){
this.handles.addEvent('touchstart', this.bound.start);
return this.previous.apply(this, arguments);
},
detach: function(){
this.handles.removeEvent('touchstart', this.bound.start);
return this.previous.apply(this, arguments);
},
start: function(event){
document.body.addEvents({
touchmove: this.bound.check,
touchend: this.bound.cancel
});
this.previous.apply(this, arguments);
},
check: function(event){
if (this.options.preventDefault) event.preventDefault();
var distance = Math.round(Math.sqrt(Math.pow(event.page.x - this.mouse.start.x, 2) + Math.pow(event.page.y - this.mouse.start.y, 2)));
if (distance > this.options.snap){
this.cancel();
this.document.addEvents({
mousemove: this.bound.drag,
mouseup: this.bound.stop
});
document.body.addEvents({
touchmove: this.bound.drag,
touchend: this.bound.stop
});
this.fireEvent('start', [this.element, event]).fireEvent('snap', this.element);
}
},
cancel: function(event){
document.body.removeEvents({
touchmove: this.bound.check,
touchend: this.bound.cancel
});
return this.previous.apply(this, arguments);
},
stop: function(event){
document.body.removeEvents({
touchmove: this.bound.drag,
touchend: this.bound.stop
});
return this.previous.apply(this, arguments);
}
});
भयानक, +1 - यदि इसका उत्पादन में परीक्षण किया गया है और यह काम करता है, तो क्यों मूल कक्षाओं को संशोधित नहीं करते हैं और इसके बजाय mootools को पुल अनुरोध भेजते हैं? स्पर्श डिवाइस बहुत अधिक व्यापक हैं और यह बॉक्स से बाहर होना उपयोगी है। –
ग्रेट !! क्या आप जानते हैं कि स्पर्श ईवेंट ड्रैग करते समय स्क्रॉलिंग को अक्षम कैसे करें? मेरी विंडो स्क्रॉल करता है जैसे ही यह ड्रैग करता है ... – Sergio
असल में एंड्रॉइड बग के कारण कोई समस्या है, http://uihacker.blogspot.it/2011/01/android-touchmove-event-bug.html और http देखें : //code.google.com/p/android/issues/detail आईडी = 5491। असल में आपको टचमोव कॉलबैक में event.preventDefault() को कॉल करने की आवश्यकता है, फिर इवेंट हैंडलर को सही ढंग से निकालने के लिए चीजों को समायोजित करें – abidibo
यह mootools 1.2 के लिए और मैं 1.3 का उपयोग कर रहा हूँ। इसके अलावा मैं देशी ड्रैग क्लास के आधार पर कई घटकों का उपयोग कर रहा हूं, इसलिए मैं उस वर्ग के लिए एक फिक्स पसंद करता हूं। धन्यवाद! – aartiles