mirror of
https://github.com/Redocly/redoc.git
synced 2025-03-03 09:25:47 +03:00
parent
b9740bfe55
commit
4f4e7489ce
|
@ -27,8 +27,12 @@ export class Hash {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
update(hash: string|null) {
|
update(hash: string|null, rewriteHistory:boolean = false) {
|
||||||
if (hash == undefined) return;
|
if (hash == undefined) return;
|
||||||
|
if (rewriteHistory) {
|
||||||
|
window.history.replaceState(null, '', '#' + hash);
|
||||||
|
return;
|
||||||
|
}
|
||||||
this.noEmit = true;
|
this.noEmit = true;
|
||||||
window.location.hash = hash;
|
window.location.hash = hash;
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
|
|
@ -202,14 +202,14 @@ export class MenuService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
activate(idx, force = false) {
|
activate(idx, force = false, replaceState = false) {
|
||||||
let item = this.flatItems[idx];
|
let item = this.flatItems[idx];
|
||||||
if (!force && item && !item.ready) return;
|
if (!force && item && !item.ready) return;
|
||||||
|
|
||||||
this.deactivate(this.activeIdx);
|
this.deactivate(this.activeIdx);
|
||||||
this.activeIdx = idx;
|
this.activeIdx = idx;
|
||||||
if (idx < 0) {
|
if (idx < 0) {
|
||||||
this.hash.update('');
|
this.hash.update('', replaceState);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -220,14 +220,14 @@ export class MenuService {
|
||||||
cItem.parent.active = true;
|
cItem.parent.active = true;
|
||||||
cItem = cItem.parent;
|
cItem = cItem.parent;
|
||||||
}
|
}
|
||||||
this.hash.update(this.hashFor(item.id, item.metadata, item.parent && item.parent.id));
|
this.hash.update(this.hashFor(item.id, item.metadata, item.parent && item.parent.id), replaceState);
|
||||||
this.changedActiveItem.next(item);
|
this.changedActiveItem.next(item);
|
||||||
}
|
}
|
||||||
|
|
||||||
changeActive(offset = 1):boolean {
|
changeActive(offset = 1):boolean {
|
||||||
let noChange = (this.activeIdx <= 0 && offset === -1) ||
|
let noChange = (this.activeIdx <= 0 && offset === -1) ||
|
||||||
(this.activeIdx === this.flatItems.length - 1 && offset === 1);
|
(this.activeIdx === this.flatItems.length - 1 && offset === 1);
|
||||||
this.activate(this.activeIdx + offset);
|
this.activate(this.activeIdx + offset, false, true);
|
||||||
return noChange;
|
return noChange;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user