Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Diff 4.52 KB | None | 0 0
  1. Index: .../OpenLayers/Handler/Drag.js
  2. ===================================================================
  3. --- .../OpenLayers/Handler/Drag.js  (revision 600)
  4. +++ .../OpenLayers/Handler/Drag.js  (working copy)
  5. @@ -189,6 +189,10 @@
  6.          var propagate = true;
  7.          this.dragging = false;
  8.          if (this.checkModifiers(evt) && OpenLayers.Event.isLeftClick(evt)) {
  9. +            this.downEvt = OpenLayers.Util.extend({}, evt);
  10. +            delete this.downEvt.preventDefault;
  11. +            delete this.downEvt.stopPropagation;
  12. +            
  13.              this.started = true;
  14.              this.start = evt.xy;
  15.              this.last = evt.xy;
  16. @@ -269,6 +273,7 @@
  17.       * {Boolean} Let the event propagate.
  18.       */
  19.      mouseup: function (evt) {
  20. +        var propagate = true;
  21.          if (this.started) {
  22.              if(this.documentDrag === true && this.documentEvents) {
  23.                  this.adjustXY(evt);
  24. @@ -284,12 +289,29 @@
  25.              this.callback("up", [evt.xy]);
  26.              if(dragged) {
  27.                  this.callback("done", [evt.xy]);
  28. +            } else {
  29. +                this.replayClickSequence();
  30. +                propagate = false;
  31.              }
  32.              document.onselectstart = this.oldOnselectstart;
  33.          }
  34. -        return true;
  35. +        return propagate;
  36.      },
  37.  
  38. +    replayClickSequence: function() {
  39. +        this.map.events.injectEventLower(this.downEvt.type, this.downEvt, this);
  40. +
  41. +        var upEvt = OpenLayers.Util.extend({}, this.downEvt);
  42. +        upEvt.type = 'mouseup';
  43. +        this.map.events.injectEventLower(upEvt.type, upEvt, this);
  44. +
  45. +        var clickEvt = OpenLayers.Util.extend({}, this.downEvt);
  46. +        clickEvt.type = 'click';
  47. +        this.map.events.injectEventLower(clickEvt.type, clickEvt, this);
  48. +
  49. +        this.downEvt = null;
  50. +    },
  51. +
  52.      /**
  53.       * Method: mouseout
  54.       * Handle mouseout events
  55. @@ -301,6 +323,7 @@
  56.       * {Boolean} Let the event propagate.
  57.       */
  58.      mouseout: function (evt) {
  59. +        var propagate = true;
  60.          if (this.started && OpenLayers.Util.mouseLeft(evt, this.map.div)) {
  61.              if(this.documentDrag === true) {
  62.                  this.documentEvents = new OpenLayers.Events(this, document,
  63. @@ -323,13 +346,16 @@
  64.                  this.callback("out", []);
  65.                  if(dragged) {
  66.                      this.callback("done", [evt.xy]);
  67. +                } else {
  68. +                    this.replayClickSequence();
  69. +                    propagate = false;
  70.                  }
  71.                  if(document.onselectstart) {
  72.                      document.onselectstart = this.oldOnselectstart;
  73.                  }
  74.              }
  75.          }
  76. -        return true;
  77. +        return propagate;
  78.      },
  79.  
  80.      /**
  81.  
  82. Index: .../OpenLayers/Events.js
  83. ===================================================================
  84. --- .../OpenLayers/Events.js    (revision 600)
  85. +++ .../OpenLayers/Events.js    (working copy)
  86. @@ -737,7 +737,8 @@
  87.       * {Boolean} The last listener return.  If a listener returns false, the
  88.       *     chain of listeners will stop getting called.
  89.       */
  90. -    triggerEvent: function (type, evt) {
  91. +    triggerEvent: function (type, evt, fromHandler) {
  92. +        fromHandler = fromHandler || null;
  93.          var listeners = this.listeners[type];
  94.  
  95.          // fast path
  96. @@ -754,13 +755,20 @@
  97.          if(!evt.type) {
  98.              evt.type = type;
  99.          }
  100. -    
  101. +
  102. +        var shouldFire = null == fromHandler;
  103.          // execute all callbacks registered for specified type
  104.          // get a clone of the listeners array to
  105.          // allow for splicing during callbacks
  106.          var listeners = listeners.slice(), continueChain;
  107.          for (var i=0, len=listeners.length; i<len; i++) {
  108.              var callback = listeners[i];
  109. +            if (!shouldFire || (null != fromHandler && fromHandler == callback.obj)) {
  110. +                if (fromHandler == callback.obj)
  111. +                    shouldFire = true;
  112. +                continue;
  113. +            }
  114. +
  115.              // bind the context to callback.obj
  116.              continueChain = callback.func.apply(callback.obj, [evt]);
  117.  
  118. @@ -776,6 +784,11 @@
  119.          return continueChain;
  120.      },
  121.  
  122. +    injectEventLower:function(type, evt, fromHandler) {
  123. +        console.log("Events.injectEventLower(" + type + "," + evt + ", " + fromHandler + ")");
  124. +        return this.triggerEvent(type, evt, fromHandler);
  125. +    },
  126. +
  127.      /**
  128.       * Method: handleBrowserEvent
  129.       * Basically just a wrapper to the triggerEvent() function, but takes
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement