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

Scroll cursor into view on enter.

This commit is contained in:
Neil Jenkins 2011-12-09 13:15:15 +11:00
parent ffe8d95cc1
commit 14ee0d0ad5

View file

@ -295,7 +295,7 @@
undoStack, // = [],
undoStackLength, // = 0,
isInUndoState, // = false,
docWasChanged = function docWasChanged () {
docWasChanged = function () {
if ( isInUndoState ) {
isInUndoState = false;
fireEvent( 'undoStateChange', {
@ -1253,6 +1253,16 @@
setSelection( createRange( nodeAfterSplit, 0 ) );
updatePath( 0, true );
// Scroll into view
if ( nodeAfterSplit.nodeType === TEXT_NODE ) {
nodeAfterSplit = nodeAfterSplit.parentNode;
}
if ( nodeAfterSplit.offsetTop + nodeAfterSplit.offsetHeight >
( doc.documentElement.scrollTop || body.scrollTop ) +
body.offsetHeight ) {
nodeAfterSplit.scrollIntoView( false );
}
// We're not still in an undo state
docWasChanged();
},