Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScrollSync disable smooth scroll option #1092

Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Implement disable smooth scroll option for ScrollSync
  • Loading branch information
ferrybig committed Jun 9, 2017
commit 69f4c3aaecf257e75f3ef36f4bfc3abfacc59d16
16 changes: 15 additions & 1 deletion public/res/extensions/scrollSync.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,23 @@
define([
"jquery",
"underscore",
"utils",
"classes/Extension",
"text!html/scrollSyncSettingsBlock.html"
], function($, _, Extension, scrollSyncSettingsBlockHTML) {
], function($, _, utils, Extension, scrollSyncSettingsBlockHTML) {

var scrollSync = new Extension("scrollSync", "Scroll Sync", true, true);
scrollSync.settingsBlock = scrollSyncSettingsBlockHTML;
scrollSync.defaultConfig = {
noSmooth: false
};
scrollSync.onLoadSettings = function() {
utils.setInputChecked("#input-scrollsync-smooth", scrollSync.config.noSmooth);
};

scrollSync.onSaveSettings = function(newConfig) {
newConfig.noSmooth = utils.getInputChecked("#input-scrollsync-smooth");
};
var sectionList;
scrollSync.onSectionsCreated = function(sectionListParam) {
sectionList = sectionListParam;
Expand Down Expand Up @@ -105,6 +115,10 @@ define([
var currentEndCb;

function animate(elt, startValue, endValue, stepCb, endCb) {
if(scrollSync.config.noSmooth) {
elt.scrollTop = endValue;
return;
}
if(currentEndCb) {
clearTimeout(timeoutId);
currentEndCb();
Expand Down
12 changes: 11 additions & 1 deletion public/res/html/scrollSyncSettingsBlock.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,14 @@
position of the title elements (h1, h2...) in the page. Therefore if
your document does not contain any title, the mapping will be linear and
consequently less accurate.</p>
</blockquote>
</blockquote>
<div class="form-horizontal">
<div class="form-group">
<label class="col-sm-4 control-label" for="input-scrollsync-smooth">Disable smooth scroll</label>
<div class="col-sm-7">
<div class="checkbox">
<input type="checkbox" id="input-scrollsync-smooth">
</div>
</div>
</div>
</div>