0
Fork 0
mirror of https://github.com/fastmail/Squire.git synced 2024-12-22 15:23:29 -05:00

Better positioning of paste area to prevent auto-scrolling.

This commit is contained in:
Neil Jenkins 2014-08-06 14:42:57 +02:00
parent afd3e9807c
commit da49316876
3 changed files with 24 additions and 6 deletions

View file

@ -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

View file

@ -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 );