Selaa lähdekoodia

fix bug where touch dayClick with delay wouldnt fire

Adam Shaw 9 vuotta sitten
vanhempi
sitoutus
bcd368f6b8
2 muutettua tiedostoa jossa 12 lisäystä ja 3 poistoa
  1. 9 1
      src/common/Grid.js
  2. 3 2
      src/common/HitDragListener.js

+ 9 - 1
src/common/Grid.js

@@ -282,12 +282,20 @@ var Grid = FC.Grid = Class.extend(ListenerMixin, {
 		// if 'selectable' is enabled, this listener also detects selections.
 		var dragListener = this.dayDragListener = new HitDragListener(this, {
 			scroll: view.opt('dragScroll'),
+			interactionStart: function() {
+				dayClickHit = dragListener.origHit;
+			},
 			dragStart: function() {
 				view.unselect(); // since we could be rendering a new selection, we want to clear any old one
 			},
 			hitOver: function(hit, isOrig, origHit) {
 				if (origHit) { // click needs to have started on a hit
-					dayClickHit = isOrig ? hit : null; // single-hit selection is a day click
+
+					// if user dragged to another cell at any point, it can no longer be a dayClick
+					if (!isOrig) {
+						dayClickHit = null;
+					}
+
 					if (isSelectable) {
 						selectionSpan = _this.computeSelection(
 							_this.getHitSpan(origHit),

+ 3 - 2
src/common/HitDragListener.js

@@ -31,8 +31,6 @@ var HitDragListener = DragListener.extend({
 		var origPoint;
 		var point;
 
-		DragListener.prototype.handleInteractionStart.apply(this, arguments); // call the super-method
-
 		this.computeCoords();
 
 		if (ev) {
@@ -66,6 +64,9 @@ var HitDragListener = DragListener.extend({
 			this.origHit = null;
 			this.coordAdjust = null;
 		}
+
+		// call the super-method. do it after origHit has been computed
+		DragListener.prototype.handleInteractionStart.apply(this, arguments);
 	},