MCPcopy
hub / github.com/alyssaxuu/motionity / newKeyframe

Function newKeyframe

src/js/functions.js:2173–2306  ·  view source on GitHub ↗
(property, object, time, value, render)

Source from the content-addressed store, hash-verified

2171
2172// Create a keyframe
2173function newKeyframe(property, object, time, value, render) {
2174 // Check if property can be animated
2175 if (
2176 $.inArray(
2177 property,
2178 objects.find((x) => x.id == object.get('id')).animate
2179 ) != -1
2180 ) {
2181 const keyarr = $.grep(keyframes, function (e) {
2182 return (
2183 e.t == parseFloat(time) &&
2184 e.id == object.get('id') &&
2185 e.name == property
2186 );
2187 });
2188 const keyarr2 = $.grep(keyframes, function (e) {
2189 return e.id == object.get('id') && e.name == property;
2190 });
2191 if (keyarr2.length == 0) {
2192 if (property == 'left') {
2193 objects
2194 .find((x) => x.id == object.get('id'))
2195 .defaults.find((x) => x.name == property).value =
2196 object.get(property) - artboard.get('left');
2197 } else if (property == 'top') {
2198 objects
2199 .find((x) => x.id == object.get('id'))
2200 .defaults.find((x) => x.name == property).value =
2201 object.get(property) - artboard.get('top');
2202 } else {
2203 objects
2204 .find((x) => x.id == object.get('id'))
2205 .defaults.find((x) => x.name == property).value = value;
2206 }
2207 }
2208 if (keyarr.length == 0) {
2209 if (property == 'left') {
2210 keyframes.push({
2211 t: time,
2212 name: property,
2213 value: value - artboard.get('left'),
2214 id: object.get('id'),
2215 easing: 'linear',
2216 });
2217 } else if (property == 'top') {
2218 keyframes.push({
2219 t: time,
2220 name: property,
2221 value: value - artboard.get('top'),
2222 id: object.get('id'),
2223 easing: 'linear',
2224 });
2225 } else {
2226 keyframes.push({
2227 t: time,
2228 name: property,
2229 value: value,
2230 id: object.get('id'),

Callers 11

updateObjectValuesFunction · 0.85
init.jsFile · 0.85
alignObjectFunction · 0.85
autoKeyframeFunction · 0.85
keyframeChangesFunction · 0.85
manualKeyframeFunction · 0.85
toggleAnimateFunction · 0.85
animatePropFunction · 0.85
cropFunction · 0.85
copyKeyframesFunction · 0.85
updateKeyframeFunction · 0.85

Calls 3

renderKeyframeFunction · 0.85
updateKeyframeFunction · 0.85
$Function · 0.50

Tested by

no test coverage detected