mirror of
https://github.com/fastmail/Squire.git
synced 2024-12-22 07:13:08 -05:00
Better positioning of paste area to prevent auto-scrolling.
This commit is contained in:
parent
afd3e9807c
commit
da49316876
3 changed files with 24 additions and 6 deletions
|
@ -2646,11 +2646,20 @@ proto._onPaste = function ( event ) {
|
|||
startContainer = range.startContainer,
|
||||
startOffset = range.startOffset,
|
||||
endContainer = range.endContainer,
|
||||
endOffset = range.endOffset;
|
||||
endOffset = range.endOffset,
|
||||
startBlock = startContainer.nodeType === TEXT_NODE ?
|
||||
startContainer : startContainer.childNodes[ startOffset ];
|
||||
|
||||
// We need to position the pasteArea in the visible portion of the screen
|
||||
// to stop the browser auto-scrolling.
|
||||
while ( isInline( startBlock ) ) {
|
||||
startBlock = startBlock.parentNode;
|
||||
}
|
||||
|
||||
var pasteArea = this.createElement( 'DIV', {
|
||||
style: 'position: absolute; overflow: hidden; top:' +
|
||||
(body.scrollTop + 30) + 'px; left: 0; width: 1px; height: 1px;'
|
||||
( body.scrollTop + startBlock.getBoundingClientRect().top ) +
|
||||
'px; left: 0; width: 1px; height: 1px;'
|
||||
});
|
||||
body.appendChild( pasteArea );
|
||||
range.selectNodeContents( pasteArea );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -1533,11 +1533,20 @@ proto._onPaste = function ( event ) {
|
|||
startContainer = range.startContainer,
|
||||
startOffset = range.startOffset,
|
||||
endContainer = range.endContainer,
|
||||
endOffset = range.endOffset;
|
||||
endOffset = range.endOffset,
|
||||
startBlock = startContainer.nodeType === TEXT_NODE ?
|
||||
startContainer : startContainer.childNodes[ startOffset ];
|
||||
|
||||
// We need to position the pasteArea in the visible portion of the screen
|
||||
// to stop the browser auto-scrolling.
|
||||
while ( isInline( startBlock ) ) {
|
||||
startBlock = startBlock.parentNode;
|
||||
}
|
||||
|
||||
var pasteArea = this.createElement( 'DIV', {
|
||||
style: 'position: absolute; overflow: hidden; top:' +
|
||||
(body.scrollTop + 30) + 'px; left: 0; width: 1px; height: 1px;'
|
||||
( body.scrollTop + startBlock.getBoundingClientRect().top ) +
|
||||
'px; left: 0; width: 1px; height: 1px;'
|
||||
});
|
||||
body.appendChild( pasteArea );
|
||||
range.selectNodeContents( pasteArea );
|
||||
|
|
Loading…
Reference in a new issue