2021-03-20 19:44:43 +01:00
|
|
|
import Container from "./container.js";
|
|
|
|
|
|
|
|
export default class ScrollingContainer extends Container {
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
|
2021-06-13 22:55:31 +02:00
|
|
|
this.css('overflow', 'auto');
|
2021-03-20 19:44:43 +01:00
|
|
|
}
|
|
|
|
|
2021-06-24 23:50:56 +02:00
|
|
|
setNoteContextEvent({noteContext}) {
|
|
|
|
/** @var {NoteContext} */
|
|
|
|
this.noteContext = noteContext;
|
|
|
|
}
|
|
|
|
|
2021-05-22 12:35:41 +02:00
|
|
|
async noteSwitchedEvent({noteContext, notePath}) {
|
2021-06-24 23:50:56 +02:00
|
|
|
this.$widget.scrollTop(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
async noteSwitchedAndActivatedEvent({noteContext, notePath}) {
|
|
|
|
this.noteContext = noteContext;
|
|
|
|
|
|
|
|
this.$widget.scrollTop(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
async activeContextChangedEvent({noteContext}) {
|
|
|
|
this.noteContext = noteContext;
|
|
|
|
}
|
|
|
|
|
|
|
|
handleEventInChildren(name, data) {
|
|
|
|
if (name === 'readOnlyTemporarilyDisabled'
|
|
|
|
&& this.noteContext
|
|
|
|
&& this.noteContext.ntxId === data.noteContext.ntxId) {
|
|
|
|
|
|
|
|
const scrollTop = this.$widget.scrollTop();
|
|
|
|
|
|
|
|
const promise = super.handleEventInChildren(name, data);
|
|
|
|
|
|
|
|
promise.then(() => setTimeout(() => this.$widget.scrollTop(scrollTop), 500));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return super.handleEventInChildren(name, data);
|
2021-03-20 19:44:43 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|