Hi all,
Maths was never my strong suit, but I've managed to make this following code work for bringing in a menu from the right hand side of a screen with a button press, and then moving it back off screen, using a Cosine function to smoothly adjust the X property:
Switch(true,
flyOut,
//Begins on-screen and moves off-screen, using Cosine to smoothly subtract a fraction of the Rectangle's full width at a time
//Starting Position on-screen
((Parent.Width - Self.Width) - 10) +
//Gradually add the width of the rectangle
(-Self.Width - 10) * Cos(MenuTimer.Value/MenuTimer.Duration * (Pi()/2)) + (Self.Width + 10),
!flyOut,
//This takes the box from off-screen to on-screen, beginning with it's position being equal to the width of the screen
//Starting position off-screen
Parent.Width -
//Gradually add the width of the rectangle
((-Self.Width - 10) * Cos(MenuTimer.Value/MenuTimer.Duration * (Pi()/2)) + (Self.Width + 10))
)
I adapted this from the fantastic work of @Mr-Dang-MSFT to make it work on the right-hand side of the screen.
What I would like now is to see if I can make it do this with the EaseOutBack version, giving it a little bounce on the way out. Does anyone know at all how to make this happen? I guess it's nowhere near as simple of the Cosine version as we're technically adding a few extra pixels of movement just before it reaches it's final position just on screen.
-Edit-
I have included a gif of what it currently does:
WarrenBelz
146,645
Most Valuable Professional
RandyHayes
76,287
Super User 2024 Season 1
Pstork1
65,997
Most Valuable Professional