Esanders has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/270261

Change subject: Expand variable names in scrollIntoView
......................................................................

Expand variable names in scrollIntoView

Because humans.

Change-Id: Ic2fc9a678c1e56e36cfb5058cfa7e1ccdfb9407c
---
M src/Element.js
1 file changed, 31 insertions(+), 31 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/oojs/ui refs/changes/61/270261/1

diff --git a/src/Element.js b/src/Element.js
index 6b770a5..4f86844 100644
--- a/src/Element.js
+++ b/src/Element.js
@@ -574,56 +574,56 @@
  * @param {Function} [config.complete] Function to call when scrolling 
completes
  */
 OO.ui.Element.static.scrollIntoView = function ( el, config ) {
-       var rel, anim, callback, sc, $sc, eld, scd, $win;
+       var position, animations, callback, container, $container, 
elementDimensions, containerDimensions, $window;
 
        // Configuration initialization
        config = config || {};
 
-       anim = {};
+       animations = {};
        callback = typeof config.complete === 'function' && config.complete;
-       sc = this.getClosestScrollableContainer( el, config.direction );
-       $sc = $( sc );
-       eld = this.getDimensions( el );
-       scd = this.getDimensions( sc );
-       $win = $( this.getWindow( el ) );
+       container = this.getClosestScrollableContainer( el, config.direction );
+       $container = $( container );
+       elementDimensions = this.getDimensions( el );
+       containerDimensions = this.getDimensions( container );
+       $window = $( this.getWindow( el ) );
 
-       // Compute the distances between the edges of el and the edges of the 
scroll viewport
-       if ( $sc.is( 'html, body' ) ) {
+       // Compute the element's position relative to the container
+       if ( $container.is( 'html, body' ) ) {
                // If the scrollable container is the root, this is easy
-               rel = {
-                       top: eld.rect.top,
-                       bottom: $win.innerHeight() - eld.rect.bottom,
-                       left: eld.rect.left,
-                       right: $win.innerWidth() - eld.rect.right
+               position = {
+                       top: elementDimensions.rect.top,
+                       bottom: $window.innerHeight() - 
elementDimensions.rect.bottom,
+                       left: elementDimensions.rect.left,
+                       right: $window.innerWidth() - 
elementDimensions.rect.right
                };
        } else {
-               // Otherwise, we have to subtract el's coordinates from sc's 
coordinates
-               rel = {
-                       top: eld.rect.top - ( scd.rect.top + scd.borders.top ),
-                       bottom: scd.rect.bottom - scd.borders.bottom - 
scd.scrollbar.bottom - eld.rect.bottom,
-                       left: eld.rect.left - ( scd.rect.left + 
scd.borders.left ),
-                       right: scd.rect.right - scd.borders.right - 
scd.scrollbar.right - eld.rect.right
+               // Otherwise, we have to subtract el's coordinates from 
container's coordinates
+               position = {
+                       top: elementDimensions.rect.top - ( 
containerDimensions.rect.top + containerDimensions.borders.top ),
+                       bottom: containerDimensions.rect.bottom - 
containerDimensions.borders.bottom - containerDimensions.scrollbar.bottom - 
elementDimensions.rect.bottom,
+                       left: elementDimensions.rect.left - ( 
containerDimensions.rect.left + containerDimensions.borders.left ),
+                       right: containerDimensions.rect.right - 
containerDimensions.borders.right - containerDimensions.scrollbar.right - 
elementDimensions.rect.right
                };
        }
 
        if ( !config.direction || config.direction === 'y' ) {
-               if ( rel.top < 0 ) {
-                       anim.scrollTop = scd.scroll.top + rel.top;
-               } else if ( rel.top > 0 && rel.bottom < 0 ) {
-                       anim.scrollTop = scd.scroll.top + Math.min( rel.top, 
-rel.bottom );
+               if ( position.top < 0 ) {
+                       animations.scrollTop = containerDimensions.scroll.top + 
position.top;
+               } else if ( position.top > 0 && position.bottom < 0 ) {
+                       animations.scrollTop = containerDimensions.scroll.top + 
Math.min( position.top, -position.bottom );
                }
        }
        if ( !config.direction || config.direction === 'x' ) {
-               if ( rel.left < 0 ) {
-                       anim.scrollLeft = scd.scroll.left + rel.left;
-               } else if ( rel.left > 0 && rel.right < 0 ) {
-                       anim.scrollLeft = scd.scroll.left + Math.min( rel.left, 
-rel.right );
+               if ( position.left < 0 ) {
+                       animations.scrollLeft = containerDimensions.scroll.left 
+ position.left;
+               } else if ( position.left > 0 && position.right < 0 ) {
+                       animations.scrollLeft = containerDimensions.scroll.left 
+ Math.min( position.left, -position.right );
                }
        }
-       if ( !$.isEmptyObject( anim ) ) {
-               $sc.stop( true ).animate( anim, config.duration || 'fast' );
+       if ( !$.isEmptyObject( animations ) ) {
+               $container.stop( true ).animate( animations, config.duration || 
'fast' );
                if ( callback ) {
-                       $sc.queue( function ( next ) {
+                       $container.queue( function ( next ) {
                                callback();
                                next();
                        } );

-- 
To view, visit https://gerrit.wikimedia.org/r/270261
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic2fc9a678c1e56e36cfb5058cfa7e1ccdfb9407c
Gerrit-PatchSet: 1
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Esanders <esand...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to