OptionalprogressRafLoop: Function
Optional function to be called on each progress update event.
Similar to easeTo but applied a smoothdamp instead.
Eases the progress to a target value. Until that value is reached, the progressRafLoop is called.
The progress to get to.
The amount to ease. This gets calculated as per RAF, how much of the difference between the current value and target should the current value be updated by. Therefore, 1 would mean no ease. 0.1 would mean a lot of ease.
An optional easing funciton. Defaults to linear.
Prevent progress clamping. Allows values outside range of 0-1.
Gets the lerp delta - the difference between the current ease and the targetEase (where it should be if it caught up).
Gets the current scroll direction. 1 is down scroll, -1 is up scroll and 0 is no scroll (when progress is catching up).
Run calculations. Normally. you would call easeTo to set the latest current progress, you may want to call this if forced stopped and want to restart the raf loop manually.
Sets the current progress. This forces an immediate update to the passed progress.
Sets the FPS of the internal raf loop.
Sets the precision. Precision is used to check how closely the current progress is versus the previous progress per RAF cycle. The lower the number, the less precise.
Use a lower number if you want want to improve performance since it will result in calling Raf fewer times.
Force stops running calculations.
Removes a progress listener.
Removes a given
Adds a progress listener.
Sets a callback for a specific range.
A class that runs Raf for a limited time while a given progress (a value between 0-1) eases. This class is useful because instead of constanlty runnig raf, it will only run RAF when a progress value is unstable. This class also allows you to register and listen for specific progress values and run callbacks (IE: run a callback when the progress crosses 0.5).
Example WITHOUT RafProgress: Consider the following example to understand what RafProgress does. Here we are using an html range input to represent Progress but progresss could be a window scroll, duration, mouse position etc.....a percentage amount:
Here you can see that on each RAF cycle, we check the value of the range and get the progress. We then apply an ease to that progress and then do something within the RAF loop based on the current progress.
This works but the problem is that RAF is constantly running and even if the value of progress is the same as the last raf loop, we still are running RAf and perhaps layout thrashing or performning unncessary calcs.
Example WITH RafProgress The above is simplied with this class.
Progress Callbacks
Raf progress additionally allows you to register and listen specific progress values and run a callback.
No Inherit Doc