()
| 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 |
no test coverage detected