@micromag/element-video 0.3.105 → 0.3.108
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 +11 -8
- package/lib/index.js +11 -8
- package/package.json +5 -5
package/es/index.js
CHANGED
|
@@ -2,7 +2,6 @@ import _objectWithoutProperties from '@babel/runtime/helpers/objectWithoutProper
|
|
|
2
2
|
import _defineProperty from '@babel/runtime/helpers/defineProperty';
|
|
3
3
|
import _objectSpread from '@babel/runtime/helpers/objectSpread2';
|
|
4
4
|
import classNames from 'classnames';
|
|
5
|
-
import 'lodash';
|
|
6
5
|
import PropTypes$1 from 'prop-types';
|
|
7
6
|
import React, { useMemo, useEffect, useRef } from 'react';
|
|
8
7
|
import { PropTypes } from '@micromag/core';
|
|
@@ -25,6 +24,7 @@ var propTypes = {
|
|
|
25
24
|
loop: PropTypes$1.bool,
|
|
26
25
|
playsInline: PropTypes$1.bool,
|
|
27
26
|
preload: PropTypes$1.oneOf(['auto', 'metadata', 'none', null]),
|
|
27
|
+
shouldLoad: PropTypes$1.bool,
|
|
28
28
|
withoutCors: PropTypes$1.bool,
|
|
29
29
|
className: PropTypes$1.string,
|
|
30
30
|
onReady: PropTypes$1.func,
|
|
@@ -50,6 +50,7 @@ var defaultProps = {
|
|
|
50
50
|
loop: false,
|
|
51
51
|
playsInline: true,
|
|
52
52
|
preload: 'auto',
|
|
53
|
+
shouldLoad: true,
|
|
53
54
|
withoutCors: false,
|
|
54
55
|
className: null,
|
|
55
56
|
onReady: null,
|
|
@@ -78,6 +79,7 @@ var Video = function Video(_ref) {
|
|
|
78
79
|
loop = _ref.loop,
|
|
79
80
|
playsInline = _ref.playsInline,
|
|
80
81
|
preload = _ref.preload,
|
|
82
|
+
shouldLoad = _ref.shouldLoad,
|
|
81
83
|
withoutCors = _ref.withoutCors,
|
|
82
84
|
className = _ref.className,
|
|
83
85
|
onReady = _ref.onReady,
|
|
@@ -221,33 +223,34 @@ var Video = function Video(_ref) {
|
|
|
221
223
|
useEffect(function () {
|
|
222
224
|
var _ref$current = ref.current,
|
|
223
225
|
videoElement = _ref$current === void 0 ? null : _ref$current;
|
|
224
|
-
var canLoad = preload !== 'none' && preload !== 'metadata';
|
|
226
|
+
var canLoad = preload !== 'none' && preload !== 'metadata' && shouldLoad; // @todo
|
|
227
|
+
|
|
225
228
|
var preloadHasChanged = firstPreloadRef.current !== preload;
|
|
226
229
|
|
|
227
230
|
if (canLoad && preloadHasChanged && !hasLoadedRef.current && videoElement !== null && typeof videoElement.load !== 'undefined') {
|
|
228
231
|
hasLoadedRef.current = true;
|
|
229
232
|
videoElement.load();
|
|
230
233
|
}
|
|
231
|
-
}, [preload]);
|
|
234
|
+
}, [shouldLoad, preload]);
|
|
232
235
|
return /*#__PURE__*/React.createElement("div", {
|
|
233
236
|
className: classNames([styles.container, (_ref7 = {}, _defineProperty(_ref7, className, className !== null), _defineProperty(_ref7, styles.paused, !playing), _defineProperty(_ref7, styles.withSize, withSize), _ref7)]),
|
|
234
237
|
style: withSize ? {
|
|
235
238
|
width: width,
|
|
236
239
|
height: height
|
|
237
240
|
} : null
|
|
238
|
-
}, isImageWithoutSourceFile ? /*#__PURE__*/React.createElement("img", {
|
|
241
|
+
}, isImageWithoutSourceFile && shouldLoad ? /*#__PURE__*/React.createElement("img", {
|
|
239
242
|
src: mediaUrl,
|
|
240
243
|
alt: description,
|
|
241
244
|
className: styles.video
|
|
242
|
-
}) : /*#__PURE__*/React.createElement("video", {
|
|
245
|
+
}) : null, !isImageWithoutSourceFile ? /*#__PURE__*/React.createElement("video", {
|
|
243
246
|
key: mediaUrl,
|
|
244
247
|
ref: ref,
|
|
245
248
|
src: sourceFiles === null ? mediaUrl : null,
|
|
246
249
|
autoPlay: autoPlay,
|
|
247
250
|
loop: loop,
|
|
248
251
|
muted: muted,
|
|
249
|
-
poster: thumbnailUrl,
|
|
250
|
-
preload: preload,
|
|
252
|
+
poster: shouldLoad ? thumbnailUrl : null,
|
|
253
|
+
preload: shouldLoad ? preload : 'metadata',
|
|
251
254
|
playsInline: playsInline,
|
|
252
255
|
crossOrigin: withoutCors ? 'anonymous' : null,
|
|
253
256
|
tabIndex: focusable ? '0' : '-1',
|
|
@@ -260,7 +263,7 @@ var Video = function Video(_ref) {
|
|
|
260
263
|
src: sourceUrl,
|
|
261
264
|
type: sourceMime
|
|
262
265
|
});
|
|
263
|
-
})));
|
|
266
|
+
})) : null);
|
|
264
267
|
};
|
|
265
268
|
|
|
266
269
|
Video.propTypes = propTypes;
|
package/lib/index.js
CHANGED
|
@@ -4,7 +4,6 @@ var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProp
|
|
|
4
4
|
var _defineProperty = require('@babel/runtime/helpers/defineProperty');
|
|
5
5
|
var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
|
|
6
6
|
var classNames = require('classnames');
|
|
7
|
-
require('lodash');
|
|
8
7
|
var PropTypes = require('prop-types');
|
|
9
8
|
var React = require('react');
|
|
10
9
|
var core = require('@micromag/core');
|
|
@@ -36,6 +35,7 @@ var propTypes = {
|
|
|
36
35
|
loop: PropTypes__default["default"].bool,
|
|
37
36
|
playsInline: PropTypes__default["default"].bool,
|
|
38
37
|
preload: PropTypes__default["default"].oneOf(['auto', 'metadata', 'none', null]),
|
|
38
|
+
shouldLoad: PropTypes__default["default"].bool,
|
|
39
39
|
withoutCors: PropTypes__default["default"].bool,
|
|
40
40
|
className: PropTypes__default["default"].string,
|
|
41
41
|
onReady: PropTypes__default["default"].func,
|
|
@@ -61,6 +61,7 @@ var defaultProps = {
|
|
|
61
61
|
loop: false,
|
|
62
62
|
playsInline: true,
|
|
63
63
|
preload: 'auto',
|
|
64
|
+
shouldLoad: true,
|
|
64
65
|
withoutCors: false,
|
|
65
66
|
className: null,
|
|
66
67
|
onReady: null,
|
|
@@ -89,6 +90,7 @@ var Video = function Video(_ref) {
|
|
|
89
90
|
loop = _ref.loop,
|
|
90
91
|
playsInline = _ref.playsInline,
|
|
91
92
|
preload = _ref.preload,
|
|
93
|
+
shouldLoad = _ref.shouldLoad,
|
|
92
94
|
withoutCors = _ref.withoutCors,
|
|
93
95
|
className = _ref.className,
|
|
94
96
|
onReady = _ref.onReady,
|
|
@@ -232,33 +234,34 @@ var Video = function Video(_ref) {
|
|
|
232
234
|
React.useEffect(function () {
|
|
233
235
|
var _ref$current = ref.current,
|
|
234
236
|
videoElement = _ref$current === void 0 ? null : _ref$current;
|
|
235
|
-
var canLoad = preload !== 'none' && preload !== 'metadata';
|
|
237
|
+
var canLoad = preload !== 'none' && preload !== 'metadata' && shouldLoad; // @todo
|
|
238
|
+
|
|
236
239
|
var preloadHasChanged = firstPreloadRef.current !== preload;
|
|
237
240
|
|
|
238
241
|
if (canLoad && preloadHasChanged && !hasLoadedRef.current && videoElement !== null && typeof videoElement.load !== 'undefined') {
|
|
239
242
|
hasLoadedRef.current = true;
|
|
240
243
|
videoElement.load();
|
|
241
244
|
}
|
|
242
|
-
}, [preload]);
|
|
245
|
+
}, [shouldLoad, preload]);
|
|
243
246
|
return /*#__PURE__*/React__default["default"].createElement("div", {
|
|
244
247
|
className: classNames__default["default"]([styles.container, (_ref7 = {}, _defineProperty__default["default"](_ref7, className, className !== null), _defineProperty__default["default"](_ref7, styles.paused, !playing), _defineProperty__default["default"](_ref7, styles.withSize, withSize), _ref7)]),
|
|
245
248
|
style: withSize ? {
|
|
246
249
|
width: width,
|
|
247
250
|
height: height
|
|
248
251
|
} : null
|
|
249
|
-
}, isImageWithoutSourceFile ? /*#__PURE__*/React__default["default"].createElement("img", {
|
|
252
|
+
}, isImageWithoutSourceFile && shouldLoad ? /*#__PURE__*/React__default["default"].createElement("img", {
|
|
250
253
|
src: mediaUrl,
|
|
251
254
|
alt: description,
|
|
252
255
|
className: styles.video
|
|
253
|
-
}) : /*#__PURE__*/React__default["default"].createElement("video", {
|
|
256
|
+
}) : null, !isImageWithoutSourceFile ? /*#__PURE__*/React__default["default"].createElement("video", {
|
|
254
257
|
key: mediaUrl,
|
|
255
258
|
ref: ref,
|
|
256
259
|
src: sourceFiles === null ? mediaUrl : null,
|
|
257
260
|
autoPlay: autoPlay,
|
|
258
261
|
loop: loop,
|
|
259
262
|
muted: muted,
|
|
260
|
-
poster: thumbnailUrl,
|
|
261
|
-
preload: preload,
|
|
263
|
+
poster: shouldLoad ? thumbnailUrl : null,
|
|
264
|
+
preload: shouldLoad ? preload : 'metadata',
|
|
262
265
|
playsInline: playsInline,
|
|
263
266
|
crossOrigin: withoutCors ? 'anonymous' : null,
|
|
264
267
|
tabIndex: focusable ? '0' : '-1',
|
|
@@ -271,7 +274,7 @@ var Video = function Video(_ref) {
|
|
|
271
274
|
src: sourceUrl,
|
|
272
275
|
type: sourceMime
|
|
273
276
|
});
|
|
274
|
-
})));
|
|
277
|
+
})) : null);
|
|
275
278
|
};
|
|
276
279
|
|
|
277
280
|
Video.propTypes = propTypes;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-video",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.108",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -52,9 +52,9 @@
|
|
|
52
52
|
"@fortawesome/fontawesome-svg-core": "^1.2.32",
|
|
53
53
|
"@fortawesome/free-solid-svg-icons": "^5.15.1",
|
|
54
54
|
"@fortawesome/react-fontawesome": "^0.1.13",
|
|
55
|
-
"@micromag/core": "^0.3.
|
|
56
|
-
"@micromag/element-closed-captions": "^0.3.
|
|
57
|
-
"@micromag/element-media-controls": "^0.3.
|
|
55
|
+
"@micromag/core": "^0.3.108",
|
|
56
|
+
"@micromag/element-closed-captions": "^0.3.108",
|
|
57
|
+
"@micromag/element-media-controls": "^0.3.108",
|
|
58
58
|
"classnames": "^2.2.6",
|
|
59
59
|
"prop-types": "^15.7.2",
|
|
60
60
|
"react-intl": "^5.12.1",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"publishConfig": {
|
|
64
64
|
"access": "public"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "d7681b84be82b08eff5ed444f910ed367f235f4e"
|
|
67
67
|
}
|