diff options
author | Joas Souza <joassouzasantos@gmail.com> | 2018-01-03 18:57:28 -0300 |
---|---|---|
committer | Luiza Pagliari <lpagliari@gmail.com> | 2018-01-03 19:57:28 -0200 |
commit | f1fcd16894e562903caf02b30ac238592dac0bf8 (patch) | |
tree | d6bd9d89c6bbbcfb3f815f4f104d95d938d6e41c /src/node | |
parent | 291f700376fee09fea532993881c8ffe28cfb3be (diff) | |
download | etherpad-lite-f1fcd16894e562903caf02b30ac238592dac0bf8.zip |
Add settings to scroll on edition out of viewport (#3282)
* Add scroll when it edits a line out of viewport
By default, when there is an edition of a line, which is out of the
viewport, Etherpad scrolls the minimum necessary to make this line
visible. This makes that the line stays either on the top or the bottom
of the viewport. With this commit, we add a setting to make possible to
scroll to a position x% pixels from the viewport. Besides of that, we
add a setting to make an animation of this scroll.
If nothing is changed on settings.json the Etherpad default behavior is
kept
Diffstat (limited to 'src/node')
-rw-r--r-- | src/node/handler/PadMessageHandler.js | 9 | ||||
-rw-r--r-- | src/node/utils/Settings.js | 27 |
2 files changed, 36 insertions, 0 deletions
diff --git a/src/node/handler/PadMessageHandler.js b/src/node/handler/PadMessageHandler.js index b7ec7cb2..060bca7b 100644 --- a/src/node/handler/PadMessageHandler.js +++ b/src/node/handler/PadMessageHandler.js @@ -1216,6 +1216,15 @@ function handleClientReady(client, message) "parts": plugins.parts, }, "indentationOnNewLine": settings.indentationOnNewLine, + "scrollWhenFocusLineIsOutOfViewport": { + "percentage" : { + "editionAboveViewport": settings.scrollWhenFocusLineIsOutOfViewport.percentage.editionAboveViewport, + "editionBelowViewport": settings.scrollWhenFocusLineIsOutOfViewport.percentage.editionBelowViewport, + }, + "duration": settings.scrollWhenFocusLineIsOutOfViewport.duration, + "scrollWhenCaretIsInTheLastLineOfViewport": settings.scrollWhenFocusLineIsOutOfViewport.scrollWhenCaretIsInTheLastLineOfViewport, + "percentageToScrollWhenUserPressesArrowUp": settings.scrollWhenFocusLineIsOutOfViewport.percentageToScrollWhenUserPressesArrowUp, + }, "initialChangesets": [] // FIXME: REMOVE THIS SHIT } diff --git a/src/node/utils/Settings.js b/src/node/utils/Settings.js index 660b7afb..cf7fea80 100644 --- a/src/node/utils/Settings.js +++ b/src/node/utils/Settings.js @@ -247,6 +247,33 @@ exports.users = {}; */ exports.showSettingsInAdminPage = true; +/* +* By default, when caret is moved out of viewport, it scrolls the minimum height needed to make this +* line visible. +*/ +exports.scrollWhenFocusLineIsOutOfViewport = { + /* + * Percentage of viewport height to be additionally scrolled. + */ + "percentage": { + "editionAboveViewport": 0, + "editionBelowViewport": 0 + }, + /* + * Time (in milliseconds) used to animate the scroll transition. Set to 0 to disable animation + */ + "duration": 0, + /* + * Flag to control if it should scroll when user places the caret in the last line of the viewport + */ + /* + * Percentage of viewport height to be additionally scrolled when user presses arrow up + * in the line of the top of the viewport. + */ + "percentageToScrollWhenUserPressesArrowUp": 0, + "scrollWhenCaretIsInTheLastLineOfViewport": false +}; + //checks if abiword is avaiable exports.abiwordAvailable = function() { |