Merge pull request #22 from ApTx2012/feat/ui
Sync source to CNB / Sync Git ref (push) Skipped
Axolotl desktop CI / guardrails (push) Canceled after 0s
Axolotl desktop CI / desktop (macos-latest) (push) Canceled after 0s
Axolotl desktop CI / desktop (ubuntu-latest) (push) Canceled after 0s
Axolotl desktop CI / desktop (windows-latest) (push) Canceled after 0s
Axolotl desktop CI / website (push) Canceled after 0s
Repository checks / typos (push) Canceled after 0s
Repository checks / tombi (push) Canceled after 0s
Rust checks / shear (push) Canceled after 0s

fix: 引导步骤切换时自动滚动到目标元素
This commit is contained in:
AxTps authored and GitHub committed 2026-10-17 22:56:34 +08:00
commit 1baf1a041e
1 file changed
+22
@@ -197,6 +197,27 @@ export function useOnboardingTour(
requestAnimationFrame(updateRect) requestAnimationFrame(updateRect)
} }
// Bring the current step target into view when the tour jumps to a step
// whose target lives inside a scrollable container (e.g. the settings
// sidebar). Without this the bubble can point at an off-screen element.
function ensureTargetVisible() {
const target = targetElement.value
if (!target) return
const rect = target.getBoundingClientRect()
const outOfView =
rect.top < 0 ||
rect.left < 0 ||
rect.bottom > window.innerHeight ||
rect.right > window.innerWidth
if (!outOfView) return
target.scrollIntoView({ block: 'center', inline: 'nearest', behavior: 'smooth' })
requestAnimationFrame(() => {
if (targetElement.value === target) {
targetRect.value = target.getBoundingClientRect()
}
})
}
function goTo(destination: StepDestination) { function goTo(destination: StepDestination) {
if (destination === 'complete') { if (destination === 'complete') {
events.complete() events.complete()
@@ -343,6 +364,7 @@ export function useOnboardingTour(
await nextTick() await nextTick()
updateBubbleSize() updateBubbleSize()
updateTarget() updateTarget()
ensureTargetVisible()
}) })
watch(mode, () => { watch(mode, () => {