Control bounce?

Hi, maybe a silly one, but I thought I’d ask… anyone know of a declare (or other method) to simulate the app icon wanting attention bounce that occurs in the dock, but instead on an object on a window? Thought I’d ask before trying to figure out some code for myself (lazy I know! :wink:) tia, Dave.

In my 4-part series on the Xojo blog, I teach how to build an animation controller and include an example project. It’s fairly easy to implement from there, but if you want it even easier and you’re a GraffitiSuite customer, then my GraffitiAnimator is a more powerful version that makes it simple to animate anything and includes functionality and examples for controls.

Part 1
Part 2
Part 3
Part 4

3 Likes

Thank you Anthony :slight_smile:

1 Like

Yes, the code for making the dock icon in the macOS bounce, is included as part of the Ohanaware App Kit App Kit 2021 - Building Better Mac Applications

Thanks Sam, but it’s a control I want to animate not a dock item. Cheers.

You could checkout Thoms code

https://thezaz.com/code/animationkit/

Thanks Christoph, I do use Thom’s animation kit, a lot, it’s great. Was hoping there was a way to use a declare to call something that already exists in the OS. Being lazy! Cheers though.

It also includes the code to animate controls, download the demo application and have a play with it.

Well, ended up cobbling something together using Thom’s AnimationKit… seems to work quite well.

backgroundAnimatorThread.Stop

Var bounceTasks() As AnimationKit.MoveTask

Var bounceCurve As AnimationKit.Curve = AnimationKit.Curve.CreateFromPreset(AnimationKit.Curve.Presets.EaseOutQuad)

Var bounceCurveValue As Double = 0

While bounceCurveValue < 1
  
  Var bounceHeight As Double = bounceCurve.Evaluate(bounceCurveValue,50, 0)
  
  Var upTask As New AnimationKit.MoveTask(Canvas1)
  upTask.DurationInSeconds = 0.2
  upTask.Curve = AnimationKit.Curve.CreateFromPreset(AnimationKit.Curve.Presets.EaseOutQuad)
  upTask.Left = Canvas1.Left
  upTask.Top = Canvas1.Top-bounceHeight
  bounceTasks.Append upTask
  
  Var downTask As New AnimationKit.MoveTask(Canvas1)
  downTask.DurationInSeconds = 0.2
  downTask.Curve = AnimationKit.Curve.CreateFromPreset(AnimationKit.Curve.Presets.EaseInQuad)
  downTask.Left = Canvas1.Left
  downTask.Top = Canvas1.Top
  bounceTasks.Append downTask
  
  bounceCurveValue = bounceCurveValue + 0.2
  
Wend

Var bounceTask As AnimationKit.MoveTask

For i As Integer = 0 To bounceTasks.Ubound
  If i = 0 Then bounceTask = AnimationKit.MoveTask(bounceTasks(i)) Else bounceTask.NextTask = bounceTasks(i)
Next

bounceTask.Run
1 Like