Changeset 2908
- Timestamp:
- 03/28/07 11:59:49 (2 years ago)
- Files:
-
- trunk/openlayers/lib/OpenLayers/Handler/Drag.js (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/openlayers/lib/OpenLayers/Handler/Drag.js
r2803 r2908 17 17 * 'dragging' until the mouse moves after starting. 18 18 * 19 * @type boolean19 * @type Boolean 20 20 **/ 21 21 started: false, 22 22 23 /** @type boolean **/24 dragging: null,23 /** @type Boolean **/ 24 dragging: false, 25 25 26 26 /** @type OpenLayers.Pixel **/ 27 27 start: null, 28 29 /** 30 * @type Function 31 * @private 32 */ 33 oldOnselectstart: null, 28 34 29 35 /** … … 41 47 }, 42 48 49 /** 50 * Handle mousedown events 51 * @param {Event} evt 52 * @type Boolean 53 * @return Should the event propagate 54 */ 43 55 mousedown: function (evt) { 44 56 if (this.checkModifiers(evt) && OpenLayers.Event.isLeftClick(evt)) { 45 57 this.started = true; 46 this.dragging = null;58 this.dragging = false; 47 59 this.start = evt.xy.clone(); 48 60 // TBD replace with CSS classes … … 52 64 return false; 53 65 } 66 return true; 54 67 }, 55 68 69 /** 70 * Handle mousemove events 71 * @param {Event} evt 72 * @type Boolean 73 * @return Should the event propagate 74 */ 56 75 mousemove: function (evt) { 57 76 if (this.started) { 58 77 this.dragging = true; 59 78 this.callback("move", [evt.xy]); 79 if(document.onselectstart) { 80 if(!this.oldOnselectstart) { 81 this.oldOnselectstart = document.onselectstart; 82 document.onselectstart = function() {return false;} 83 } 84 } 60 85 } 86 return true; 61 87 }, 62 88 89 /** 90 * Handle mouseup events 91 * @param {Event} evt 92 * @type Boolean 93 * @return Should the event propagate 94 */ 63 95 mouseup: function (evt) { 64 96 if (this.started) { 65 this.started = false; 97 this.started = false; 98 this.dragging = false; 66 99 // TBD replace with CSS classes 67 100 this.map.div.style.cursor = "default"; 68 101 this.callback("up", [evt.xy]); 102 if(document.onselectstart) { 103 document.onselectstart = this.oldOnselectstart; 104 } 69 105 } 106 return true; 70 107 }, 71 108 109 /** 110 * Handle mouseout events 111 * @param {Event} evt 112 * @type Boolean 113 * @return Should the event propagate 114 */ 72 115 mouseout: function (evt) { 73 116 if (this.started && OpenLayers.Util.mouseLeft(evt, this.map.div)) { 74 117 this.started = false; 75 this.dragging = null;118 this.dragging = false; 76 119 // TBD replace with CSS classes 77 120 this.map.div.style.cursor = "default"; 78 121 this.callback("out", []); 122 if(document.onselectstart) { 123 document.onselectstart = this.oldOnselectstart; 124 } 125 } 126 return true; 127 }, 128 129 /** 130 * The drag handler captures the click event. If something else registers 131 * for clicks on the same element, its listener will not be called after a 132 * drag. 133 * @param {Event} evt 134 * @type Boolean 135 * @return Should the event propagate 136 */ 137 click: function (evt) { 138 // throw away the first left click event that happens after a mouse up 139 if (OpenLayers.Event.isLeftClick(evt) && this.dragging) { 140 this.dragging = true; 141 return false; 142 } 143 this.started = false; 144 return true; 145 }, 146 147 /** 148 * Activate the handler. 149 * @type Boolean 150 * @return Was activation successful. Returns false if already active. 151 */ 152 activate: function() { 153 if(OpenLayers.Handler.prototype.activate.apply(this, arguments)) { 154 this.dragging = false; 155 return true; 156 } else { 157 return false; 79 158 } 80 159 }, 81 160 82 161 /** 83 * @param {Event} evt 84 * 162 * Deactivate the handler. 85 163 * @type Boolean 164 * @return Was deactivation successful. Returns false if not already active. 86 165 */ 87 click: function (evt) { 88 // throw away the first left click event that happens after a mouse up 89 if (OpenLayers.Event.isLeftClick(evt) && this.dragging != null) { 90 this.dragging = null; 91 return false; 166 deactivate: function() { 167 if(OpenLayers.Handler.prototype.deactivate.apply(this, arguments)) { 168 this.dragging = false; 169 return true; 170 } else { 171 return false; 92 172 } 93 this.started = false;94 },95 96 activate: function (evt) {97 OpenLayers.Handler.prototype.activate.apply(this, arguments);98 document.onselectstart = function() { return false; };99 this.dragging = null;100 },101 102 deactivate: function (evt) {103 OpenLayers.Handler.prototype.deactivate.apply(this, arguments);104 document.onselectstart = null;105 this.dragging = null;106 173 }, 107 174
