@micromag/core 0.3.588 → 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/components.js CHANGED
@@ -3683,6 +3683,7 @@ var propTypes$9 = {
3683
3683
  screenState: PropTypes$1.string,
3684
3684
  index: PropTypes$1.number,
3685
3685
  active: PropTypes$1.bool,
3686
+ preload: PropTypes$1.bool,
3686
3687
  current: PropTypes$1.bool,
3687
3688
  component: PropTypes$1.node,
3688
3689
  components: PropTypes.components,
@@ -3695,6 +3696,7 @@ var defaultProps$9 = {
3695
3696
  screenState: null,
3696
3697
  index: null,
3697
3698
  current: false,
3699
+ preload: true,
3698
3700
  component: null,
3699
3701
  components: null,
3700
3702
  className: null,
@@ -3707,6 +3709,7 @@ var Screen = function Screen(_ref) {
3707
3709
  index = _ref.index,
3708
3710
  active = _ref.active,
3709
3711
  current = _ref.current,
3712
+ preload = _ref.preload,
3710
3713
  components = _ref.components,
3711
3714
  component = _ref.component,
3712
3715
  className = _ref.className,
@@ -3727,6 +3730,7 @@ var Screen = function Screen(_ref) {
3727
3730
  index: index,
3728
3731
  active: active,
3729
3732
  current: current,
3733
+ preload: preload,
3730
3734
  mediaRef: mediaRef
3731
3735
  }))) : /*#__PURE__*/React.createElement("div", {
3732
3736
  className: className
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.588",
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": "c2ec51edbaf9bb6c78bbaf7996b2ad0fd1651993"
147
+ "gitHead": "aee5033c29da327111287f71fd59cb77f469306a"
148
148
  }