change LinksReform.js

This commit is contained in:
F4ilji
2026-01-26 10:24:59 +05:00
parent 2b4b97cd7e
commit 7f93aa185e
+8 -5
View File
@@ -1,3 +1,5 @@
// linksReform.js
export const linksReform = {
data() {
return {
@@ -27,11 +29,9 @@ export const linksReform = {
async removeBackdropElement() {
const backdrop = document.querySelector('div[data-hs-overlay-backdrop-template]');
if (backdrop) {
// Добавляем анимацию исчезновения
backdrop.style.transition = 'opacity 0.5s ease';
backdrop.style.opacity = '0';
// Ждем завершения анимации
await new Promise(resolve => {
backdrop.addEventListener('transitionend', () => {
backdrop.remove();
@@ -49,20 +49,23 @@ export const linksReform = {
reactiveLinks.forEach(link => {
link.addEventListener('click', async (event) => {
if (link.getAttribute('target') === '_blank') {
return;
}
if (this.checkPathname(link.pathname)) return;
event.preventDefault();
const url = link.getAttribute('href');
try {
// Удаляем бэкдроп с анимацией перед переходом
await this.removeBackdropElement();
this.clearBodyStyles();
this.$inertia.visit(url, {
preserveScroll: false,
onBefore: () => {
// Дополнительная проверка перед переходом
this.removeBackdropElement().catch(() => {});
this.clearBodyStyles();
return true;
@@ -70,7 +73,7 @@ export const linksReform = {
});
} catch (e) {
console.error('Error during navigation:', e);
this.$inertia.visit(url); // Fallback на обычный переход
this.$inertia.visit(url);
}
});
});