@micromag/viewer 0.3.803 → 0.3.804

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.
Files changed (2) hide show
  1. package/es/index.js +58 -53
  2. package/package.json +2 -2
package/es/index.js CHANGED
@@ -3021,6 +3021,8 @@ var Viewer = function Viewer(_ref) {
3021
3021
  mediaCompleted = _usePlaybackContext$c3 === void 0 ? false : _usePlaybackContext$c3,
3022
3022
  _usePlaybackContext$i = _usePlaybackContext.isBackground,
3023
3023
  isBackgroundVideo = _usePlaybackContext$i === void 0 ? false : _usePlaybackContext$i,
3024
+ _usePlaybackContext$m2 = _usePlaybackContext.mediaRef,
3025
+ playbackMediaRef = _usePlaybackContext$m2 === void 0 ? null : _usePlaybackContext$m2,
3024
3026
  _usePlaybackContext$s = _usePlaybackContext.setMuted,
3025
3027
  setMuted = _usePlaybackContext$s === void 0 ? null : _usePlaybackContext$s;
3026
3028
  var playbackHelpVisible = useMemo(function () {
@@ -3173,7 +3175,10 @@ var Viewer = function Viewer(_ref) {
3173
3175
  setPointerDownTime(null);
3174
3176
  }, [screenIndex]);
3175
3177
  useEffect(function () {
3176
- if (pointerDownTime === null || !playing) {
3178
+ var _ref1 = playbackMediaRef.current || {},
3179
+ mediaTagName = _ref1.tagName;
3180
+ var mediaIsVideo = mediaTagName === 'VIDEO';
3181
+ if (pointerDownTime === null || !playing || !mediaIsVideo) {
3177
3182
  return function () {};
3178
3183
  }
3179
3184
  var interval = setTimeout(function () {
@@ -3187,22 +3192,22 @@ var Viewer = function Viewer(_ref) {
3187
3192
  var onPointerDown = useCallback(function () {
3188
3193
  setPointerDownTime(Date.now());
3189
3194
  }, []);
3190
- var onTap = useCallback(function (_ref1) {
3191
- var currentTarget = _ref1.currentTarget,
3192
- event = _ref1.event,
3193
- target = _ref1.target,
3194
- _ref1$xy = _slicedToArray(_ref1.xy, 2),
3195
- x = _ref1$xy[0],
3196
- y = _ref1$xy[1],
3197
- elapsedTime = _ref1.elapsedTime,
3198
- _ref1$args = _slicedToArray(_ref1.args, 1),
3199
- bindState = _ref1$args[0];
3195
+ var onTap = useCallback(function (_ref10) {
3196
+ var currentTarget = _ref10.currentTarget,
3197
+ event = _ref10.event,
3198
+ target = _ref10.target,
3199
+ _ref10$xy = _slicedToArray(_ref10.xy, 2),
3200
+ x = _ref10$xy[0],
3201
+ y = _ref10$xy[1],
3202
+ elapsedTime = _ref10.elapsedTime,
3203
+ _ref10$args = _slicedToArray(_ref10.args, 1),
3204
+ bindState = _ref10$args[0];
3200
3205
  setPointerDownTime(null);
3201
- var _ref10 = bindState || {},
3202
- _ref10$playing = _ref10.playing,
3203
- currentPlaying = _ref10$playing === void 0 ? false : _ref10$playing,
3204
- _ref10$longPressPause = _ref10.longPressPaused,
3205
- currentLongPressPaused = _ref10$longPressPause === void 0 ? false : _ref10$longPressPause;
3206
+ var _ref11 = bindState || {},
3207
+ _ref11$playing = _ref11.playing,
3208
+ currentPlaying = _ref11$playing === void 0 ? false : _ref11$playing,
3209
+ _ref11$longPressPause = _ref11.longPressPaused,
3210
+ currentLongPressPaused = _ref11$longPressPause === void 0 ? false : _ref11$longPressPause;
3206
3211
  if (!currentPlaying && currentLongPressPaused) {
3207
3212
  setPlaying(true);
3208
3213
  setLongPressPaused(false);
@@ -3223,12 +3228,12 @@ var Viewer = function Viewer(_ref) {
3223
3228
  y: y
3224
3229
  });
3225
3230
  }, [interactWithScreen, screenIndex, tapMaximumDuration]);
3226
- var computeScreenProgress = useCallback(function (_ref11) {
3227
- var active = _ref11.active,
3228
- _ref11$movement = _slicedToArray(_ref11.movement, 1),
3229
- mx = _ref11$movement[0],
3230
- _ref11$velocity = _slicedToArray(_ref11.velocity, 1),
3231
- vx = _ref11$velocity[0];
3231
+ var computeScreenProgress = useCallback(function (_ref12) {
3232
+ var active = _ref12.active,
3233
+ _ref12$movement = _slicedToArray(_ref12.movement, 1),
3234
+ mx = _ref12$movement[0],
3235
+ _ref12$velocity = _slicedToArray(_ref12.velocity, 1),
3236
+ vx = _ref12$velocity[0];
3232
3237
  var p = mx / screenContainerWidth; // drag "ratio": how much of the screen width has been swiped?
3233
3238
  var forwards = mx < 0; // true if swiping to left (to navigate forwards)
3234
3239
  var newIndex = !forwards ? screenIndex - 1 : screenIndex + 1; // which item index are we moving towards?
@@ -3241,15 +3246,15 @@ var Viewer = function Viewer(_ref) {
3241
3246
  }
3242
3247
  return screenIndex - progress;
3243
3248
  }, [screenContainerWidth, screenIndex]);
3244
- var onScreenProgress = useCallback(function (progress, _ref12) {
3245
- var active = _ref12.active,
3246
- _ref12$args = _slicedToArray(_ref12.args, 1),
3247
- bindState = _ref12$args[0];
3248
- var _ref13 = bindState || {},
3249
- _ref13$playing = _ref13.playing,
3250
- currentPlaying = _ref13$playing === void 0 ? false : _ref13$playing,
3251
- _ref13$longPressPause = _ref13.longPressPaused,
3252
- currentLongPressPaused = _ref13$longPressPause === void 0 ? false : _ref13$longPressPause;
3249
+ var onScreenProgress = useCallback(function (progress, _ref13) {
3250
+ var active = _ref13.active,
3251
+ _ref13$args = _slicedToArray(_ref13.args, 1),
3252
+ bindState = _ref13$args[0];
3253
+ var _ref14 = bindState || {},
3254
+ _ref14$playing = _ref14.playing,
3255
+ currentPlaying = _ref14$playing === void 0 ? false : _ref14$playing,
3256
+ _ref14$longPressPause = _ref14.longPressPaused,
3257
+ currentLongPressPaused = _ref14$longPressPause === void 0 ? false : _ref14$longPressPause;
3253
3258
  if (!active && !currentPlaying && currentLongPressPaused) {
3254
3259
  setPlaying(true);
3255
3260
  setLongPressPaused(false);
@@ -3355,11 +3360,11 @@ var Viewer = function Viewer(_ref) {
3355
3360
  menuDotsContainerRef = _useDimensionObserver3.ref,
3356
3361
  _useDimensionObserver4 = _useDimensionObserver3.height,
3357
3362
  menuDotsContainerHeight = _useDimensionObserver4 === void 0 ? 0 : _useDimensionObserver4;
3358
- var onClickScreen = useCallback(function (_ref14) {
3359
- var itemScreenId = _ref14.screenId;
3363
+ var onClickScreen = useCallback(function (_ref15) {
3364
+ var itemScreenId = _ref15.screenId;
3360
3365
  onInteractionPrivate();
3361
- var index = screens.findIndex(function (_ref15) {
3362
- var id = _ref15.id;
3366
+ var index = screens.findIndex(function (_ref16) {
3367
+ var id = _ref16.id;
3363
3368
  return id === itemScreenId;
3364
3369
  });
3365
3370
  changeIndex(index);
@@ -3430,26 +3435,26 @@ var Viewer = function Viewer(_ref) {
3430
3435
  _useState12 = _slicedToArray(_useState11, 2),
3431
3436
  shareIncentiveVisible = _useState12[0],
3432
3437
  setShareIncentiveVisible = _useState12[1];
3433
- var _ref16 = currentScreen || {},
3434
- _ref16$header = _ref16.header,
3435
- header = _ref16$header === void 0 ? null : _ref16$header;
3436
- var _ref17 = header || {},
3437
- _ref17$shareIncentive = _ref17.shareIncentive,
3438
- shareIncentive = _ref17$shareIncentive === void 0 ? null : _ref17$shareIncentive;
3439
- var _ref18 = shareIncentive || {},
3440
- _ref18$active = _ref18.active,
3441
- hasShareIncentive = _ref18$active === void 0 ? false : _ref18$active,
3442
- _ref18$label = _ref18.label,
3443
- shareIncentiveLabel = _ref18$label === void 0 ? null : _ref18$label;
3444
- var _ref19 = currentShareIncentive || {},
3438
+ var _ref17 = currentScreen || {},
3439
+ _ref17$header = _ref17.header,
3440
+ header = _ref17$header === void 0 ? null : _ref17$header;
3441
+ var _ref18 = header || {},
3442
+ _ref18$shareIncentive = _ref18.shareIncentive,
3443
+ shareIncentive = _ref18$shareIncentive === void 0 ? null : _ref18$shareIncentive;
3444
+ var _ref19 = shareIncentive || {},
3445
+ _ref19$active = _ref19.active,
3446
+ hasShareIncentive = _ref19$active === void 0 ? false : _ref19$active,
3445
3447
  _ref19$label = _ref19.label,
3446
- currentShareIncentiveLabel = _ref19$label === void 0 ? null : _ref19$label;
3447
- var _ref20 = shareIncentiveLabel || {},
3448
- _ref20$body = _ref20.body,
3449
- incentiveLabel = _ref20$body === void 0 ? null : _ref20$body;
3450
- var _ref21 = currentShareIncentiveLabel || {},
3448
+ shareIncentiveLabel = _ref19$label === void 0 ? null : _ref19$label;
3449
+ var _ref20 = currentShareIncentive || {},
3450
+ _ref20$label = _ref20.label,
3451
+ currentShareIncentiveLabel = _ref20$label === void 0 ? null : _ref20$label;
3452
+ var _ref21 = shareIncentiveLabel || {},
3451
3453
  _ref21$body = _ref21.body,
3452
- currentIncentiveLabel = _ref21$body === void 0 ? null : _ref21$body;
3454
+ incentiveLabel = _ref21$body === void 0 ? null : _ref21$body;
3455
+ var _ref22 = currentShareIncentiveLabel || {},
3456
+ _ref22$body = _ref22.body,
3457
+ currentIncentiveLabel = _ref22$body === void 0 ? null : _ref22$body;
3453
3458
  useEffect(function () {
3454
3459
  setShareIncentiveVisible(true);
3455
3460
  if (hasShareIncentive && shareIncentiveLabel !== currentShareIncentiveLabel) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/viewer",
3
- "version": "0.3.803",
3
+ "version": "0.3.804",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -91,5 +91,5 @@
91
91
  "access": "public",
92
92
  "registry": "https://registry.npmjs.org/"
93
93
  },
94
- "gitHead": "b8d7486367da5144fa0824e48527c44aa4123ddf"
94
+ "gitHead": "0a4e4a1bf65af4345c0f1d97d0a1443f8946bcfc"
95
95
  }