MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / animate

Function animate

scripts/magnify_image.js:1293–1311  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

1291
1292 let run = true;
1293 function animate() {
1294 let updated = false;
1295 let updatedValue = {};
1296 for (let prop in animTarget) {
1297 const currentValue = parseFloat(element.style[prop]);
1298 const targetValue = animTarget[prop];
1299 let del = Math.abs(targetValue - currentValue);
1300
1301 if (del > 0.1) {
1302 const newValue =
1303 del < 1 ? targetValue : lerp(currentValue, targetValue, lerpSpeed);
1304 element.style[prop] = newValue + "px";
1305 updatedValue[prop] = newValue;
1306 updated = true;
1307 }
1308 }
1309 if (updated) onUpdateCallback?.(updatedValue);
1310 if (run) requestAnimationFrame(animate);
1311 }
1312
1313 animate();
1314

Callers 1

enableDragAndZoomFunction · 0.70

Calls 1

lerpFunction · 0.85

Tested by

no test coverage detected