@micromag/screen-urbania-article 0.3.246 → 0.3.250

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/index.js CHANGED
@@ -4,7 +4,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
4
  import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProperties';
5
5
  import { getJSON } from '@folklore/fetch';
6
6
  import PropTypes from 'prop-types';
7
- import React, { useMemo, useCallback, useState, useEffect } from 'react';
7
+ import React, { useMemo, useState, useCallback, useEffect } from 'react';
8
8
  import { isTextFilled, getStyleFromColor } from '@micromag/core/utils';
9
9
  import _defineProperty from '@babel/runtime/helpers/defineProperty';
10
10
  import classNames from 'classnames';
@@ -178,6 +178,7 @@ var UrbaniaArticle = function UrbaniaArticle(_ref) {
178
178
  backgroundColor = _ref2$color === void 0 ? null : _ref2$color;
179
179
 
180
180
  var _useViewerWebView = useViewerWebView(),
181
+ openedWebView = _useViewerWebView.opened,
181
182
  openWebView = _useViewerWebView.open;
182
183
 
183
184
  var _useViewerContext = useViewerContext(),
@@ -231,14 +232,29 @@ var UrbaniaArticle = function UrbaniaArticle(_ref) {
231
232
  url = _ref5$url === void 0 ? null : _ref5$url;
232
233
 
233
234
  var hasImage = url !== null;
234
- var backgroundPlaying = current && (isView || isEdit);
235
235
  var mediaShouldLoad = current || active;
236
- var hasCallToAction = callToAction !== null && callToAction.active === true;
236
+ var hasCallToAction = callToAction !== null && callToAction.active === true; // const backgroundPlaying = current && (isView || isEdit);
237
+
238
+ var _useState = useState(false),
239
+ _useState2 = _slicedToArray(_useState, 2),
240
+ backgroundPlaying = _useState2[0],
241
+ setBackgroundPlaying = _useState2[1];
242
+
237
243
  var playIfCurrent = useCallback(function () {
238
- if (current && !playing) {
244
+ if (current && !openedWebView && !playing) {
239
245
  setPlaying(true);
246
+ } else {
247
+ setPlaying(false);
248
+ }
249
+ }, [current, openedWebView, playing, setPlaying]); // TODO: link playIfCurrent and backgroundPlaying
250
+
251
+ useEffect(function () {
252
+ if (!current) {
253
+ setBackgroundPlaying(false);
254
+ } else if (current && (isView || isEdit)) {
255
+ setBackgroundPlaying(!openedWebView);
240
256
  }
241
- }, [current, playing, setPlaying]);
257
+ }, [current, isView, isEdit, openedWebView, setBackgroundPlaying]);
242
258
  useDebounce(playIfCurrent, current, 500);
243
259
 
244
260
  var _ref6 = background || {},
package/lib/index.js CHANGED
@@ -199,6 +199,7 @@ var UrbaniaArticle = function UrbaniaArticle(_ref) {
199
199
  backgroundColor = _ref2$color === void 0 ? null : _ref2$color;
200
200
 
201
201
  var _useViewerWebView = contexts.useViewerWebView(),
202
+ openedWebView = _useViewerWebView.opened,
202
203
  openWebView = _useViewerWebView.open;
203
204
 
204
205
  var _useViewerContext = contexts.useViewerContext(),
@@ -252,14 +253,29 @@ var UrbaniaArticle = function UrbaniaArticle(_ref) {
252
253
  url = _ref5$url === void 0 ? null : _ref5$url;
253
254
 
254
255
  var hasImage = url !== null;
255
- var backgroundPlaying = current && (isView || isEdit);
256
256
  var mediaShouldLoad = current || active;
257
- var hasCallToAction = callToAction !== null && callToAction.active === true;
257
+ var hasCallToAction = callToAction !== null && callToAction.active === true; // const backgroundPlaying = current && (isView || isEdit);
258
+
259
+ var _useState = React.useState(false),
260
+ _useState2 = _slicedToArray__default["default"](_useState, 2),
261
+ backgroundPlaying = _useState2[0],
262
+ setBackgroundPlaying = _useState2[1];
263
+
258
264
  var playIfCurrent = React.useCallback(function () {
259
- if (current && !playing) {
265
+ if (current && !openedWebView && !playing) {
260
266
  setPlaying(true);
267
+ } else {
268
+ setPlaying(false);
269
+ }
270
+ }, [current, openedWebView, playing, setPlaying]); // TODO: link playIfCurrent and backgroundPlaying
271
+
272
+ React.useEffect(function () {
273
+ if (!current) {
274
+ setBackgroundPlaying(false);
275
+ } else if (current && (isView || isEdit)) {
276
+ setBackgroundPlaying(!openedWebView);
261
277
  }
262
- }, [current, playing, setPlaying]);
278
+ }, [current, isView, isEdit, openedWebView, setBackgroundPlaying]);
263
279
  hooks.useDebounce(playIfCurrent, current, 500);
264
280
 
265
281
  var _ref6 = background || {},
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/screen-urbania-article",
3
- "version": "0.3.246",
3
+ "version": "0.3.250",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -53,7 +53,7 @@
53
53
  "@folklore/size": "^0.1.20",
54
54
  "@micromag/core": "^0.3.246",
55
55
  "@micromag/element-background": "^0.3.246",
56
- "@micromag/element-call-to-action": "^0.3.246",
56
+ "@micromag/element-call-to-action": "^0.3.250",
57
57
  "@micromag/element-closed-captions": "^0.3.246",
58
58
  "@micromag/element-container": "^0.3.246",
59
59
  "@micromag/element-heading": "^0.3.246",
@@ -73,5 +73,5 @@
73
73
  "publishConfig": {
74
74
  "access": "public"
75
75
  },
76
- "gitHead": "473a4ad55684e54d3f1e62e760792ed6e003f8e7"
76
+ "gitHead": "f0c7716e6a78f4c0025594b668e669f0baf5286d"
77
77
  }