- Reference
- Animation
iRidi API. Animation
Functions, methods, and object properties for animating popup and graphic-item movement with the animation library. The animation library is a legacy approach; you can also use the new native animation methods (described at this link).
Animation library
attend a free training webinar
The animation library is a ready-made JavaScript file containing functions and methods for animating items in your project.
Standard methods use frame-by-frame animation and item state changes. The iRidi animation library allows you to create complex effects for individual items and groups.
The current library version is available here:
download:
iRidi animation library (*.js)
Do not edit the library or write your own code in its file, to preserve compatibility.
Using the library
- Download the library (*.js file) and add it to the iRidi project (
JavaScript Editor >> Add from file). - Create a script file (
JavaScript Editor >> New file) and enterANIMATION- the library function.
Function parameters:
var Player1 = ANIMATION(
[effect_1, effect_2],
[item_1, item_2],
duration,
delay,
repeat,
type,
startCallBack,
endCallBack,
context
);
- [effect_1, effect_2] -
{Array | Effect}the array contains effects to apply to the items. Available effects:- MoveHorizontal(0, 100) - horizontal movement; parameters: starting position and X displacement in pixels
- MoveVertical(0, 100) - vertical movement; parameters: starting position and Y displacement in pixels
- MoveDiagonal(0, 100) - diagonal movement; parameters: starting position and X/Y displacement in pixels
- Rotate(360) - rotation; parameter: rotation angle in degrees
- Show() - show
- Hide() - hide
- ScaleXY(0.0, 1.1) - scale; parameters: initial size and X/Y scaling factor
- ScaleX(0.0, 1.1) - scale; parameters: initial size and X scaling factor
- ScaleY(0.0, 1.1) - scale; parameters: initial size and Y scaling factor
- Value(0, 100) - smoothly changes the item's Value; parameters: initial and final values
- ValueToText(0, 100) - smoothly changes the item's Text; parameters: initial and final values
- [item_1, item_2] -
{Array | IridiumItem}the array contains references to the items to animate - duration -
{Number}animation duration (ms) >= 0; keywordANIMATION.DEFAULT_TIME= 300 ms, the default duration - delay -
{Number}animation delay, >= 0; if there is no delay, useANIMATION.NO_DELAY - repeat -
{Number}repeat the animation (yes/no). Keywords:LOOP- repeat,ANIMATION.NO_LOOP- do not repeat - type -
{Number}tweener, the animation calculation type. Available calculation types:- IR.LINEAR = 0;
- IR.SINE_IN = 1;
- IR.SINE_OUT = 2;
- IR.SINE_IN_OUT = 3;
- IR.QUINT_IN = 4;
- IR.QUINT_OUT = 5;
- IR.QUINT_IN_OUT = 6;
- IR.QUART_IN = 7;
- IR.QUART_OUT = 8;
- IR.QUART_IN_OUT = 9;
- IR.QUAD_IN = 10;
- IR.QUAD_OUT = 11;
- IR.QUAD_IN_OUT = 12;
- IR.EXPO_IN = 13;
- IR.EXPO_OUT = 14;
- IR.EXPO_IN_OUT = 15;
- IR.ELASTIC_IN = 16;
- IR.ELASTIC_OUT = 17;
- IR.ELASTIC_IN_OUT = 18;
- IR.CUBIC_IN = 19;
- IR.CUBIC_OUT = 20;
- IR.CUBIC_IN_OUT = 21;
- IR.CIRC_IN = 22;
- IR.CIRC_OUT = 23;
- IR.CIRC_IN_OUT = 24;
- IR.BOUNCE_IN = 25;
- IR.BOUNCE_OUT = 26;
- IR.BOUNCE_IN_OUT = 27;
- IR.IR.BACK_IN = 28;
- IR.BACK_OUT = 29;
- IR.BACK_IN_OUT = 30;
- startCallBack -
{Function}callback invoked when the animation starts - endCallBack -
{Function}callback invoked when the animation finishes - context -
{Object}execution context for the callbacks
Player control
- Player.stop() - ends the animation and disables looping until restarted
- Player.pause() - pauses the animation
- Player.restart() - restarts the animation after stop
- Player.play() - resumes the animation after pause
- Player.nextFrame() - advances to the next frame while paused
- Player.prevFrame() - moves to the previous frame while paused
Controlling all animations together
- ANIMATION.stopAll() - ends all animations and disables looping until restarted
- ANIMATION.pauseAll() - pauses all animations
- ANIMATION.restartAll() - restarts all animations after stop
- ANIMATION.playAll() - resumes all animations after pause
- ANIMATION.nextFrameAll() - advances to the next frame while paused
- ANIMATION.prevFrameAll() - moves to the previous frame while paused
Example
download:
example of using the library (*.irpz)
var Home_main = IR.GetItem("Home Page");
function Open_Home()
{
ANIMATION(
[ANIMATION.Show(), ANIMATION.ScaleXY(0.8, 0.2)],
[Home_main.GetItem("B1")],
200,
ANIMATION.NO_DELAY,
ANIMATION.NO_LOOP,
IR.CIRC_OUT
);
ANIMATION(
[ANIMATION.Show(), ANIMATION.MoveVertical(1164, 980)],
[Home_main.GetItem("Item 3")],
400,
ANIMATION.NO_DELAY,
ANIMATION.NO_LOOP,
IR.QUART_OUT
);
ANIMATION(
[ANIMATION.Show(), ANIMATION.MoveHorizontal(360, -220)],
Home_main.GetItem("t1"),
200,
ANIMATION.NO_DELAY,
ANIMATION.NO_LOOP,
IR.QUART_OUT
);
ANIMATION(
ANIMATION.Show(),
Home_main.GetItem("i1"),
200,
ANIMATION.NO_DELAY,
ANIMATION.NO_LOOP,
IR.CIRC_OUT
);
ANIMATION(
[ANIMATION.Value(0, 78)],
[Home_main.GetItem("v1")],
500,
ANIMATION.NO_DELAY,
ANIMATION.NOT_LOOP,
IR.CIRC_OUT
);
ANIMATION(
[ANIMATION.MoveHorizontal(116, -100)],
[Home_main.GetItem("Zone Name")],
700,
ANIMATION.NO_DELAY,
ANIMATION.NO_LOOP,
IR.CIRC_OUT
);
function animationStartCallBack(){
IR.Log("Start " + this.Name);
}
function animationEndCallBack(){
IR.Log("End " + this.Name);
}
var Player1 = ANIMATION(
ANIMATION.Rotate(360),
[IR.GetItem("Page 1").GetItem(0), IR.GetItem("Page 1").GetItem(1)],
1000,
1000,
ANIMATION.LOOP,
IR.LINEAR,
animationStartCallBack,
animationEndCallBack,
{
Name: "Animation 1"
}
);
}
IR.AddListener(IR.EVENT_START, 0, Open_Home);
Methods
IR.CreateEffect
Create an effect and use it in an effect group when showing or hiding a popup.
This method is the basis of the ready-made animation library , which can be applied to popups and graphic items in your project.
Syntax
IR.CreateEffect(effect).property
| Input | Value | Description |
|---|---|---|
| effect | type: object effect typeIR.EFFECT_FADE - smooth appearance / disappearanceIR.EFFECT_ROTATE - rotation around the central axisIR.EFFECT_SCALE - enlargement / reductionIR.EFFECT_SLIDE - movement in from or out to a side*IR.EFFECT_TVSCAN - horizontal compression | |
| property | type: object effect properties* Group - effect-group number to which the effect is added. Numbers starting at 1000 are recommended to avoid affecting effect groups created by the editor* Delay (ms) - delay before the effect* Duration (ms) - effect duration* Tween - calculation formula; see the list of formulas | |
| Output | ||
| effect | type: object effect reference to store in a variable |
Example
IR.AddListener(IR.EVENT_START, 0, function()
{
// create effect, add in variable
var Fade = IR.CreateEffect(IR.EFFECT_FADE);
Fade.Group = 1000; // assign number of group
Fade.Delay = 0; // choose delay
Fade.Duration = 400; // choose duration of effect
Fade.Tween = 0; // choose tweener
// show popup with created effect
IR.ShowPopup("Popup 1", 1000)
});
This method is the basis of the ready-made animation library
When using EFFECT_SLIDE, configure the additional SlideType parameter.
Available values and their corresponding editor values:
- SLIDE_TYPE_LEFT - 0 - Left
- SLIDE_TYPE_RIGHT - 1 - Right
- SLIDE_TYPE_TOP - 2 - Top
- SLIDE_TYPE_BOTTOM - 3 - Bottom
- SLIDE_TYPE_CROP_LEFT - 4 - Left out
- SLIDE_TYPE_CROP_RIGHT - 5 - Right out
- SLIDE_TYPE_CROP_TOP - 6 - top out
- SLIDE_TYPE_CROP_BOTTOM - 7 - bottom out
Example:
IR.AddListener(IR.EVENT_START, 0, function()
{
// create effect, add in variable
var slideEffect = IR.CreateEffect(IR.EFFECT_SLIDE);
slideEffect.Group = 1000;
slideEffect.Delay = 0;
slideEffect.Duration = 400;
slideEffect.Tween = IR.TWEEN_SINE_IN_OUT;
slideEffect.SlideType = 0;
});
IR.Tween
Calculates an intermediate variable value using a formula over the specified interval. Builds an animation curve for a popup's appearance
Syntax
IR.Tween(formula, step_number, begin, end, steps)
| Input | Value | Description |
|---|---|---|
| formula | IR.TWEEN_LINEAR | type: object calculation formula name from the formula list |
| begin | 0 | type: number start of the calculation range |
| end | 100 | type: number amount by which to change the range |
| steps | 255 | type: number number of parts (calculation steps) into which to divide the specified range |
| Output | ||
| number | 50 | type: number returned value |
Example
IR.AddListener(IR.EVENT_START, 0, function()
{
var value1 = IR.Tween(IR.TWEEN_LINEAR, 126, 0, 100, 255);
IR.Log(value1); // 50
var value2 = IR.Tween(IR.TWEEN_LINEAR, 50, 0, 255, 100);
IR.Log(value2); // 126
});
var timer = 0;
LeftTween("Popup 1", 20, 852, 400); // popup, X, Y, moving range
function LeftTween(popup, X, Y, range)
{
IR.ShowPopup(popup); // show popup
IR.GetItem(popup).Y = Y; // position by Y
var Tm = IR.SetInterval(1, function(){ // change coordinate X in interval of 1 ms
var speed = 20; // showing speed
timer++;
var Tween = IR.Tween(IR.TWEEN_LINEAR, timer, 0, range, speed); // calculate Tweener
IR.GetItem(popup).X = X+Tween; // set coordinate by X
if (timer > speed) {IR.ClearInterval(Tm); timer = 0;} // delete interval when finished
});
}
Visual representation of value recalculation:

Calculation formulas
The formula determines how intermediate values are calculated over the selected interval. Each formula has a number to pass to IR.Tween as its first parameter:

Formula names and numbers:
- IR.TWEEN_LINEAR: 0
- IR.TWEEN_SINE_IN: 1
- IR.TWEEN_SINE_OUT: 2
- IR.TWEEN_SINE_IN_OUT: 3
- IR.TWEEN_QUINT_IN: 4
- IR.TWEEN_QUINT_OUT: 5
- IR.TWEEN_QUINT_IN_OUT: 6
- IR.TWEEN_QUART_IN: 7
- IR.TWEEN_QUART_OUT: 8
- IR.TWEEN_QUART_IN_OUT: 9
- IR.TWEEN_QUAD_IN: 10
- IR.TWEEN_QUAD_OUT: 11
- IR.TWEEN_QUAD_IN_OUT: 12
- IR.TWEEN_EXPO_IN: 13
- IR.TWEEN_EXPO_OUT: 14
- IR.TWEEN_EXPO_IN_OUT: 15
- IR.TWEEN_ELASTIC_IN: 16
- IR.TWEEN_ELASTIC_OUT: 17
- IR.TWEEN_ELASTIC_IN_OUT: 18
- IR.TWEEN_CUBIC_IN: 19
- IR.TWEEN_CUBIC_OUT: 20
- IR.TWEEN_CUBIC_IN_OUT: 21
- IR.TWEEN_CIRC_IN: 22
- IR.TWEEN_CIRC_OUT: 23
- IR.TWEEN_CIRC_IN_OUT: 24
- IR.TWEEN_BOUNCE_IN: 25
- IR.TWEEN_BOUNCE_OUT: 26
- IR.TWEEN_BOUNCE_IN_OUT: 27
- IR.TWEEN_BACK_IN: 28
- IR.TWEEN_BACK_OUT: 29
- IR.TWEEN_BACK_IN_OUT: 30