Ticket #3583: drop_notification_and_new_hovering.diff
| File drop_notification_and_new_hovering.diff, 3.1 kB (added by rob.mayhew@gmail.com, 2 years ago) |
|---|
-
src/dragdrop.js
old new 67 67 }, 68 68 69 69 show: function(point, element) { 70 if(!this.drops.length) return ;71 70 if(!this.drops.length) return 0; 71 var affectedDrop = null; 72 72 if(this.last_active) this.deactivate(this.last_active); 73 73 this.drops.each( function(drop) { 74 if(Droppables.isAffected(point, element, drop)) { 74 if(Droppables.isAffected(point, element, drop)) { 75 affectedDrop = drop; 75 76 if(drop.onHover) 76 77 drop.onHover(element, drop.element, Position.overlap(drop.overlap, drop.element)); 77 78 if(drop.greedy) { … … 79 80 throw $break; 80 81 } 81 82 } 82 }); 83 } 84 ); 85 if(affectedDrop) 86 return affectedDrop.element; 87 return null; 83 88 }, 84 89 85 90 fire: function(event, element) { … … 172 177 }, 173 178 174 179 _cacheObserverCallbacks: function() { 175 ['onStart','onEnd','onDrag' ].each( function(eventName) {180 ['onStart','onEnd','onDrag','onNothing'].each( function(eventName) { 176 181 Draggables[eventName+'Count'] = Draggables.observers.select( 177 182 function(o) { return o[eventName]; } 178 183 ).length; … … 185 190 var Draggable = Class.create(); 186 191 Draggable.prototype = { 187 192 initialize: function(element) { 188 var options = Object.extend({ 193 var options = Object.extend({ 194 hoveringEle: null, 189 195 handle: false, 190 196 starteffect: function(element) { 191 197 new Effect.Opacity(element, {duration:0.2, from:1.0, to:0.7}); … … 288 294 updateDrag: function(event, pointer) { 289 295 if(!this.dragging) this.startDrag(event); 290 296 Position.prepare(); 291 Droppables.show(pointer, this.element); 297 var result = Droppables.show(pointer, this.element); 298 if(this.hoveringEle && !result){ 299 if(this.options.onHoverEnd) 300 this.options.onHoverEnd(this.element); 301 } 302 if(result && (!this.hoveringEle || this.hoveringEle.id != result.id)){ 303 if(this.options.onHoverStart) 304 this.options.onHoverStart(this.element, result); 305 } 306 this.hoveringEle=(result!=null)?result:null; 292 307 Draggables.notify('onDrag', this, event); 293 308 this.draw(pointer); 294 309 if(this.options.change) this.options.change(this); … … 326 341 327 342 if(success) Droppables.fire(event, this.element); 328 343 Draggables.notify('onEnd', this, event); 329 344 if(this.options.onDrop)this.options.onDrop(this.element, this.hoveringEle); 330 345 var revert = this.options.revert; 331 346 if(revert && typeof revert == 'function') revert = revert(this.element); 332 347 … … 423 438 424 439 if(this.options.change) this.options.change(this); 425 440 } 426 } 441 } 442 427 443 444 428 445 /*--------------------------------------------------------------------------*/ 429 446 430 447 var SortableObserver = Class.create(); … … 550 567 this.sortables.push(options); 551 568 552 569 // for onupdate 553 Draggables.addObserver(new SortableObserver(element, options.onUpdate)); 570 Draggables.addObserver(new SortableObserver(element, options.onUpdate)); 571 554 572 555 573 }, 556 574