coily 0.4.0 → 0.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +2 -4
- package/dist/index.js +2 -4
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -116,15 +116,13 @@ var createSpringImpl = (initial, config, options) => {
|
|
|
116
116
|
emit("update:state", state);
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
|
-
const tension = -config.tension * 1e-6;
|
|
120
|
-
const friction = -config.friction * 1e-3;
|
|
121
119
|
const simulate = (deltaTime) => {
|
|
122
120
|
if (state === "moving") {
|
|
123
121
|
const iterations = Math.ceil(deltaTime);
|
|
124
122
|
for (let n = 0; n < iterations; n++) {
|
|
125
123
|
const previousDelta = value - target;
|
|
126
|
-
const springForce = tension * previousDelta;
|
|
127
|
-
const dampingForce = friction * velocity;
|
|
124
|
+
const springForce = -config.tension * 1e-6 * previousDelta;
|
|
125
|
+
const dampingForce = -config.friction * 1e-3 * velocity;
|
|
128
126
|
const acceleration = (springForce + dampingForce) / config.mass;
|
|
129
127
|
velocity = velocity + acceleration;
|
|
130
128
|
value = value + velocity;
|
package/dist/index.js
CHANGED
|
@@ -78,15 +78,13 @@ var createSpringImpl = (initial, config, options) => {
|
|
|
78
78
|
emit("update:state", state);
|
|
79
79
|
}
|
|
80
80
|
};
|
|
81
|
-
const tension = -config.tension * 1e-6;
|
|
82
|
-
const friction = -config.friction * 1e-3;
|
|
83
81
|
const simulate = (deltaTime) => {
|
|
84
82
|
if (state === "moving") {
|
|
85
83
|
const iterations = Math.ceil(deltaTime);
|
|
86
84
|
for (let n = 0; n < iterations; n++) {
|
|
87
85
|
const previousDelta = value - target;
|
|
88
|
-
const springForce = tension * previousDelta;
|
|
89
|
-
const dampingForce = friction * velocity;
|
|
86
|
+
const springForce = -config.tension * 1e-6 * previousDelta;
|
|
87
|
+
const dampingForce = -config.friction * 1e-3 * velocity;
|
|
90
88
|
const acceleration = (springForce + dampingForce) / config.mass;
|
|
91
89
|
velocity = velocity + acceleration;
|
|
92
90
|
value = value + velocity;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "coily",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Simulate values using spring physics",
|
|
5
5
|
"author": "Tim Morris <timthewebguy@gmail.com>",
|
|
6
6
|
"homepage": "https://github.com/tkofh/coily#readme",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"url": "https://github.com/tkofh/coily/issues"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
|
-
"@vitest/ui": "^0.
|
|
41
|
+
"@vitest/ui": "^0.30.0",
|
|
42
42
|
"tsup": "^6.7.0",
|
|
43
|
-
"vitest": "^0.
|
|
43
|
+
"vitest": "^0.30.0"
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"mitt": "^3.0.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "f9abbda0b74187ce13a07638458df845c5b51ec6"
|
|
49
49
|
}
|