jenkins-bot has submitted this change and it was merged.

Change subject: [DEPRECATING CHANGE] Element#scrollIntoView: Replace callback 
with promise
......................................................................


[DEPRECATING CHANGE] Element#scrollIntoView: Replace callback with promise

Change-Id: I7cd4f20ab889e42d760e3f88163f62eacfc3cad4
---
M src/Element.js
1 file changed, 13 insertions(+), 7 deletions(-)

Approvals:
  Jforrester: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/src/Element.js b/src/Element.js
index c8abc33..619477a 100644
--- a/src/Element.js
+++ b/src/Element.js
@@ -595,10 +595,13 @@
  * @param {string} [config.duration='fast'] jQuery animation duration value
  * @param {string} [config.direction] Scroll in only one direction, e.g. 'x' 
or 'y', omit
  *  to scroll in both directions
- * @param {Function} [config.complete] Function to call when scrolling 
completes
+ * @param {Function} [config.complete] Function to call when scrolling 
completes.
+ *  Deprecated since 0.15.4, use the return promise instead.
+ * @return {jQuery.Promise} Promise which resolves when the scroll is complete
  */
 OO.ui.Element.static.scrollIntoView = function ( el, config ) {
-       var position, animations, callback, container, $container, 
elementDimensions, containerDimensions, $window;
+       var position, animations, callback, container, $container, 
elementDimensions, containerDimensions, $window,
+               deferred = $.Deferred();
 
        // Configuration initialization
        config = config || {};
@@ -646,17 +649,20 @@
        }
        if ( !$.isEmptyObject( animations ) ) {
                $container.stop( true ).animate( animations, config.duration 
=== undefined ? 'fast' : config.duration );
-               if ( callback ) {
-                       $container.queue( function ( next ) {
+               $container.queue( function ( next ) {
+                       if ( callback ) {
                                callback();
-                               next();
-                       } );
-               }
+                       }
+                       deferred.resolve();
+                       next();
+               } );
        } else {
                if ( callback ) {
                        callback();
+                       deferred.resolve();
                }
        }
+       return deferred.promise();
 };
 
 /**

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I7cd4f20ab889e42d760e3f88163f62eacfc3cad4
Gerrit-PatchSet: 2
Gerrit-Project: oojs/ui
Gerrit-Branch: master
Gerrit-Owner: Esanders <[email protected]>
Gerrit-Reviewer: Jforrester <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to