perf(stage-tamagotchi): resize once and then animate the window move
--------- Co-authored-by-agent: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -12,7 +12,7 @@ import { computeAdjacentPosition } from '../../../windows/shared/display'
|
|||||||
|
|
||||||
const ANIMATION_DURATION = 350
|
const ANIMATION_DURATION = 350
|
||||||
|
|
||||||
function animateWindowBounds(
|
function animateWindowTo(
|
||||||
window: BrowserWindow,
|
window: BrowserWindow,
|
||||||
target: Rectangle,
|
target: Rectangle,
|
||||||
): ReturnType<typeof animate> | undefined {
|
): ReturnType<typeof animate> | undefined {
|
||||||
@@ -20,25 +20,22 @@ function animateWindowBounds(
|
|||||||
return undefined
|
return undefined
|
||||||
|
|
||||||
const current = window.getBounds()
|
const current = window.getBounds()
|
||||||
const state = { x: current.x, y: current.y, w: current.width, h: current.height }
|
const needsResize = current.width !== target.width || current.height !== target.height
|
||||||
|
|
||||||
|
if (needsResize)
|
||||||
|
window.setSize(target.width, target.height)
|
||||||
|
|
||||||
|
const state = { x: current.x, y: current.y }
|
||||||
|
|
||||||
return animate(state, {
|
return animate(state, {
|
||||||
x: target.x,
|
x: target.x,
|
||||||
y: target.y,
|
y: target.y,
|
||||||
w: target.width,
|
|
||||||
h: target.height,
|
|
||||||
duration: ANIMATION_DURATION,
|
duration: ANIMATION_DURATION,
|
||||||
ease: 'outCubic',
|
ease: 'outCubic',
|
||||||
modifier: utils.round(0),
|
modifier: utils.round(0),
|
||||||
onRender: () => {
|
onRender: () => {
|
||||||
if (!window.isDestroyed()) {
|
if (!window.isDestroyed())
|
||||||
window.setBounds({
|
window.setPosition(Math.round(state.x), Math.round(state.y))
|
||||||
x: Math.round(state.x),
|
|
||||||
y: Math.round(state.y),
|
|
||||||
width: Math.round(state.w),
|
|
||||||
height: Math.round(state.h),
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -65,7 +62,7 @@ export function createOnboardingService(params: {
|
|||||||
)
|
)
|
||||||
|
|
||||||
currentAnimation?.pause()
|
currentAnimation?.pause()
|
||||||
currentAnimation = animateWindowBounds(params.mainWindow, {
|
currentAnimation = animateWindowTo(params.mainWindow, {
|
||||||
x: adjacent.x,
|
x: adjacent.x,
|
||||||
y: adjacent.y,
|
y: adjacent.y,
|
||||||
width: adjacent.width,
|
width: adjacent.width,
|
||||||
@@ -95,7 +92,7 @@ export function createOnboardingService(params: {
|
|||||||
|
|
||||||
if (!userMovedManually && !params.mainWindow.isDestroyed()) {
|
if (!userMovedManually && !params.mainWindow.isDestroyed()) {
|
||||||
currentAnimation?.pause()
|
currentAnimation?.pause()
|
||||||
currentAnimation = animateWindowBounds(params.mainWindow, savedBounds)
|
currentAnimation = animateWindowTo(params.mainWindow, savedBounds)
|
||||||
}
|
}
|
||||||
|
|
||||||
cleanupOnClosed = undefined
|
cleanupOnClosed = undefined
|
||||||
|
|||||||
Reference in New Issue
Block a user