Skip to content

Commit 60ef205

Browse files
committed
Improve jump-to-section scrolling
1 parent 7ae8015 commit 60ef205

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

gui/app/components/document/view-content.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,12 +45,12 @@ export default Component.extend(Notifier, {
4545
didInsertElement() {
4646
this._super(...arguments);
4747

48-
this.jumpToSection(this.get('currentPageId'));
4948
},
5049

5150
didRender() {
5251
this._super(...arguments);
5352

53+
this.jumpToSection(this.get('currentPageId'));
5454
this.contentLinkHandler();
5555
},
5656

gui/app/services/browser.js

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
import $ from 'jquery';
1313
import Service, { inject as service } from '@ember/service';
14-
import { schedule } from '@ember/runloop';
1514

1615
export default Service.extend({
1716
sessionService: service('session'),
@@ -42,15 +41,17 @@ export default Service.extend({
4241
},
4342

4443
scrollTo(id) {
45-
schedule('afterRender', () => {
46-
let elem = $(id).offset();
47-
if (_.isUndefined(elem)) return;
44+
let elem = $(id).offset();
45+
if (_.isUndefined(elem)) return;
4846

49-
$('html, body').animate({
50-
scrollTop: elem.top
51-
}, 250);
52-
});
53-
},
47+
$('html, body').animate({
48+
scrollTop: elem.top
49+
}, 250);
50+
},
51+
52+
waitScrollTo(id) {
53+
setTimeout(() => { this.scrollTo(id); }, 1000);
54+
},
5455

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

0 commit comments

Comments
 (0)