瀏覽代碼

more draglistener fixes

Adam Shaw 10 年之前
父節點
當前提交
83eb279cb1
共有 4 個文件被更改,包括 25 次插入9 次删除
  1. 2 0
      src/common/DragListener.autoscroll.js
  2. 13 6
      src/common/DragListener.js
  3. 7 2
      src/common/MouseFollower.js
  4. 3 1
      src/common/View.js

+ 2 - 0
src/common/DragListener.autoscroll.js

@@ -33,6 +33,8 @@ DragListener.mixin({
 
 
 	destroyAutoScroll: function() {
+		this.endAutoScroll(); // kill any animation loop
+
 		// remove the scroll handler if there is a scrollEl
 		if (this.isAutoScroll) {
 			this.stopListeningTo(this.scrollEl, 'scroll'); // will probably get removed by unbindHandlers too :(

+ 13 - 6
src/common/DragListener.js

@@ -124,10 +124,10 @@ var DragListener = FC.DragListener = Class.extend(ListenerMixin, {
 
 		this.listenTo($(document), {
 			touchmove: this.handleTouchMove,
-			touchend: this.endInteraction,
-			touchcancel: this.endInteraction,
+			touchend: this.endInteraction, // always guaranteed to end the interaction
+			touchcancel: this.endInteraction, // "
 			mousemove: this.handleMouseMove,
-			mouseup: this.endInteraction
+			mouseup: this.handleMouseUp,
 			selectstart: preventDefault, // don't allow selection while dragging
 			contextmenu: preventDefault // long taps would open menu on Chrome dev tools
 		});
@@ -216,8 +216,8 @@ var DragListener = FC.DragListener = Class.extend(ListenerMixin, {
 		var _this = this;
 		var delay = this.delay;
 
-		// prevents mousemove+mousedown+click for before "click" on touch devices
-		if (!delay && FC.isTouchEnabled && !getIsEvTouch(initialEv)) {
+		// ignores mousemove+mousedown+mouseup for before "click" on touch devices
+		if (!delay && FC.isTouchEnabled && !getEvIsTouch(initialEv)) {
 			delay = 1;
 		}
 
@@ -254,7 +254,7 @@ var DragListener = FC.DragListener = Class.extend(ListenerMixin, {
 	},
 
 
-	// Moving via Mouse/Touch
+	// Mouse / Touch
 	// -----------------------------------------------------------------------------------------------------------------
 
 
@@ -277,6 +277,13 @@ var DragListener = FC.DragListener = Class.extend(ListenerMixin, {
 	},
 
 
+	handleMouseUp: function(ev) {
+		if (!this.isTouch) {
+			this.endInteraction(ev);
+		}
+	},
+
+
 	// Scrolling (unrelated to auto-scroll)
 	// -----------------------------------------------------------------------------------------------------------------
 

+ 7 - 2
src/common/MouseFollower.js

@@ -111,8 +111,13 @@ var MouseFollower = Class.extend(ListenerMixin, {
 					height: this.sourceEl.height(), // explicit width in case there was a 'bottom' value
 					opacity: this.options.opacity || '',
 					zIndex: this.options.zIndex
-				})
-				.appendTo(this.parentEl);
+				});
+
+			// we don't want long taps or any mouse interaction causing selection/menus.
+			// would use preventSelection(), but that prevents selectstart, causing problems.
+			el.addClass('fc-unselectable');
+
+			el.appendTo(this.parentEl);
 		}
 
 		return el;

+ 3 - 1
src/common/View.js

@@ -948,7 +948,9 @@ var View = FC.View = Class.extend(EmitterMixin, ListenerMixin, {
 
 
 	handleDocumentMousedown: function(ev) {
-		if (isPrimaryMouseButton(ev)) {
+		// touch devices fire simulated mouse events on a "click".
+		// only process mousedown if we know this isn't a touch device.
+		if (!FC.isTouchEnabled && isPrimaryMouseButton(ev)) {
 			this.processRangeUnselect(ev);
 			this.processEventUnselect(ev);
 		}