padEnd() V4
Pads a Number from the end with a string until the result reaches a given length or creates a padding Function with pre-defined totalLength and padString parameters.
const paddedValue = utils.padEnd(value, totalLength, padString);
const padderFunction = utils.padEnd(totalLength, padString);
Parameters
| Name | Accepts |
|---|---|
| value (opt) | String / Number |
| totalLength | Number |
| padString | String |
Returns
A String if a value is provided, otherwise a chain-able utility Function to pad numbers from the end:
const padTo5WithZeros = utils.padEnd(5, '0');
padTo5WithZeros('123'); // '12300'
padTo5WithZeros(78); // '78000'
padTo5WithZeros('1234'); // '12340'
const roundAndPadEnd = utils.round(0).padEnd(5, '0'); // Round to nearest integer then pad to 5 characters
roundAndPadEnd(123.456); // '12300'
roundAndPadEnd(7.8); // '80000' padEnd() code example
import { animate, utils } from 'animejs';
animate('.value', {
innerHTML: 1,
modifier: utils.round(3).padEnd(6, '-'),
duration: 100000,
ease: 'linear',
});
<div class="large row">
<pre class="large log row">
<span class="value lcd">0</span>
</pre>
</div>