Ticket #3795: 3795.patch

File 3795.patch, 1.1 KB (added by Garry Yao, 11 years ago)
  • _source/core/dom/element.js

     
    12231223                        // Append the offsets for the entire element hierarchy.
    12241224                        var elementPosition = this.getDocumentPosition();
    12251225                        offset += elementPosition.y;
    1226                         // Scroll the window to the desired position, if not already visible.
    1227                         var currentScroll = win.getScrollPosition().y;
    12281226
    1229                         // Though the computed offset value maybe out of range ( e.g.
    1230                         // a negative value ), browser will try to scroll as much as possible. (#3692)
    1231                         win.$.scrollTo( 0, offset > 0 ? offset : 0 );
     1227                        // offset value might be out of range(nagative), fix it(#3692).
     1228                        offset = offset < 0 ? 0 : offset;
     1229
     1230                        // Scroll the window to the desired position, if not already visible(#3795).
     1231                        var currentScroll = win.getScrollPosition().y;
     1232                        if ( offset > currentScroll || offset < currentScroll - winHeight )
     1233                                win.$.scrollTo( 0, offset );
    12321234                },
    12331235
    12341236                setState : function( state )
© 2003 – 2019 CKSource – Frederico Knabben. All rights reserved. | Terms of use | Privacy policy