mirror of
https://github.com/Redocly/redoc.git
synced 2025-07-29 17:40:05 +03:00
feat(): Add custom code for events
This commit is contained in:
parent
d5e5559c49
commit
8c7771e610
|
@ -72,6 +72,9 @@ export class AppStore {
|
|||
// update position statically based on hash (in case of SSR)
|
||||
MenuStore.updateOnHistory(this.history.currentId, this.scroll);
|
||||
|
||||
// Listen for external event to update
|
||||
window.addEventListener('redocUpdatePosition', this.updateOnEvent);
|
||||
|
||||
// override the openApi standard to version 3.1.0
|
||||
// TODO remove when fully supporting open API 3.1.0
|
||||
spec.openapi = '3.1.0';
|
||||
|
@ -98,6 +101,7 @@ export class AppStore {
|
|||
dispose() {
|
||||
this.scroll.dispose();
|
||||
this.menu.dispose();
|
||||
window.removeEventListener('redocUpdatePosition', this.updateOnEvent);
|
||||
if (this.search) {
|
||||
this.search.dispose();
|
||||
}
|
||||
|
@ -125,6 +129,10 @@ export class AppStore {
|
|||
};
|
||||
}
|
||||
|
||||
private updateOnEvent(): void {
|
||||
MenuStore.updateOnHistory(this.history.currentId, this.scroll);
|
||||
}
|
||||
|
||||
private updateMarkOnMenu(idx: number) {
|
||||
const start = Math.max(0, idx);
|
||||
const end = Math.min(this.menu.flatItems.length, start + 5);
|
||||
|
|
Loading…
Reference in New Issue
Block a user