Index: trunk/extensions/VisualEditor/modules/es/views/es.SurfaceView.js |
— | — | @@ -27,6 +27,7 @@ |
28 | 28 | this.$cursor = $( '<div class="es-surfaceView-cursor"></div>' ) |
29 | 29 | .appendTo( this.$ ); |
30 | 30 | this.updateSelectionTimeout = undefined; |
| 31 | + this.emitUpdateTimeoue = undefined; |
31 | 32 | |
32 | 33 | // Interaction states |
33 | 34 | |
— | — | @@ -72,9 +73,9 @@ |
73 | 74 | _this.updateSelection( 0 ); |
74 | 75 | } ); |
75 | 76 | this.model.getDocument().on( 'update', function() { |
76 | | - _this.emit( 'update' ); |
| 77 | + _this.emitUpdate( 25 ); |
77 | 78 | // Respond to layout changes |
78 | | - _this.updateSelection( 50 ); |
| 79 | + _this.updateSelection( 25 ); |
79 | 80 | } ); |
80 | 81 | this.$.mousedown( function(e) { |
81 | 82 | return _this.onMouseDown( e ); |
— | — | @@ -153,9 +154,20 @@ |
154 | 155 | _this.documentView.clearSelection( _this.currentSelection ); |
155 | 156 | } |
156 | 157 | _this.updateSelectionTimeout = undefined; |
157 | | - }, delay ); |
| 158 | + }, delay || 0 ); |
158 | 159 | }; |
159 | 160 | |
| 161 | +es.SurfaceView.prototype.emitUpdate = function( delay ) { |
| 162 | + if ( this.emitUpdateTimeout !== undefined ) { |
| 163 | + return; |
| 164 | + } |
| 165 | + var _this = this; |
| 166 | + this.emitUpdateTimeout = setTimeout( function() { |
| 167 | + _this.emit( 'update' ); |
| 168 | + _this.emitUpdateTimeout = undefined; |
| 169 | + }, delay || 0 ); |
| 170 | +}; |
| 171 | + |
160 | 172 | es.SurfaceView.prototype.onMouseDown = function( e ) { |
161 | 173 | // Only for left mouse button |
162 | 174 | if ( e.button === 0 ) { |