GraffitiAnimatorControl

View Categories

Enumerations #

NameValues

This class exposes no enumerations.

Constants #

NameTypeValue

This class exposes no constants.

Events #

DefinitionDescription

This class exposes no events.

Delegates #

Definition
AtKeyframe(currentKeyframe as GraffitiAnimatorKeyframe)
AnimationComplete()
AnimationProgress(animControl as GraffitiAnimatorControl, animOp as GraffitiAnimatorOperation, newValue as Double)

Methods #

DefinitionDescription
AddKeyframe(Name as String, waitTime as Integer = 0) as GraffitiAnimatorControlAdds a new keyframe.
AddKeyframe(newKeyframe as GraffitiAnimatorKeyframe) as GraffitiAnimatorControl
AddKeyframe(waitTime as Integer = 0) as GraffitiAnimatorControl
AddOperation(animOp as GraffitiAnimatorOperation) as GraffitiAnimatorControlAdds a new animation operation to the stack.
Constructor(Target as RectControl)Instantiates a new instance of the class.
Move(newLeft as Double, newTop as Double, animationLength as Integer, easing as GraffitiAnimator.Easings) as GraffitiAnimatorControlMoves the control to the specified position.
OnComplete(finishFunction as AnimationComplete)Invokes the provided delegate when all animation has completed.
OnKeyframe(keyframeFunction as AtKeyframe)Invokes the provided delegate when the animation encounters a keyframe.
OnProgress(changeFunction as AnimationProgress)Invokes the provided delegate as animation operations progress.
Play(DestroyWhenComplete as Boolean = True)Plays the provided animation stack, optionally destructs itself when complete.
Resize(newWidth as Double, newHeight as Double, animationLength as Integer, easing as GraffitiAnimator.Easings)Resizes the RectControl using the specified values.
Shake(numberOfShakes as Integer = 5, deltaX as Integer = 5, deltaY as Integer = 0, animationLength as Integer = 800)Causes the RectControl to shake violently along the X-axis.
Stop() as GraffitiAnimatorControlCancels all running animations and immediately applies the requested end values for those operations.

Properties #

NameTypeDefault ValueDescription
ConstraintHeightiOSLayoutConstraintNilAutoLayout constraint to use when animating control’s height.
ConstraintLeftiOSLayoutConstraintNilAutoLayout constraint to use when animating control’s width.
ConstraintTopiOSLayoutConstraintNilAutoLayout constraint to use when animating control’s top.
ConstraintWidthiOSLayoutConstraintNilAutoLayout constraint to use when animating control’s width.
StateGraffitiAnimator.StatesIdleThe current running state of the animator.
TargetRectControlNilThe UI element to be animated.

Examples #

Chaining #

This class was developed to make animation chaining simple for enthralling UI animations. Below is an example directly from the demo project that demonstrates how this is done. Me is a PushButton:

if animControl = nil then
  '// Setup constraints.
  var x as new iOSLayoutConstraint( me, iOSLayoutConstraint.AttributeTypes.Left, _
  iOSLayoutConstraint.RelationTypes.Equal, _
  self, iOSLayoutConstraint.AttributeTypes.Left, 1, me.Left, 1000 )
  x.Active = True
  
  var y as new iOSLayoutConstraint( me, iOSLayoutConstraint.AttributeTypes.Top, _
  iOSLayoutConstraint.RelationTypes.Equal, _
  self, iOSLayoutConstraint.AttributeTypes.Top, 1, 70, 1000 )
  y.Active = True
  
  var w as new iOSLayoutConstraint( me, iOSLayoutConstraint.AttributeTypes.Width, _
  iOSLayoutConstraint.RelationTypes.Equal, _
  nil, iOSLayoutConstraint.AttributeTypes.None, 1, me.Width, 1000 )
  w.Active = True
  
  var h as new iOSLayoutConstraint( me, iOSLayoutConstraint.AttributeTypes.Height, _
  iOSLayoutConstraint.RelationTypes.Equal, _
  nil, iOSLayoutConstraint.AttributeTypes.None, 1, me.Height, 1000 )
  h.Active = True
  
  self.AddConstraint( x )
  self.AddConstraint( y )
  self.AddConstraint( w )
  self.AddConstraint( h )
  
  animControl = new GraffitiAnimatorControl( me, x, y, w, h )
  call animControl.OnProgress( GraffitiAnimatorControl.AnimationProgress( WeakAddressOf bounceProgress ) )._
  OnKeyframe( GraffitiAnimatorControl.AtKeyframe( WeakAddressOf bounceKeyframe ) )._
  OnComplete( GraffitiAnimatorControl.AnimationComplete( WeakAddressOf bounceFinished ) )
end if

if animControl.State = GraffitiAnimator.States.Running then Return

animControl.constraintTop.Offset = 70

Call animControl._
AddOperation( new GraffitiAnimatorOperation( "textsize", me.FontSize, me.FontSize * 2, 1000, GraffitiAnimator.Easings.BounceOut ) )._
Move( me.Left, me.Top + 50, 1000, GraffitiAnimator.Easings.BounceOut )._
Resize( me.Width * 2, me.Height, 1000, GraffitiAnimator.Easings.ElasticOut )._
AddKeyframe( "MidPoint", 1000 )

call animControl.Play( True )

Notes #

Constraints #

In order for animations to function correctly, any constraints on the target object must be set to have any priority except Highest. GraffitiAnimator will modify the Offset of these constraints based on the time elapsed in the animation sequence.