physics-animator 0.15.0 → 0.15.2

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/README.md CHANGED
@@ -24,7 +24,7 @@ useSpringValue(
24
24
  Or via state
25
25
 
26
26
  ```tsx
27
- const opacity = useSpringState({ initial: 0, target: 1, duration_s: 0.8 })
27
+ const { state: opacity, setTarget } = useSpringState({ initial: 0, duration_s: 0.8 })
28
28
 
29
29
  return <div style={{ opacity }} />
30
30
  ```
@@ -88,6 +88,9 @@ class Animator {
88
88
  });
89
89
  return listener;
90
90
  }
91
+ /**
92
+ * Execute a callback when a specific field of an object is changed by the animator
93
+ */
91
94
  onChangeField(object, field, callback) {
92
95
  // check if field is an object
93
96
  if (typeof object[field] === 'object' && object[field] !== null) {
@@ -100,6 +103,9 @@ class Animator {
100
103
  return this.addChangeFieldListener(object, field, callback);
101
104
  }
102
105
  }
106
+ /**
107
+ * Execute a callback when the object or any of its sub-objects is changed by the animator
108
+ */
103
109
  onChange(object, callback) {
104
110
  // add a listener for this object and every sub-object
105
111
  const removeCallbacks = new Array();
@@ -116,7 +122,7 @@ class Animator {
116
122
  objectChanged = true;
117
123
  };
118
124
  enumerateObjects(object, (subObject) => {
119
- let signal = this.changeObjectEvents.get(object);
125
+ let signal = this.changeObjectEvents.get(subObject);
120
126
  if (signal == null) {
121
127
  signal = new event_signal_1.EventSignal();
122
128
  this.changeObjectEvents.set(subObject, signal);
@@ -125,7 +131,7 @@ class Animator {
125
131
  removeCallbacks.push(() => {
126
132
  subListener.remove();
127
133
  if (!signal.hasListeners()) {
128
- this.changeObjectEvents.delete(object);
134
+ this.changeObjectEvents.delete(subObject);
129
135
  }
130
136
  });
131
137
  });
@@ -83,6 +83,9 @@ export class Animator {
83
83
  });
84
84
  return listener;
85
85
  }
86
+ /**
87
+ * Execute a callback when a specific field of an object is changed by the animator
88
+ */
86
89
  onChangeField(object, field, callback) {
87
90
  // check if field is an object
88
91
  if (typeof object[field] === 'object' && object[field] !== null) {
@@ -95,6 +98,9 @@ export class Animator {
95
98
  return this.addChangeFieldListener(object, field, callback);
96
99
  }
97
100
  }
101
+ /**
102
+ * Execute a callback when the object or any of its sub-objects is changed by the animator
103
+ */
98
104
  onChange(object, callback) {
99
105
  // add a listener for this object and every sub-object
100
106
  const removeCallbacks = new Array();
@@ -111,7 +117,7 @@ export class Animator {
111
117
  objectChanged = true;
112
118
  };
113
119
  enumerateObjects(object, (subObject) => {
114
- let signal = this.changeObjectEvents.get(object);
120
+ let signal = this.changeObjectEvents.get(subObject);
115
121
  if (signal == null) {
116
122
  signal = new EventSignal();
117
123
  this.changeObjectEvents.set(subObject, signal);
@@ -120,7 +126,7 @@ export class Animator {
120
126
  removeCallbacks.push(() => {
121
127
  subListener.remove();
122
128
  if (!signal.hasListeners()) {
123
- this.changeObjectEvents.delete(object);
129
+ this.changeObjectEvents.delete(subObject);
124
130
  }
125
131
  });
126
132
  });
@@ -68,9 +68,15 @@ export declare class Animator {
68
68
  }) => void;
69
69
  remove: () => void;
70
70
  };
71
+ /**
72
+ * Execute a callback when a specific field of an object is changed by the animator
73
+ */
71
74
  onChangeField<Obj, Name extends keyof Obj>(object: Obj, field: Name, callback: (object: Obj, field: Name) => void): {
72
75
  remove: () => void;
73
76
  };
77
+ /**
78
+ * Execute a callback when the object or any of its sub-objects is changed by the animator
79
+ */
74
80
  onChange<Obj>(object: Obj, callback: (object: Obj) => void): {
75
81
  remove: () => void;
76
82
  };
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "physics-animator",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "author": "haxiomic (George Corney)",
5
5
  "license": "MIT",
6
6
  "description": "A TypeScript animation system grounded in physics with three.js and react support.",
7
+ "homepage": "https://github.com/haxiomic/physics-animator",
8
+ "bugs": "https://github.com/haxiomic/physics-animator/issues",
9
+ "repository": "github:haxiomic/physics-animator",
7
10
  "keywords": [
8
11
  "physics",
9
12
  "animation",