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

Change subject: Scroll elements to middle of the screen
......................................................................


Scroll elements to middle of the screen

Currently scrolls new forms to the very top of the screen, which removes 
context.
Instead scroll the new form into the middle of the screen.

Change-Id: I1a0334571ea43e165c775bcf4cb59c930a418227
---
M modules/discussion/ui.js
1 file changed, 9 insertions(+), 7 deletions(-)

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



diff --git a/modules/discussion/ui.js b/modules/discussion/ui.js
index cb3d74e..d7ff64a 100644
--- a/modules/discussion/ui.js
+++ b/modules/discussion/ui.js
@@ -47,7 +47,8 @@
                        .click( function ( e ) {
                                e.preventDefault();
 
-                               var $form;
+                               var $form,
+                                       $viewport = $('main, html');
 
                                if ( $(this).is( '.flow-post-container 
.flow-post-container *' ) ) {
                                        // We're in a tangent
@@ -77,10 +78,9 @@
                                mw.flow.editor.load( $textarea );
 
                                // Scroll to the form
-                               // @todo should we try to center the form 
instead?
-                               $( 'html, body' ).animate( {
-                                       'scrollTop' : $form.offset().top
-                               } );
+                               $viewport.animate( {
+                                       'scrollTop' : $form.offset().top - 
$viewport.height()/2
+                               }, 500 );
                        } );
 
                $( '<a />' )
@@ -182,8 +182,10 @@
                                var $hideElement = $( this ).closest( 
'.flow-topic-container' ).children( '.flow-post-container' ), self = this;
                                e.stopPropagation();
                                $hideElement.slideDown( function() {
-                                       $( 'html,body' ).animate( {
-                                               'scrollTop': $( 
'#flow-topic-reply-' + $( self ).data( 'topic-id' ) ).offset().top
+                                       var $viewport = $( 'html,body' ),
+                                               $replyContainer = $( 
'#flow-topic-reply-' + $( self ).data( 'topic-id' ) );
+                                       $viewport.animate( {
+                                               'scrollTop': 
$replyContainer.offset().top - $viewport.height()/2
                                        }, 500 );
                                } );
                        }

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

Gerrit-MessageType: merged
Gerrit-Change-Id: I1a0334571ea43e165c775bcf4cb59c930a418227
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
Gerrit-Reviewer: Matthias Mullie <[email protected]>
Gerrit-Reviewer: jenkins-bot

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

Reply via email to