mirror of
https://github.com/Spythere/stacjownik.git
synced 2026-05-03 13:28:11 +00:00
chore: reactive hiding body scroll on modal
This commit is contained in:
@@ -29,8 +29,15 @@ export default defineComponent({
|
|||||||
chosenTrain(train: Train | undefined) {
|
chosenTrain(train: Train | undefined) {
|
||||||
this.$nextTick(() => {
|
this.$nextTick(() => {
|
||||||
if (train) {
|
if (train) {
|
||||||
|
document.body.classList.add('no-scroll');
|
||||||
const contentEl = this.$refs['content'] as HTMLElement;
|
const contentEl = this.$refs['content'] as HTMLElement;
|
||||||
contentEl.focus();
|
contentEl.focus();
|
||||||
|
} else {
|
||||||
|
(this.store.modalLastClickedTarget as any)?.focus();
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
document.body.classList.remove('no-scroll');
|
||||||
|
}, 90);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,24 +14,17 @@ export default defineComponent({
|
|||||||
methods: {
|
methods: {
|
||||||
selectModalTrain(train: Train, target?: EventTarget | null) {
|
selectModalTrain(train: Train, target?: EventTarget | null) {
|
||||||
this.store.chosenModalTrainId = train.modalId;
|
this.store.chosenModalTrainId = train.modalId;
|
||||||
document.body.classList.add('no-scroll');
|
|
||||||
if (target) this.store.modalLastClickedTarget = target;
|
if (target) this.store.modalLastClickedTarget = target;
|
||||||
},
|
},
|
||||||
|
|
||||||
selectModalTrainById(modalId: string, target?: EventTarget | null) {
|
selectModalTrainById(modalId: string, target?: EventTarget | null) {
|
||||||
this.store.chosenModalTrainId = modalId;
|
this.store.chosenModalTrainId = modalId;
|
||||||
document.body.classList.add('no-scroll');
|
|
||||||
if (target) this.store.modalLastClickedTarget = target;
|
if (target) this.store.modalLastClickedTarget = target;
|
||||||
},
|
},
|
||||||
|
|
||||||
closeModal() {
|
closeModal() {
|
||||||
this.store.chosenModalTrainId = undefined;
|
this.store.chosenModalTrainId = undefined;
|
||||||
this.tooltipStore.hide();
|
this.tooltipStore.hide();
|
||||||
|
|
||||||
setTimeout(() => {
|
|
||||||
(this.store.modalLastClickedTarget as any)?.focus();
|
|
||||||
document.body.classList.remove('no-scroll');
|
|
||||||
}, 150);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user