Helder.wiki has uploaded a new change for review.

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

Change subject: Postpone autoHide timer of notifications if window is not 
focused
......................................................................

Postpone autoHide timer of notifications if window is not focused

While at it, if there is no notification visible, avoid adding or
removing classes to the notification area when scrolling.

Bug: 40322
Change-Id: I7843daad5d4f3edbc9b1d3843dae2ce7af72d9c7
---
M resources/src/mediawiki/mediawiki.notification.js
1 file changed, 15 insertions(+), 4 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/mediawiki/core 
refs/changes/27/154227/1

diff --git a/resources/src/mediawiki/mediawiki.notification.js 
b/resources/src/mediawiki/mediawiki.notification.js
index 79ec310..015d010 100644
--- a/resources/src/mediawiki/mediawiki.notification.js
+++ b/resources/src/mediawiki/mediawiki.notification.js
@@ -6,6 +6,7 @@
                $area,
                // Number of open notification boxes at any time
                openNotificationCount = 0,
+               updateAreaMode,
                isPageReady = false,
                preReadyNotifQueue = [];
 
@@ -98,7 +99,14 @@
                        autohideCount,
                        notif;
 
-               $area.show();
+               if ( openNotificationCount === 0 ) {
+                       $area.show();
+                       $( window ).on( {
+                               scroll: updateAreaMode,
+                               blur: notification.pause,
+                               focus: notification.resume
+                       } );
+               }
 
                if ( this.isOpen ) {
                        return;
@@ -330,6 +338,11 @@
                                        // It's okay to do this before getting 
rid of the placeholder, as it's invisible as well.
                                        if ( openNotificationCount === 0 ) {
                                                $area.hide();
+                                               $( window ).off( {
+                                                       scroll: updateAreaMode,
+                                                       blur: 
notification.pause,
+                                                       focus: 
notification.resume
+                                               } );
                                        }
                                        if ( options.placeholder ) {
                                                // Use a fast slide up 
animation after closing to make it look like the notifications
@@ -392,14 +405,12 @@
                mw.util.$content.prepend( $area );
                offset = $area.offset();
 
-               function updateAreaMode() {
+               updateAreaMode = function () {
                        var isFloating = $window.scrollTop() > offset.top;
                        $area
                                .toggleClass( 'mw-notification-area-floating', 
isFloating )
                                .toggleClass( 'mw-notification-area-layout', 
!isFloating );
                }
-
-               $window.on( 'scroll', updateAreaMode );
 
                // Initial mode
                updateAreaMode();

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I7843daad5d4f3edbc9b1d3843dae2ce7af72d9c7
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/core
Gerrit-Branch: master
Gerrit-Owner: Helder.wiki <[email protected]>

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

Reply via email to