Browse Source

hit-related stuff not totally in ChonoComponent

Adam Shaw 8 years ago
parent
commit
a2c22d8c63
2 changed files with 10 additions and 20 deletions
  1. 8 2
      src/common/ChronoComponent.js
  2. 2 18
      src/common/Grid.js

+ 8 - 2
src/common/ChronoComponent.js

@@ -246,23 +246,29 @@ var ChronoComponent = Model.extend({
 	},
 	},
 
 
 
 
+	// Called before one or more queryHit calls might happen. Should prepare any cached coordinates for queryHit
 	prepareHits: function() {
 	prepareHits: function() {
 		this.callChildren('prepareHits');
 		this.callChildren('prepareHits');
 	},
 	},
 
 
 
 
+	// Called when queryHit calls have subsided. Good place to clear any coordinate caches.
 	releaseHits: function() {
 	releaseHits: function() {
 		this.callChildren('releaseHits');
 		this.callChildren('releaseHits');
 	},
 	},
 
 
 
 
-	queryHit: function(left, top) {
+	// Given coordinates from the topleft of the document, return data about the date-related area underneath.
+	// Can return an object with arbitrary properties (although top/right/left/bottom are encouraged).
+	// Must have a `grid` property, a reference to this current grid. TODO: avoid this
+	// The returned object will be processed by getHitFootprint and getHitEl.
+	queryHit: function(leftOffset, topOffset) {
 		var children = this.children;
 		var children = this.children;
 		var i;
 		var i;
 		var hit;
 		var hit;
 
 
 		for (i = 0; i < children.length; i++) {
 		for (i = 0; i < children.length; i++) {
-			hit = children[i].queryHit(left, top);
+			hit = children[i].queryHit(leftOffset, topOffset);
 
 
 			if (hit) {
 			if (hit) {
 				break;
 				break;

+ 2 - 18
src/common/Grid.js

@@ -144,12 +144,14 @@ var Grid = FC.Grid = ChronoComponent.extend({
 
 
 	hitsNeededDepth: 0, // necessary because multiple callers might need the same hits
 	hitsNeededDepth: 0, // necessary because multiple callers might need the same hits
 
 
+
 	hitsNeeded: function() {
 	hitsNeeded: function() {
 		if (!(this.hitsNeededDepth++)) {
 		if (!(this.hitsNeededDepth++)) {
 			this.prepareHits();
 			this.prepareHits();
 		}
 		}
 	},
 	},
 
 
+
 	hitsNotNeeded: function() {
 	hitsNotNeeded: function() {
 		if (this.hitsNeededDepth && !(--this.hitsNeededDepth)) {
 		if (this.hitsNeededDepth && !(--this.hitsNeededDepth)) {
 			this.releaseHits();
 			this.releaseHits();
@@ -157,24 +159,6 @@ var Grid = FC.Grid = ChronoComponent.extend({
 	},
 	},
 
 
 
 
-	// Called before one or more queryHit calls might happen. Should prepare any cached coordinates for queryHit
-	prepareHits: function() {
-	},
-
-
-	// Called when queryHit calls have subsided. Good place to clear any coordinate caches.
-	releaseHits: function() {
-	},
-
-
-	// Given coordinates from the topleft of the document, return data about the date-related area underneath.
-	// Can return an object with arbitrary properties (although top/right/left/bottom are encouraged).
-	// Must have a `grid` property, a reference to this current grid. TODO: avoid this
-	// The returned object will be processed by getHitFootprint and getHitEl.
-	queryHit: function(leftOffset, topOffset) {
-	},
-
-
 	getSafeHitFootprint: function(hit) {
 	getSafeHitFootprint: function(hit) {
 		var footprint = this.getHitFootprint(hit);
 		var footprint = this.getHitFootprint(hit);