Skip to content

Commit

Permalink
Improve jump-to-section scrolling
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmatts committed Nov 8, 2019
1 parent 7ae8015 commit 60ef205
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
2 changes: 1 addition & 1 deletion gui/app/components/document/view-content.js
Expand Up @@ -45,12 +45,12 @@ export default Component.extend(Notifier, {
didInsertElement() {
this._super(...arguments);

this.jumpToSection(this.get('currentPageId'));
},

didRender() {
this._super(...arguments);

this.jumpToSection(this.get('currentPageId'));
this.contentLinkHandler();
},

Expand Down
19 changes: 10 additions & 9 deletions gui/app/services/browser.js
Expand Up @@ -11,7 +11,6 @@

import $ from 'jquery';
import Service, { inject as service } from '@ember/service';
import { schedule } from '@ember/runloop';

export default Service.extend({
sessionService: service('session'),
Expand Down Expand Up @@ -42,15 +41,17 @@ export default Service.extend({
},

scrollTo(id) {
schedule('afterRender', () => {
let elem = $(id).offset();
if (_.isUndefined(elem)) return;
let elem = $(id).offset();
if (_.isUndefined(elem)) return;

$('html, body').animate({
scrollTop: elem.top
}, 250);
});
},
$('html, body').animate({
scrollTop: elem.top
}, 250);
},

waitScrollTo(id) {
setTimeout(() => { this.scrollTo(id); }, 1000);
},

downloadFile(content, filename) {
let b = new Blob([content], { type: 'text/html' });
Expand Down

0 comments on commit 60ef205

Please sign in to comment.