Ticket #7429: 7429.patch

File 7429.patch, 2.5 KB (added by Garry Yao, 13 years ago)
  • _source/core/dom/element.js

     
    13471347                        return { x : x, y : y };
    13481348                },
    13491349
    1350                 scrollIntoView : function( alignTop )
     1350                scrollIntoView : function()
    13511351                {
    13521352                        // Get the element window.
    13531353                        var win = this.getWindow(),
    13541354                                winHeight = win.getViewPaneSize().height;
    13551355
    1356                         // Starts from the offset that will be scrolled with the negative value of
    1357                         // the visible window height.
    1358                         var offset = winHeight * -1;
     1356                        var startOffset = this.getDocumentPosition().y,
     1357                                endOffset = startOffset + this.$.offsetHeight || 0 + parseInt( this.getComputedStyle( 'marginBottom' ) || 0, 10 ) || 0;
    13591358
    1360                         // Append the view pane's height if align to top.
    1361                         // Append element height if we are aligning to the bottom.
    1362                         if ( alignTop )
    1363                                 offset += winHeight;
    1364                         else
    1365                         {
    1366                                 offset += this.$.offsetHeight || 0;
    1367 
    1368                                 // Consider the margin in the scroll, which is ok for our current needs, but
    1369                                 // needs investigation if we will be using this function in other places.
    1370                                 offset += parseInt( this.getComputedStyle( 'marginBottom' ) || 0, 10 ) || 0;
    1371                         }
    1372 
    1373                         // Append the offsets for the entire element hierarchy.
    1374                         var elementPosition = this.getDocumentPosition();
    1375                         offset += elementPosition.y;
    1376 
    1377                         // offset value might be out of range(nagative), fix it(#3692).
    1378                         offset = offset < 0 ? 0 : offset;
    1379 
    13801359                        // Scroll the window to the desired position, if not already visible(#3795).
    13811360                        var currentScroll = win.getScrollPosition().y;
    1382                         if ( offset > currentScroll || offset < currentScroll - winHeight )
    1383                                 win.$.scrollTo( 0, offset );
     1361
     1362                        // Bring it to bottom if  overflow forward.
     1363                        if ( endOffset > currentScroll + winHeight )
     1364                                win.$.scrollTo( 0, endOffset - winHeight );
     1365                        // Bring it to top if overflow backward.
     1366                        else if ( startOffset < currentScroll )
     1367                                win.$.scrollTo( 0, startOffset );
    13841368                },
    13851369
    13861370                setState : function( state )
  • _source/plugins/maximize/plugin.js

     
    311311
    312312                                                                editor.getSelection().selectRanges(savedSelection);
    313313                                                                var element = editor.getSelection().getStartElement();
    314                                                                 element && element.scrollIntoView( true );
     314                                                                element && element.scrollIntoView();
    315315                                                        }
    316316
    317317                                                        else
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy