jenkins-bot has submitted this change and it was merged.
Change subject: If cursor is obscured by toolbar, on keypress scroll to cursor.
......................................................................
If cursor is obscured by toolbar, on keypress scroll to cursor.
Bug: 48735
Change-Id: I45028ed2f13148332518badd5f4647d4d652884e
---
M modules/ve/ui/ve.ui.Toolbar.js
1 file changed, 19 insertions(+), 2 deletions(-)
Approvals:
Catrope: Looks good to me, approved
jenkins-bot: Verified
diff --git a/modules/ve/ui/ve.ui.Toolbar.js b/modules/ve/ui/ve.ui.Toolbar.js
index f180066..52042ac 100644
--- a/modules/ve/ui/ve.ui.Toolbar.js
+++ b/modules/ve/ui/ve.ui.Toolbar.js
@@ -37,7 +37,8 @@
this.$window = null;
this.windowEvents = {
'resize': ve.bind( this.onWindowResize, this ),
- 'scroll': ve.bind( this.onWindowScroll, this )
+ 'scroll': ve.bind( this.onWindowScroll, this ),
+ 'keypress': ve.bind( this.onWindowKeypress, this )
};
// Events
@@ -101,7 +102,7 @@
};
/**
- * Handle window scroll events while toolbar floating is enabled.
+ * Handle window resize events while toolbar floating is enabled.
*
* Toolbar will stick to the top of the screen unless it would be over or
under the last visible
* branch node in the root of the document being edited, at which point it
will stop just above it.
@@ -122,6 +123,22 @@
};
/**
+ * Method to scroll to the cursor position while toolbar is floating on
keypress only if
+ * the cursor is obscured by the toolbar.
+ *
+ */
+ve.ui.Toolbar.prototype.onWindowKeypress = function () {
+ var cursorPos = this.surface.view.getSelectionRect(),
+ scrollTo = cursorPos.end.y - this.surface.view.$.offset().top,
+ obscured = cursorPos.end.y - this.$window.scrollTop() <
this.$.height() + this.$.offset().top;
+
+ // If toolbar is floating and cursor is obscured, scroll cursor into
view
+ if ( obscured && this.floating ) {
+ $( 'html,body' ).animate( { scrollTop: scrollTo }, 0 );
+ }
+};
+
+/**
* Gets the surface the toolbar controls.
*
* @method
--
To view, visit https://gerrit.wikimedia.org/r/70918
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: I45028ed2f13148332518badd5f4647d4d652884e
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/extensions/VisualEditor
Gerrit-Branch: master
Gerrit-Owner: Robmoen <[email protected]>
Gerrit-Reviewer: Catrope <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits