MCPcopy
hub / github.com/greensock/GSAP / getProgressData

Function getProgressData

esm/utils/paths.js:580–654  ·  view source on GitHub ↗
(rawPath, progress, decoratee, pushToNextIfAtEnd)

Source from the content-addressed store, hash-verified

578} // returns an object {path, segment, segIndex, i, t}
579
580function getProgressData(rawPath, progress, decoratee, pushToNextIfAtEnd) {
581 decoratee = decoratee || {};
582 rawPath.totalLength || cacheRawPathMeasurements(rawPath);
583
584 if (progress < 0 || progress > 1) {
585 progress = _wrapProgress(progress);
586 }
587
588 var segIndex = 0,
589 segment = rawPath[0],
590 samples,
591 resolution,
592 length,
593 min,
594 max,
595 i,
596 t;
597
598 if (!progress) {
599 t = i = segIndex = 0;
600 segment = rawPath[0];
601 } else if (progress === 1) {
602 t = 1;
603 segIndex = rawPath.length - 1;
604 segment = rawPath[segIndex];
605 i = segment.length - 8;
606 } else {
607 if (rawPath.length > 1) {
608 //speed optimization: most of the time, there's only one segment so skip the recursion.
609 length = rawPath.totalLength * progress;
610 max = i = 0;
611
612 while ((max += rawPath[i++].totalLength) < length) {
613 segIndex = i;
614 }
615
616 segment = rawPath[segIndex];
617 min = max - segment.totalLength;
618 progress = (length - min) / (max - min) || 0;
619 }
620
621 samples = segment.samples;
622 resolution = segment.resolution; //how many samples per cubic bezier chunk
623
624 length = segment.totalLength * progress;
625 i = segment.lookup.length ? segment.lookup[~~(length / segment.minLength)] || 0 : _getSampleIndex(samples, length, progress);
626 min = i ? samples[i - 1] : 0;
627 max = samples[i];
628
629 if (max < length) {
630 min = max;
631 max = samples[++i];
632 }
633
634 t = 1 / resolution * ((length - min) / (max - min) + i % resolution);
635 i = ~~(i / resolution) * 6;
636
637 if (pushToNextIfAtEnd && t === 1) {

Callers 2

getRotationAtProgressFunction · 0.70
sliceRawPathFunction · 0.70

Calls 3

cacheRawPathMeasurementsFunction · 0.70
_wrapProgressFunction · 0.70
_getSampleIndexFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…