controllerCircle
circle(x_radius, y_radius, x_center, y_center,
angle, init_angle, marked_angle,
duration, is_path, repeat_start_pos, register_actions,
half_step, spring_acc, spring_vdamp,
ease_type, ease_amount, ease_mirror)
circle.messages = [start, start_back, start_reverse, start_new, start_new_back, pos0, pos1]
circle.events = [start, half, end, cycle, mark,
start_back, half_back, end_back, cycle_back, mark_back, pos0, pos1]
Description
Performs a circular movement animation, moving the element in a circular orbit around a center onto the 2D plane. The last performed movement is remembered and at any time during or after it you can order performing it backwards or repeat it.
Applies one translate
transform.
The eliptical trajectory is described by x_radius
and y_radius
,
and its center is supplied by x_center
and y_center
.
The center coordinates are relative to the element's layout position.
If parameter is_path
is set (to true
),
then no translation is applied but its coordinates are kept for other controllers that read a 'path' from this controller.
Parameters
Visit page Controller # Common Parameters for documentation on the parameters, common to all controllers:
id
,
paused
and
disabled
.
Coordinate/Size Parameters: Note that all parameters representing screen coordinates or sizes also accept relative values as percentages of own/parent/viewport/document size or coordinates relative to own/parent/viewport/document's origin. For more information, visit page Controller # Coordinate Parameters.
Parameters of circle()
:
- duration
- Duration of the animation in milliseconds. Default value: 1000
- x_radius, y_radius
- Radiuses of the elliptical trajectory in the 2D plane. Default values: 50, 50
- x_center, y_center
- The elliptical trajectory's center coordinates in the 2D plane. Default values: 0, 0
- angle
-
Angle (in degrees) specifying the part of ellipse to travel.
Positive angles denote clockwise movement.
The starting position (angle) can be supplied with the
init_angle
parameter. Default value: 0 - init_angle
-
Set initial position (angle) onto the elliptical trajectory.
Note that the displacement will be applied immediately (when the controller is enabled), not waiting for the movement to be started with any of the
start
messages. Default value: 0 - marked_angle
-
If different than
-1
, then the controller will fire eventmark
each time the rotation passes through this absolute angle. Default value: -1 - is_path
-
If
true
, then the controller will not apply the translation tranform, but will keep the coordinates, so that other controllers can use them as a 'path'. Default value: false - repeat_start_pos
-
If
true
, then everystart
orstart_back
message will start a forward/reverse movement from the direction's starting position. Iffalse
(by default), then sending these messages when a movement is already started will continue the current movement (if already moving in the same direction), or will start a movement in the opposite direction, but continuing from the current position. This parameter has no effect on thestart_new
orstart_new_back
messages, as they start a new movement from the current position in all cases. Default value: false - register_actions
-
Tells whether to handle the element's
show
,hide
,show_immediately
andhide_immediately
actions.
Values:false
/true
/"500"
(i.e. react with 500 milliseconds delay) /"500 elm"
(i.e. set event handlers with delay 500ms for HTML element #elm's actions). Default value: false - half_step
-
If set to less than
1
, each frame the current angle will step closer to the required angle, where step =half_step
* distance_to_required_angle. Values in the range (0
-1
) make sense. Default value: 1 - spring_acc
-
If bigger than
0
, the animated angle will behave as if attached to a spring. Bigger values ofspring_acc
result in stronger pulling of the "spring" and faster motion (i.e. shorter spring period). Note that setting too high of a value will cause a self-amplifying spring motion of the animated angle. What is the highest value before the positive feedback kicks in depends on the value ofspring_vdamp
, but values up to2
are always safe. Default value: 0 - spring_vdamp
-
When spring motion is enabled via parameter
spring_acc
, every frame the current speed of the spring is multiplied by this parameter, effectively slowing the spring motion. Values between0
and1
are reasonable, where smaller values result in faster dying of the spring motion and a value of1
means absolute elasticity of the spring. Default value: 0.92 - ease_type
-
What kind of 'easing' to be applied on the movement.
Currently supported values:"linear"
- constant speed in all movement parts,"ease"
- slower start and end of movement, elliptical shape,"ease_in"
- slower start, fast and sudden end,"ease_out"
- fast and sudden start, slow end.
- ease_amount
-
Strength of 'easing' to be applied on the movement.
Values in the range (0
-1
] make sense, though values greater than1
(up to 2-3) can also be of use. Default value: 1 - ease_mirror
-
Tells if the easing applied on 'backwards' movement is the same as the forward easing, or mirrored.
If this parameter is set to
true
and parameterease_type
is"ease_in"
, then upon a backwards movement,"ease_out"
easing will be applied. Default value: false
Accepted Messages
Visit page Controller # Common Messages for documentation on the messages, accepted by all controllers:
pause
,
unpause
,
enable
,
disable
,
params
and
remove
.
Message Parameters: Note that along the message parameters specific to each message type, every message (not only params
) accepts as parameters any of the controller parameters,
which are set before the message is executed.
Messages accepted by circle()
:
- start
-
Starts a movement from the current angle to the target angle.
The message has no effect if already in the target angle or moving towards it.
If currently moving in the 'backwards' direction (from the target to the starting angle, ordered with messages
start_back
andstart_new_back
), then the movement direction will be switched to 'forwards' and the 'forward' movement will continue from the current position to the target position. Message params: none - start_back
- Starts a 'backwards' movement from the current angle to the starting angle of the current forward movement. The message has no effect if already in the starting angle or moving towards it. Message params: none
- start_reverse
- Start moving in the reverse direction within the current (or last) movement. Message params: none
- start_new
-
Same as the
start
message, but does not continue a current movement. It always starts a new movement from the current angle to the supplied target angle. Message params: none - start_new_back
-
Start the 'backwards' motion (i.e. starting from the target angle) of a new movement.
So, calling
controller.message('start_new_back', {angle: 20})
will cause the element to jump 20 deegrees clockwise and then start moving backwards to the current angle. Message params: none - pos0
- Position the element in the starting angle of the current movement immediately. Message params: none
- pos1
- Position the element in the target angle of the current movement immediately. Message params: none
Generated Events
Visit page Controller # Common Events for documentation on the events, generated by all controllers:
frame
,
remove
,
paused
,
unpaused
enabled
and
disabled
.
Events fired by circle()
:
- start
- Fired upon starting a (forward) movement, as long as not already on the target angle. Event params: none
- half
- Fired upon reaching the middle of the current (forward) movement. Event params: none
- end
- Fired upon reaching the end of the current (forward) movement. Event params: none
- cycle
-
When performing a movement of an
angle
greater in absolute value than 360 degrees, this event is fired upon passing every 360 degrees (full turn) counting from the starting angle of the movement. Event params: none - mark
-
If parameter
marked_angle
is supplied (i.e. is different than-1
), then this event is fired upon every passing of this marked angle. The value of the angle is absolute, and not relative to the starting angle for the movement. Event params: none - start_back
- Fired upon start of backwards movement. Event params: none
- half_back
- Fired upon reaching the middle of the current backwards movement. Event params: none
- end_back
- Fired upon reaching the end of the current backwards movement. Event params: none
- cycle_back
-
Same as the
cycle
event, but is fired when performing a 'backwards' movement. Note that the event is fired on every passing of the starting angle of the current 'forward' movement, not on every passing of 360 degrees counting from the start of the backwards movement. Event params: none - mark_back
-
Same as the
mark
event, but is fired when performing a 'backwards' movement. Event params: none - pos0
-
Fired upon reaching the starting angle when moving backwards, i.e. it is fired when
end_back
is fired. Event params: none - pos1
-
Fired upon reaching the target angle when moving forward, i.e. it is fired when
end
is fired. Event params: none
Interaction with DOM
- Transforms: Applies one
translate
transform. - CSS: Works with any styling. Does not set any style properties.
- Events: Does not set event listeners.
Changes Log
- Controller introduced in v.0.80