mirror of
https://github.com/documize/community.git
synced 2025-07-19 13:19:43 +02:00
Improve jump-to-section scrolling
This commit is contained in:
parent
7ae801554d
commit
60ef205948
2 changed files with 11 additions and 10 deletions
|
@ -45,12 +45,12 @@ export default Component.extend(Notifier, {
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
this.jumpToSection(this.get('currentPageId'));
|
|
||||||
},
|
},
|
||||||
|
|
||||||
didRender() {
|
didRender() {
|
||||||
this._super(...arguments);
|
this._super(...arguments);
|
||||||
|
|
||||||
|
this.jumpToSection(this.get('currentPageId'));
|
||||||
this.contentLinkHandler();
|
this.contentLinkHandler();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
|
|
||||||
import $ from 'jquery';
|
import $ from 'jquery';
|
||||||
import Service, { inject as service } from '@ember/service';
|
import Service, { inject as service } from '@ember/service';
|
||||||
import { schedule } from '@ember/runloop';
|
|
||||||
|
|
||||||
export default Service.extend({
|
export default Service.extend({
|
||||||
sessionService: service('session'),
|
sessionService: service('session'),
|
||||||
|
@ -42,14 +41,16 @@ export default Service.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
scrollTo(id) {
|
scrollTo(id) {
|
||||||
schedule('afterRender', () => {
|
|
||||||
let elem = $(id).offset();
|
let elem = $(id).offset();
|
||||||
if (_.isUndefined(elem)) return;
|
if (_.isUndefined(elem)) return;
|
||||||
|
|
||||||
$('html, body').animate({
|
$('html, body').animate({
|
||||||
scrollTop: elem.top
|
scrollTop: elem.top
|
||||||
}, 250);
|
}, 250);
|
||||||
});
|
},
|
||||||
|
|
||||||
|
waitScrollTo(id) {
|
||||||
|
setTimeout(() => { this.scrollTo(id); }, 1000);
|
||||||
},
|
},
|
||||||
|
|
||||||
downloadFile(content, filename) {
|
downloadFile(content, filename) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue