mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 15:23:29 -05:00
Fix multiple firing of updatePathOnEvent
This commit is contained in:
parent
267085e8c1
commit
db09921d7b
3 changed files with 26 additions and 4 deletions
|
@ -2324,6 +2324,7 @@ function Squire ( root, config ) {
|
||||||
this._lastAnchorNode = null;
|
this._lastAnchorNode = null;
|
||||||
this._lastFocusNode = null;
|
this._lastFocusNode = null;
|
||||||
this._path = '';
|
this._path = '';
|
||||||
|
this._willUpdatePath = false;
|
||||||
|
|
||||||
if ( 'onselectionchange' in doc ) {
|
if ( 'onselectionchange' in doc ) {
|
||||||
this.addEventListener( 'selectionchange', this._updatePathOnEvent );
|
this.addEventListener( 'selectionchange', this._updatePathOnEvent );
|
||||||
|
@ -2859,8 +2860,18 @@ proto._updatePath = function ( range, force ) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// selectionchange is fired synchronously in IE when removing current selection
|
||||||
|
// and when setting new selection; keyup/mouseup may have processing we want
|
||||||
|
// to do first. Either way, send to next event loop.
|
||||||
proto._updatePathOnEvent = function () {
|
proto._updatePathOnEvent = function () {
|
||||||
this._updatePath( this.getSelection() );
|
var self = this;
|
||||||
|
if ( !self._willUpdatePath ) {
|
||||||
|
self._willUpdatePath = true;
|
||||||
|
setTimeout( function () {
|
||||||
|
self._willUpdatePath = false;
|
||||||
|
self._updatePath( self.getSelection() );
|
||||||
|
}, 0 );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Focus ---
|
// --- Focus ---
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -56,6 +56,7 @@ function Squire ( root, config ) {
|
||||||
this._lastAnchorNode = null;
|
this._lastAnchorNode = null;
|
||||||
this._lastFocusNode = null;
|
this._lastFocusNode = null;
|
||||||
this._path = '';
|
this._path = '';
|
||||||
|
this._willUpdatePath = false;
|
||||||
|
|
||||||
if ( 'onselectionchange' in doc ) {
|
if ( 'onselectionchange' in doc ) {
|
||||||
this.addEventListener( 'selectionchange', this._updatePathOnEvent );
|
this.addEventListener( 'selectionchange', this._updatePathOnEvent );
|
||||||
|
@ -591,8 +592,18 @@ proto._updatePath = function ( range, force ) {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// selectionchange is fired synchronously in IE when removing current selection
|
||||||
|
// and when setting new selection; keyup/mouseup may have processing we want
|
||||||
|
// to do first. Either way, send to next event loop.
|
||||||
proto._updatePathOnEvent = function () {
|
proto._updatePathOnEvent = function () {
|
||||||
this._updatePath( this.getSelection() );
|
var self = this;
|
||||||
|
if ( !self._willUpdatePath ) {
|
||||||
|
self._willUpdatePath = true;
|
||||||
|
setTimeout( function () {
|
||||||
|
self._willUpdatePath = false;
|
||||||
|
self._updatePath( self.getSelection() );
|
||||||
|
}, 0 );
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
// --- Focus ---
|
// --- Focus ---
|
||||||
|
|
Loading…
Reference in a new issue