Editor scrolling: Remember and restore scroll position for visual and text modes.
This prevents the editor from jumping off screen when the rendered visual content is significantly taller than plain text, e.g. when there are views present. This is also a close restoration of 3.9 behavior, some of which was browser-specific. props avryl. fixes #29338. git-svn-id: https://develop.svn.wordpress.org/trunk@29693 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
7716dae9fa
commit
c529b75886
@ -31,6 +31,8 @@ jQuery( document ).ready( function($) {
|
||||
fixedSideBottom = false,
|
||||
scrollTimer,
|
||||
lastScrollPosition = 0,
|
||||
visualEditorScrollPosition = 0,
|
||||
textEditorScrollPosition = 0,
|
||||
pageYOffsetAtTop = 130,
|
||||
pinnedToolsTop = 56,
|
||||
sidebarBottom = 20,
|
||||
@ -224,20 +226,35 @@ jQuery( document ).ready( function($) {
|
||||
|
||||
// Adjust when switching editor modes.
|
||||
function mceShow() {
|
||||
textEditorScrollPosition = window.pageYOffset;
|
||||
|
||||
setTimeout( function() {
|
||||
var top = $contentWrap.offset().top;
|
||||
|
||||
if ( window.pageYOffset > top || visualEditorScrollPosition ) {
|
||||
window.scrollTo( window.pageXOffset, visualEditorScrollPosition ? visualEditorScrollPosition : top - heights.adminBarHeight );
|
||||
}
|
||||
|
||||
editor.execCommand( 'wpAutoResize' );
|
||||
adjust();
|
||||
}, 300 );
|
||||
|
||||
adjust();
|
||||
}
|
||||
|
||||
function mceHide() {
|
||||
var wrapHeight = $( '#wpwrap' ).height();
|
||||
visualEditorScrollPosition = window.pageYOffset;
|
||||
|
||||
setTimeout( function() {
|
||||
var top = $contentWrap.offset().top;
|
||||
|
||||
if ( window.pageYOffset > top || textEditorScrollPosition ) {
|
||||
window.scrollTo( window.pageXOffset, textEditorScrollPosition ? textEditorScrollPosition : top - heights.adminBarHeight );
|
||||
}
|
||||
|
||||
textEditorResize();
|
||||
|
||||
if ( wrapHeight && $window.scrollTop() > wrapHeight ) {
|
||||
window.scrollTo( window.pageXOffset, wrapHeight - 1 );
|
||||
}
|
||||
adjust();
|
||||
}, 100 );
|
||||
|
||||
adjust();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user