I have the following GASP animation:
$(function () {
var tmax_options = {
repeat: -1
};
var tmax_tl = new TimelineMax(tmax_options),
tween_options_to = {
css: {
rotation: 360,
transformOrigin: 'center center'
},
ease: Cubic.Linear,
force3D: true
};
// Last Argument is Position Timing.
// Use this argument to stagger the visibility of surrounding circles
tmax_tl.to($('svg > path'), 10, tween_options_to, 0)
.to($('svg > #XMLID_26_'), 5, tween_options_to, 0)
.to($('svg > #XMLID_23_'), 70, tween_options_to, 0)
.to($('svg > #XMLID_20_'), 65, tween_options_to, 0);
});
FIDDLE HERE
Now what I wanted to happen in the above animation is that the outermost polygons should rotate (they are found in total). All 4 should rotate at different speeds and should rotate continuously without stopping.
As of now my animation code looks like the following:
tmax_tl.to($('svg > path'), 10, tween_options_to, 0)
.to($('svg > #XMLID_26_'), 5, tween_options_to, 0)
.to($('svg > #XMLID_23_'), 70, tween_options_to, 0)
.to($('svg > #XMLID_20_'), 65, tween_options_to, 0);
As you can see the duration are different: 10,5,70,65
. Now the longest animation does't stop, but the shorter animations stop and and then start again at some point. How can I stop this? i.e., how do I make the animations such that the rotation for all the circles are the continuous without stopping?
The animation-duration CSS property defines the length of time (in seconds or milliseconds) that an animation takes to complete one cycle of animation.
The animation-duration CSS property sets the length of time that an animation takes to complete one cycle. It is often convenient to use the shorthand property animation to set all animation properties at once. The time that an animation takes to complete one cycle.
Default value for the animation-duration property is 0, which means that the animation starts immediately and the keyframes don’t have an effect. Negative values are invalid and they cause the property to be ignored. But they may be considered as equal to 0s by some earlier implementations.
The animation-duration property defines the length of time (in seconds or milliseconds) that an animation takes to complete its one cycle. Very often the animation shorthand property is used to set all animation properties at once.
The problem is that GSAP will only restart the loop if all animations in a TimelineMax
object have stopped. Thus, you will need one TimelineMax
object per gear:
$(() => {
const tweenOptions = {
css: {
rotation: 360,
transformOrigin: "center center"
},
ease: Linear.easeNone,
force3D: true
};
const timelines = [];
for (let i = 0; i < 4; ++i) {
timelines.push(new TimelineMax({
repeat: -1
}));
}
timelines[0].to($("svg > path"), 10, tweenOptions, 0);
timelines[1].to($("svg > #XMLID_26_"), 5, tweenOptions, 0)
timelines[2].to($("svg > #XMLID_23_"), 70, tweenOptions, 0)
timelines[3].to($("svg > #XMLID_20_"), 65, tweenOptions, 0);
});
Also, make sure to use Linear.easeNone
if you want the speed of the animation to stay constant.
You can check out a demo here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With