Ticket #7946: 7946_2.patch

File 7946_2.patch, 1.9 KB (added by Garry Yao, 12 years ago)
  • _source/core/dom/element.js

     
    13961396                        return { x : x, y : y };
    13971397                },
    13981398
    1399                 scrollIntoView : function( alignTop )
     1399                /**
     1400                 * Scrolls the specified element into the visible area of  the viewport.
     1401                 * @param [alignTop=true] {Boolean} On which side will this element be aligned to the closest scrollable ancestor element, by default it will be the top side to be aligned.
     1402                 */
     1403                scrollIntoView : function()
    14001404                {
    1401                         // Get the element window.
    1402                         var win = this.getWindow(),
    1403                                 winHeight = win.getViewPaneSize().height;
    1404 
    1405                         // Starts from the offset that will be scrolled with the negative value of
    1406                         // the visible window height.
    1407                         var offset = winHeight * -1;
    1408 
    1409                         // Append the view pane's height if align to top.
    1410                         // Append element height if we are aligning to the bottom.
    1411                         if ( alignTop )
    1412                                 offset += winHeight;
    1413                         else
    1414                         {
    1415                                 offset += this.$.offsetHeight || 0;
    1416 
    1417                                 // Consider the margin in the scroll, which is ok for our current needs, but
    1418                                 // needs investigation if we will be using this function in other places.
    1419                                 offset += parseInt( this.getComputedStyle( 'marginBottom' ) || 0, 10 ) || 0;
    1420                         }
    1421 
    1422                         // Append the offsets for the entire element hierarchy.
    1423                         var elementPosition = this.getDocumentPosition();
    1424                         offset += elementPosition.y;
    1425 
    1426                         // offset value might be out of range(nagative), fix it(#3692).
    1427                         offset = offset < 0 ? 0 : offset;
    1428 
    1429                         // Scroll the window to the desired position, if not already visible(#3795).
    1430                         var currentScroll = win.getScrollPosition().y;
    1431                         if ( offset > currentScroll || offset < currentScroll - winHeight )
    1432                                 win.$.scrollTo( 0, offset );
     1405                        this.$.scrollIntoView.apply( this.$, arguments );
    14331406                },
    14341407
    14351408                setState : function( state )
© 2003 – 2022, CKSource sp. z o.o. sp.k. All rights reserved. | Terms of use | Privacy policy