Skip to main content
Version: 9.0.2

gre.animation_trigger

gre.animation_trigger(animation_id, data)
--OR
gre.animation_trigger("animation_name")

Trigger an animation to run. If an animation_id is used to trigger the animation, then it must be the return value from gre.animation_create(). If a name is used to trigger an animation, then that name must be the name of the animation specified in Designer. This function can take an optional parameter, data_table. The data_table contains the tags and values for the extra arguments to set.

animation_state_machine.png

When an animation is triggered from ANIMATION_NOT_RUNNING, each of the steps duration and offset is resolved. All the steps from the beginning of the animation, until the time specified by progress * duration are computed, this means their to/from/tween values are resolved and the values are applied as appropriate.

When an animation is triggered from ANIMATION_PAUSED, the animation will either seek forwards or backwards, depending on the previous progress and the newly specified progress. When seeking forwards, all the steps that have not yet been processed, up until the specified progress will computed and the values applied. When seeking backwards, the previously computed steps will be directly reversed using the values from when the animation steps were originally computed.

When an animation is triggered without pausing, it will reach ANIMATION_NOT_RUNNING, at which point the animation is partially released from memory and the computed steps can no longer be used. This may have an adverse affect on those animations with relative start values.

ParameterTypeDescription
animation_id#stringThe animation to trigger
data#table[Optional] A table containing the tags and values for the extra arguments to set (see Animation Data)

Animation Data

ParameterTypeDescription
id#stringThe animation id used in the case of multiple animations with the same name
context#stringThe fully qualified name of an object in the model which will be used as the context for the animation.
progress#numberA value from 0.0-1.0, the percentage into the animation to begin. (default is 0)
pause#booleanA boolean value to indicate if the animation should be paused immediately after seeking to the value specified by progress, (default is false)
reverse#booleanA boolean value to indicate that the animation should run in reverse. (default is false)
cleanupbooleanA boolean value to indicate that the running instance of an animation should be removed from memory pon completion. Specifying false will enable a complex animation to be triggered in reverse after completion. (default is true)

Example

function create_animation(mapargs)
local data = {}

-- slide the x position 400 pixels over 2000 ms and auto-destroy
-- it on completion
id = gre.animation_create(60, 1)
data["rate"] = "linear"
data["duration"] = 2000
data["offset"] = 0
data["delta"] = 400
data["key"] = "mylayer.mycontrol.grd_x"
gre.animation_add_step(id, data)

gre.animation_trigger(id)
end

--Example of using gre.animation_trigger passing animation names.
function cb_toggle_cur_5day()
if cur_5day_toggle == false then
gre.animation_trigger("show_5day")
else
gre.animation_trigger("hide_mon_to_fri")
end
end

--Example of using gre.animation_trigger with context.
function cb_toggle_cur_5day()
local data = {}

data["context"] = "Layer1.mycontrol"
gre.animation_trigger("show_5day", data)
end