Changeset 5555
- Timestamp:
- 12/21/07 03:48:08 (1 year ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Handler/Feature.js
r5553 r5555 34 34 /** 35 35 * Property: feature 36 * {<OpenLayers.Feature.Vector>} The feature currently being handled. 37 */ 38 feature: null, 39 40 /** 41 * Property: lastFeature 36 42 * {<OpenLayers.Feature.Vector>} The last feature that was handled. 37 43 */ 38 feature: null,44 lastFeature: null, 39 45 40 46 /** … … 134 140 /** 135 141 * Method: mousemove 136 * Handle mouse moves. Call the "over" callback if mov e overa feature,137 * or the "out" callback if mov e outside anyfeature.142 * Handle mouse moves. Call the "over" callback if moving in to a feature, 143 * or the "out" callback if moving out of a feature. 138 144 * 139 145 * Parameters: … … 191 197 var type = evt.type; 192 198 var stopEvtPropag = false; 193 var lastFeature = this.feature; 194 var feature = this.layer.getFeatureFromEvent(evt); 195 if(feature) { 196 if(this.geometryTypeMatches(feature)) { 197 if(lastFeature && (lastFeature != feature)) { 198 // out of last feature 199 this.triggerCallback(type, 'out', [lastFeature]); 199 var previouslyIn = !!(this.feature); // previously in a feature 200 var click = (type == "click" || type == "dblclick"); 201 this.feature = this.layer.getFeatureFromEvent(evt); 202 if(this.feature) { 203 var inNew = (this.feature != this.lastFeature); 204 if(this.geometryTypeMatches(this.feature)) { 205 // in to a feature 206 if(previouslyIn && inNew) { 207 // out of last feature and in to another 208 this.triggerCallback(type, 'out', [this.lastFeature]); 209 this.triggerCallback(type, 'in', [this.feature]); 210 } else if(!previouslyIn || click) { 211 // in feature for the first time 212 this.triggerCallback(type, 'in', [this.feature]); 200 213 } 201 this.triggerCallback(type, 'in', [feature]);202 lastFeature = feature;203 214 stopEvtPropag = true; 204 215 } else { 205 if(lastFeature && (lastFeature != feature)) {206 // out of last feature207 this.triggerCallback(type, 'out', [lastFeature]);208 lastFeature = feature;216 // not in to a feature 217 if(previouslyIn && inNew || (click && this.lastFeature)) { 218 // out of last feature for the first time 219 this.triggerCallback(type, 'out', [this.lastFeature]); 209 220 } 210 221 } 222 this.lastFeature = this.feature; 211 223 } else { 212 if(lastFeature) { 213 this.triggerCallback(type, 'out', [lastFeature]); 214 lastFeature = null; 215 } 216 } 217 if(lastFeature) { 218 this.feature = lastFeature; 224 if(previouslyIn || (click && this.lastFeature)) { 225 this.triggerCallback(type, 'out', [this.lastFeature]); 226 } 219 227 } 220 228 return stopEvtPropag; … … 278 286 } 279 287 this.feature = null; 288 this.lastFeature = null; 280 289 this.down = null; 281 290 this.up = null;
