mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 01:22:36 +08:00
UX: remove swipe support from slideout
This commit is contained in:
parent
16d532e9c8
commit
540fe953e0
|
@ -35,11 +35,6 @@ export default Ember.Component.extend({
|
|||
this.set('visible', false);
|
||||
}
|
||||
});
|
||||
|
||||
if (this.capabilities.touch) {
|
||||
$('body').on('swipeleft.discourse-hamburger', () => this.set('visible', true));
|
||||
$('body').on('swiperight.discourse-hamburger', () => this.set('visible', false));
|
||||
}
|
||||
},
|
||||
|
||||
@on('willDestroyElement')
|
||||
|
|
|
@ -1,74 +0,0 @@
|
|||
/**
|
||||
* jquery.detectSwipe v2.1.1
|
||||
* jQuery Plugin to obtain touch gestures from iPhone, iPod Touch, iPad and Android
|
||||
* http://github.com/marcandre/detect_swipe
|
||||
* Based on touchwipe by Andreas Waltl, netCU Internetagentur (http://www.netcu.de)
|
||||
*/
|
||||
|
||||
/* modified by sam to disable the preventDefault stuff */
|
||||
(function($) {
|
||||
|
||||
$.detectSwipe = {
|
||||
version: '2.1.1',
|
||||
enabled: 'ontouchstart' in document.documentElement,
|
||||
preventDefault: false,
|
||||
threshold: 20
|
||||
};
|
||||
|
||||
var startX,
|
||||
startY,
|
||||
isMoving = false;
|
||||
|
||||
function onTouchEnd() {
|
||||
this.removeEventListener('touchmove', onTouchMove);
|
||||
this.removeEventListener('touchend', onTouchEnd);
|
||||
isMoving = false;
|
||||
}
|
||||
|
||||
function onTouchMove(e) {
|
||||
if ($.detectSwipe.preventDefault) { e.preventDefault(); }
|
||||
if(isMoving) {
|
||||
var x = e.touches[0].pageX;
|
||||
var y = e.touches[0].pageY;
|
||||
var dx = startX - x;
|
||||
var dy = startY - y;
|
||||
var dir;
|
||||
if(Math.abs(dx) >= $.detectSwipe.threshold) {
|
||||
dir = dx > 0 ? 'left' : 'right'
|
||||
}
|
||||
else if(Math.abs(dy) >= $.detectSwipe.threshold) {
|
||||
dir = dy > 0 ? 'down' : 'up'
|
||||
}
|
||||
if(dir) {
|
||||
onTouchEnd.call(this);
|
||||
$(this).trigger('swipe', dir).trigger('swipe' + dir);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onTouchStart(e) {
|
||||
if (e.touches.length === 1) {
|
||||
startX = e.touches[0].pageX;
|
||||
startY = e.touches[0].pageY;
|
||||
isMoving = true;
|
||||
this.addEventListener('touchmove', onTouchMove, false);
|
||||
this.addEventListener('touchend', onTouchEnd, false);
|
||||
}
|
||||
}
|
||||
|
||||
function setup() {
|
||||
this.addEventListener && this.addEventListener('touchstart', onTouchStart, false);
|
||||
}
|
||||
|
||||
function teardown() {
|
||||
this.removeEventListener('touchstart', onTouchStart);
|
||||
}
|
||||
|
||||
$.event.special.swipe = { setup: setup, teardown: teardown };
|
||||
|
||||
$.each(['left', 'up', 'down', 'right'], function () {
|
||||
$.event.special['swipe' + this] = { setup: function() {
|
||||
$(this).on('swipe', $.noop);
|
||||
} };
|
||||
});
|
||||
})(jQuery);
|
Loading…
Reference in New Issue
Block a user