@micromag/core 0.3.589 → 0.3.590
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/es/hooks.js +24 -4
- package/package.json +2 -2
package/es/hooks.js
CHANGED
|
@@ -209,14 +209,25 @@ function useDragProgress() {
|
|
|
209
209
|
} : _ref$dragOptions;
|
|
210
210
|
var refDragging = useRef(false);
|
|
211
211
|
var refProgress = useRef(wantedProgress);
|
|
212
|
+
var wantedProgressRef = useRef(wantedProgress);
|
|
213
|
+
if (wantedProgress !== wantedProgressRef.current) {
|
|
214
|
+
wantedProgressRef.current = wantedProgress;
|
|
215
|
+
}
|
|
212
216
|
var _useState = useState(false),
|
|
213
217
|
_useState2 = _slicedToArray(_useState, 2),
|
|
214
218
|
dragging = _useState2[0],
|
|
215
219
|
setDragging = _useState2[1];
|
|
220
|
+
var _useState3 = useState(0),
|
|
221
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
222
|
+
direction = _useState4[0],
|
|
223
|
+
setDirection = _useState4[1];
|
|
216
224
|
var spring = useCallback(function () {
|
|
217
225
|
return _objectSpread({
|
|
218
226
|
progress: wantedProgress,
|
|
219
|
-
immediate: dragging || disabled
|
|
227
|
+
immediate: dragging || disabled,
|
|
228
|
+
onResolve: function onResolve() {
|
|
229
|
+
setDirection(0);
|
|
230
|
+
}
|
|
220
231
|
}, springParams);
|
|
221
232
|
}, [wantedProgress, disabled]);
|
|
222
233
|
var _useSpring = useSpring(spring),
|
|
@@ -241,13 +252,17 @@ function useDragProgress() {
|
|
|
241
252
|
}
|
|
242
253
|
var newProgress = computeProgress(gestureState);
|
|
243
254
|
refDragging.current = active;
|
|
255
|
+
setDirection(newProgress < wantedProgressRef.current ? -1 : 1);
|
|
244
256
|
refProgress.current = newProgress;
|
|
245
257
|
if (active !== dragging) {
|
|
246
258
|
setDragging(active);
|
|
247
259
|
}
|
|
248
260
|
api.start({
|
|
249
261
|
progress: newProgress,
|
|
250
|
-
immediate: active
|
|
262
|
+
immediate: active,
|
|
263
|
+
onResolve: !active ? function () {
|
|
264
|
+
setDirection(0);
|
|
265
|
+
} : function () {}
|
|
251
266
|
});
|
|
252
267
|
if (onProgress !== null) {
|
|
253
268
|
onProgress(newProgress, gestureState);
|
|
@@ -256,17 +271,22 @@ function useDragProgress() {
|
|
|
256
271
|
var bind = useDrag(onDrag, dragOptions);
|
|
257
272
|
useEffect(function () {
|
|
258
273
|
if (!refDragging.current && wantedProgress !== refProgress.current) {
|
|
274
|
+
setDirection(wantedProgress < refProgress.current ? -1 : 1);
|
|
259
275
|
refProgress.current = wantedProgress;
|
|
260
276
|
api.start({
|
|
261
277
|
progress: wantedProgress,
|
|
262
|
-
immediate: false
|
|
278
|
+
immediate: false,
|
|
279
|
+
onResolve: function onResolve() {
|
|
280
|
+
setDirection(0);
|
|
281
|
+
}
|
|
263
282
|
});
|
|
264
283
|
}
|
|
265
284
|
}, [wantedProgress]);
|
|
266
285
|
return {
|
|
267
286
|
bind: bind,
|
|
268
287
|
dragging: dragging,
|
|
269
|
-
progress: progress
|
|
288
|
+
progress: progress,
|
|
289
|
+
direction: direction
|
|
270
290
|
};
|
|
271
291
|
}
|
|
272
292
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.590",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "",
|
|
6
6
|
"keywords": [
|
|
@@ -144,5 +144,5 @@
|
|
|
144
144
|
"access": "public",
|
|
145
145
|
"registry": "https://registry.npmjs.org/"
|
|
146
146
|
},
|
|
147
|
-
"gitHead": "
|
|
147
|
+
"gitHead": "aee5033c29da327111287f71fd59cb77f469306a"
|
|
148
148
|
}
|