diff --git a/src/core.js b/src/core.js index 4d78f10..d679700 100644 --- a/src/core.js +++ b/src/core.js @@ -9,7 +9,7 @@ import { generateId, escapeHTML } from './utils.js'; import { DEFAULTS, ICONS, TYPE_COLORS, THEMES } from './constants.js'; import { injectStyles } from './styles.js'; import { getTheme, applyTheme } from './themes.js'; -import { t as i18nT, setCurrentLocale } from './i18n.js'; +import { t as i18nT, setCurrentLocale, getLocaleDirection, getCurrentLocale } from './i18n.js'; // 模块级共享容器缓存,所有 Toast 实例共用 // 使用 Map 而非 WeakMap:document.body 在页面存活期间永不被 GC, @@ -493,10 +493,11 @@ class Toast { el.classList.remove('met-show'); const pos = this.config.position || 'top-right'; + const isRTL = getLocaleDirection(getCurrentLocale()) === 'rtl'; let transform = 'scale(.96)'; - if (pos.includes('right')) transform = 'translateX(120%)'; - else if (pos.includes('left')) transform = 'translateX(-120%)'; + if (pos.includes('right')) transform = isRTL ? 'translateX(-120%)' : 'translateX(120%)'; + else if (pos.includes('left')) transform = isRTL ? 'translateX(120%)' : 'translateX(-120%)'; else if (pos.startsWith('top')) transform = 'translateY(-20px)'; else transform = 'translateY(20px)';