我正在使用Greensock并尝试从存储的JSON数据中实现CustomEase。我遇到的问题是,当您向时间轴添加内容时,您必须这样做:
mainTimeline.to(target, duration, vars);
which would look like this:
mainTimeline.to($(".target", 1, {"opacity":"0","y":"35"});
我遇到的问题是,如果你想使用缓动,它必须包含在“vars”对象中,如下所示:
mainTimeline.to(
$(".target", 1, {
"opacity":"0",
"y":"35",
"ease": CustomEase.create('custom','M0,0,C0.104,0.204,0.492,1,1,1')
});
我遇到的问题是,当我将数据存储在JSON中时,我可以将其存储为字符串,但是当我将其插入到变量中时,它不会执行,因为它将其视为:
"CustomEase.create('custom','M0,0,C0.104,0.204,0.492,1,1,1')"
但是,如果我将它存储为没有引号的函数,那么存储的是从函数返回的数据:
{
"_calcEnd": true,
"id": "custom",
"data": "M0,0,C0.104,0.204,0.492,1,1,1",
"lookup": [
{
"x": 0,
"cx": 0.017543859649122806,
"y": 0,
"cy": 0.0345276089301892,
"nx": 9
},
[...]
{
"x": 0.017543859649122806,
"cx": 0.017543859649122806,
"y": 0.0345276089301892,
"cy": 0.03419683114613436,
"nx": 9
}
],
"points": [
{
"x": 0,
"y": 0,
"cx": 0.022788085937499997,
"cy": 0.0448486328125,
"n": {
"x": 0.022788085937499997,
"y": 0.0448486328125,
"cx": 0.029204101562499998,
"cy": 0.05669042968749999,
"n": {
"x": 0.051992187499999995,
"y": 0.10153906249999999,
"cx": 0.0353798828125,
"cy": 0.06649902343749999,
},
[...]
"nx": 0.0873720703125
},
"nx": 0.051992187499999995
},
"nx": 0.022788085937499997
},
null,
null,
[...]
null
],
"fast": true,
"rawBezier": [
"0",
"0",
"0.104",
"0.204",
"0.492",
"1",
"1",
"1"
],
"l": 57
}"
如何将这些数据存储在将要执行的JSON中,直到Greensock函数在没有引号的情况下调用它为止:
mainTimeline.to(
$(".target", 1, {
"opacity":"0",
"y":"35",
"ease": CustomEase.create('custom','M0,0,C0.104,0.204,0.492,1,1,1')
});