EBernhardson has uploaded a new change for review.
https://gerrit.wikimedia.org/r/90077
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(-)
git pull ssh://gerrit.wikimedia.org:29418/mediawiki/extensions/Flow
refs/changes/77/90077/1
diff --git a/modules/discussion/ui.js b/modules/discussion/ui.js
index cb3d74e..4288452 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: newchange
Gerrit-Change-Id: I1a0334571ea43e165c775bcf4cb59c930a418227
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/extensions/Flow
Gerrit-Branch: master
Gerrit-Owner: EBernhardson <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits