Get remaining reading time estimates in real-time
npm install --save estimatebower install --save estimateEstimates the reading time in seconds for a piece of text to be read completely.
estimate.text('........');
// <- 3Estimates reading time for a given element. Returns a small API.
estimate.element(document.body);
// <- { ... }Total duration in seconds to read the full article.
The progress percentage that's considered to be already read.
Duration in seconds that remains to read the rest of the article.
Call it through requestAnimationFrame to update the estimate. Updates calc.progress and calc.remaining.
var calc = estimate.element(document.body);
requestAnimationFrame(function refresh () {
calc.update();
time.innerText = calc.remaining;
requestAnimationFrame(refresh);
});Re-initialize the calculator whenever the text changes. Updates calc.total.
Caveat: At any given point, half of the height in the viewport is considered read.
MIT