Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update dependencies and fix calculations with FPS differences #20

Merged
merged 5 commits into from
Apr 21, 2022
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
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

## Unreleased

# 0.3.1 (March 29, 2022)
## 1.0.0 (April 21, 2022)
* Bumped promise version to v4.0 ([@chriscerie](https://github.com/chriscerie) in [#20](https://github.com/chriscerie/roact-spring/pull/20))
* Bumped roact-hooks version to v0.4 ([@chriscerie](https://github.com/chriscerie) in [#20](https://github.com/chriscerie/roact-spring/pull/20))
* Fixed calculations not responding to fps differences ([@chriscerie](https://github.com/chriscerie) in [#20](https://github.com/chriscerie/roact-spring/pull/20))

## 0.3.1 (March 29, 2022)
* Fixed an issue where duration-based anims would always start from the same position

## 0.3.0 (March 29, 2022)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@rbxts/roact-spring",
"version": "0.3.1-ts.0",
"version": "1.0.0-ts.0",
"description": "A modern spring-physics based animation library for Roact inspired by react-spring",
"main": "src/init.lua",
"typings": "src/index.d.ts",
Expand Down
9 changes: 4 additions & 5 deletions src/SpringValue.lua
Original file line number Diff line number Diff line change
Expand Up @@ -218,8 +218,7 @@ function SpringValue:advance(dt: number)
-- When `true`, the value is increasing over time
local isGrowing = if from == to then _v0 > 0 else from < to

local step = 1 -- 1ms
local numSteps = math.ceil(dt / step) * 10
local numSteps = math.ceil(dt * 1000 / 2)
for _ = 0, numSteps do
local isMoving = math.abs(velocity) > restVelocity

Expand All @@ -229,7 +228,7 @@ function SpringValue:advance(dt: number)
break
end
end

if canBounce then
local isBouncing = position == to or position > to == isGrowing

Expand All @@ -244,8 +243,8 @@ function SpringValue:advance(dt: number)
local dampingForce = -config.friction * 0.001 * velocity
local acceleration = (springForce + dampingForce) / config.mass -- pt/ms^2

velocity = velocity + acceleration * step -- pt/ms
position = position + velocity * step
velocity = velocity + acceleration -- pt/ms
position = position + velocity
end
end

Expand Down
6 changes: 3 additions & 3 deletions wally.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[package]
name = "chriscerie/roact-spring"
description = "A modern spring-physics based animation library for Roact inspired by react-spring"
version = "0.3.1"
version = "1.0.0"
license = "MIT"
authors = ["chriscerie"]
registry = "https://github.com/UpliftGames/wally-index"
realm = "shared"

[dependencies]
Roact = "roblox/roact@^1"
Promise = "evaera/promise@^3.2"
Hooks = "kampfkarren/roact-hooks@^0.3"
Promise = "evaera/promise@^4.0"
Hooks = "kampfkarren/roact-hooks@^0.4"
TestEZ = "roblox/testez@^0.4"