浏览代码

no accidental seg mouseover/mouseout with touch

Adam Shaw 9 年之前
父节点
当前提交
a8efedfb84
共有 2 个文件被更改,包括 28 次插入1 次删除
  1. 23 1
      src/common/Grid.events.js
  2. 5 0
      src/common/Grid.js

+ 23 - 1
src/common/Grid.events.js

@@ -207,7 +207,10 @@ Grid.mixin({
 
 	// Updates internal state and triggers handlers for when an event element is moused over
 	handleSegMouseover: function(seg, ev) {
-		if (!this.mousedOverSeg) {
+		if (
+			!this.isIgnoringMouse &&
+			!this.mousedOverSeg
+		) {
 			this.mousedOverSeg = seg;
 			seg.el.addClass('fc-allow-mouse-resize');
 			this.view.trigger('eventMouseover', seg.el[0], seg.event, ev);
@@ -241,6 +244,19 @@ Grid.mixin({
 	},
 
 
+	// temporarily ignore mouse actions on segments
+	tempIgnoreMouse: function() {
+		this.isIgnoringMouse = true;
+		this.delayUnignoreMouse();
+	},
+
+
+	// delayUnignoreMouse eventually calls this
+	unignoreMouse: function() {
+		this.isIgnoringMouse = false;
+	},
+
+
 	handleSegTouchStart: function(seg, ev) {
 		var view = this.view;
 		var event = seg.event;
@@ -265,10 +281,16 @@ Grid.mixin({
 				delay: isSelected ? 0 : this.view.opt('longPressDelay') // do delay if not already selected
 			});
 		}
+
+		// a long tap simulates a mouseover. ignore this bogus mouseover.
+		this.tempIgnoreMouse();
 	},
 
 
 	handleSegTouchEnd: function(seg, ev) {
+		// touchstart+touchend = click, which simulates a mouseover.
+		// ignore this bogus mouseover.
+		this.tempIgnoreMouse();
 	},
 
 

+ 5 - 0
src/common/Grid.js

@@ -30,6 +30,10 @@ var Grid = FC.Grid = Class.extend(ListenerMixin, {
 	segResizeListener: null,
 	externalDragListener: null,
 
+	isIgnoringMouse: false, // bool
+	delayUnignoreMouse: null, // method
+
+
 
 	constructor: function(view) {
 		this.view = view;
@@ -37,6 +41,7 @@ var Grid = FC.Grid = Class.extend(ListenerMixin, {
 		this.elsByFill = {};
 
 		this.dayDragListener = this.buildDayDragListener();
+		this.delayUnignoreMouse = debounce(proxy(this, 'unignoreMouse'), 1000);
 	},