रद्द करने के लिए ध्यान नहीं दिया गया प्रयास अटक , मैं टच इवेंट्स के साथ काम करने के लिए नया हूं और इस समस्या को ठीक नहीं कर सकता।टच कदम मैं चारों ओर एक स्पर्श स्लाइडर पर स्पर्श घटनाओं के साथ खिलवाड़ कर रहा हूँ और मैं निम्नलिखित त्रुटि प्राप्त हो रही एक touchmove
Slider.prototype.isSwipe = function(threshold) {
return Math.abs(deltaX) > Math.max(threshold, Math.abs(deltaY));
}
Slider.prototype.touchStart = function(e) {
if (this._isSliding) return false;
touchMoving = true;
deltaX = deltaY = 0;
if (e.originalEvent.touches.length === 1) {
startX = e.originalEvent.touches[0].pageX;
startY = e.originalEvent.touches[0].pageY;
this._$slider.on('touchmove touchcancel', this.touchMove.bind(this)).one('touchend', this.touchEnd.bind(this));
isFlick = true;
window.setTimeout(function() {
isFlick = false;
}, flickTimeout);
}
}
Slider.prototype.touchMove = function(e) {
deltaX = startX - e.originalEvent.touches[0].pageX;
deltaY = startY - e.originalEvent.touches[0].pageY;
if(this.isSwipe(swipeThreshold)) {
e.preventDefault();
e.stopPropagation();
swiping = true;
}
if(swiping) {
this.slide(deltaX/this._sliderWidth, true)
}
}
Slider.prototype.touchEnd = function(e) {
var threshold = isFlick ? swipeThreshold : this._sliderWidth/2;
if (this.isSwipe(threshold)) {
deltaX < 0 ? this.prev() : this.next();
}
else {
this.slide(0, !deltaX);
}
swiping = false;
this._$slider.off('touchmove', this.touchMove).one(transitionend, $.proxy(function() {
this.slide(0, true);
touchMoving = false;
}, this));
}
आप वास्तविक स्लाइडर here at this pen पा सकते हैं:
यहाँ स्पर्श ईवेंट प्रबंधन कोड है।
यदि आप पर्याप्त तेज़ी से स्वाइप करते हैं तो यह त्रुटि फेंक देगा और कभी-कभी स्वाइप के बीच में फंस जाएगा। अभी भी मेरे सिर को लपेट नहीं सकता है कि यह क्यों काम नहीं कर रहा है। किसी भी मदद/अंतर्दृष्टि की सराहना की जाएगी। निश्चित नहीं कि मुझसे कौन सी गलती हो रही है।
यहां कुछ भी नहीं बदलता – Eric
और यह कारण क्या है? –
मैंने इस कथन के अंदर 'e.preventDefault()' को कॉल करने का प्रयास करने से पहले एक if-statement में 'e.cancelable' जोड़ा। – ravo10