Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@ All notable changes to this project are documented in this file.

This project follows Semantic Versioning.

## [0.1.4] - 2026-02-16

### Fixed

- Fixed paused animation behavior when calling `start()` again. It now resumes from the paused point instead of jumping directly to the final value.

## [0.1.2] - 2026-02-16

### Changed
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ counters.update([100, 250, 999]);

### Instância (1 elemento)

Métodos: `start()`, `pause()`, `resume()`, `stop()`, `reset()`, `set(value)`, `update(nextEnd, nextOptions?)`, `destroy()`
Métodos: `start()` (inicia ou retoma se pausado), `pause()`, `resume()`, `stop()`, `reset()`, `set(value)`, `update(nextEnd, nextOptions?)`, `destroy()`

Getters: `value`, `running`, `paused`

Expand Down
12 changes: 11 additions & 1 deletion dist/counterup.esm.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* @nullsablex/counter-up v0.1.3 | Author: NullSablex | https://github.com/NullSablex/counter-up.git | MIT License */
/* @nullsablex/counter-up v0.1.4 | Author: NullSablex | https://github.com/NullSablex/counter-up.git | MIT License */
const easings = {
linear: (t) => t,
easeInOutQuad: (t) => (t < 0.5 ? 2 * t * t : 1 - Math.pow(-2 * t + 2, 2) / 2),
Expand Down Expand Up @@ -177,6 +177,12 @@ function createCounterInstance(element, userOptions = {}, index = 0) {
}

function start() {
if (state.isPaused) {
return resume();
}
if (state.isRunning) {
return api;
}
return play(options.start, options.end);
}

Expand All @@ -185,13 +191,17 @@ function createCounterInstance(element, userOptions = {}, index = 0) {
cancelFrame();
state.isRunning = false;
state.isPaused = true;
// Keep elapsed progress, but force startTime recalculation on resume.
state.startTime = null;
return api;
}

function resume() {
if (!state.isPaused || state.destroyed) return api;
state.isRunning = true;
state.isPaused = false;
// Re-anchor startTime using the saved elapsed time.
state.startTime = null;
state.rafId = requestAnimationFrame(animate);
return api;
}
Expand Down
6 changes: 4 additions & 2 deletions dist/counterup.esm.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion dist/counterup.umd.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* @nullsablex/counter-up v0.1.3 | Author: NullSablex | https://github.com/NullSablex/counter-up.git | MIT License */
/* @nullsablex/counter-up v0.1.4 | Author: NullSablex | https://github.com/NullSablex/counter-up.git | MIT License */
(function (global, factory) {
if (typeof module === "object" && typeof module.exports === "object") {
module.exports = factory();
Expand Down Expand Up @@ -185,6 +185,12 @@
}

function start() {
if (state.isPaused) {
return resume();
}
if (state.isRunning) {
return api;
}
return play(options.start, options.end);
}

Expand All @@ -193,13 +199,17 @@
cancelFrame();
state.isRunning = false;
state.isPaused = true;
// Keep elapsed progress, but force startTime recalculation on resume.
state.startTime = null;
return api;
}

function resume() {
if (!state.isPaused || state.destroyed) return api;
state.isRunning = true;
state.isPaused = false;
// Re-anchor startTime using the saved elapsed time.
state.startTime = null;
state.rafId = requestAnimationFrame(animate);
return api;
}
Expand Down
Loading
Loading