Jump to content
GreenSock

Tween

.repeat()

.repeat( value:Number ) : *

Gets or sets the number of times that the tween should repeat after its first iteration.

Parameters

value: Number

(default = 0) — Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining.

Returns : *

Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining.

Details

Gets or sets the number of times that the tween should repeat after its first iteration. For example, if repeat is 1, the tween will play a total of twice (the initial play plus 1 repeat). To repeat indefinitely, use -1. repeat should always be an integer.

To cause the repeats to alternate between forward and backward, set yoyo to true. To add a time gap between repeats, use repeatDelay. You can set the initial repeat value via the vars parameter, like: gsap.to(obj, {duration: 1, x: 100, repeat: 2});

This method serves as both a getter and setter. Omitting the parameter returns the current value (getter), whereas defining the parameter sets the value (setter) and returns the instance itself for easier chaining, like myTween.repeat(2).yoyo(true).play();

  1. var progress = myTween.progress(); //gets current progress
  2. myTween.progress( 0.25 ); //sets progress to one quarter finished
Copyright 2017, GreenSock. All rights reserved. This work is subject to theterms of useor for Club GreenSock members, the software agreement that was issued with the membership.
×