@micromag/element-visual 0.3.311 → 0.3.322
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/assets/css/styles.css +1 -1
- package/es/index.js +34 -44
- package/lib/index.js +34 -44
- package/package.json +6 -6
package/assets/css/styles.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.micromag-element-visual-container{position:relative
|
|
1
|
+
.micromag-element-visual-container{overflow:hidden;position:relative}.micromag-element-visual-container .micromag-element-visual-videoContainer{overflow:hidden;position:absolute}
|
package/es/index.js
CHANGED
|
@@ -51,34 +51,31 @@ var defaultProps = {
|
|
|
51
51
|
imageClassName: null,
|
|
52
52
|
videoClassName: null
|
|
53
53
|
};
|
|
54
|
-
|
|
55
54
|
var Visual = function Visual(_ref) {
|
|
56
55
|
var media = _ref.media,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
56
|
+
mediaRef = _ref.mediaRef,
|
|
57
|
+
width = _ref.width,
|
|
58
|
+
height = _ref.height,
|
|
59
|
+
resolution = _ref.resolution,
|
|
60
|
+
objectFit = _ref.objectFit,
|
|
61
|
+
playing = _ref.playing,
|
|
62
|
+
muted = _ref.muted,
|
|
63
|
+
shouldLoad = _ref.shouldLoad,
|
|
64
|
+
videoLoop = _ref.videoLoop;
|
|
65
|
+
_ref.videoInitialMuted;
|
|
66
|
+
var onParentLoaded = _ref.onLoaded,
|
|
67
|
+
className = _ref.className,
|
|
68
|
+
imageClassName = _ref.imageClassName,
|
|
69
|
+
videoClassName = _ref.videoClassName,
|
|
70
|
+
withoutVideo = _ref.withoutVideo,
|
|
71
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
74
72
|
var _ref2 = media || {},
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
73
|
+
_ref2$type = _ref2.type,
|
|
74
|
+
type = _ref2$type === void 0 ? null : _ref2$type,
|
|
75
|
+
_ref2$thumbnail_url = _ref2.thumbnail_url,
|
|
76
|
+
thumbnailUrl = _ref2$thumbnail_url === void 0 ? null : _ref2$thumbnail_url,
|
|
77
|
+
_ref2$url = _ref2.url,
|
|
78
|
+
url = _ref2$url === void 0 ? null : _ref2$url;
|
|
82
79
|
var isVideo = type === 'video';
|
|
83
80
|
var elProps = useMemo(function () {
|
|
84
81
|
return _objectSpread(_objectSpread({}, props), {}, {
|
|
@@ -98,28 +95,23 @@ var Visual = function Visual(_ref) {
|
|
|
98
95
|
}) : tmpProps;
|
|
99
96
|
}, [isVideo, elProps, thumbnailUrl, url, shouldLoad]);
|
|
100
97
|
var videoContainerStyle = null;
|
|
101
|
-
|
|
102
98
|
if (type === 'video' && objectFit !== null && shouldLoad) {
|
|
103
99
|
var _ref3 = objectFit || {},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
100
|
+
_ref3$fit = _ref3.fit,
|
|
101
|
+
fit = _ref3$fit === void 0 ? 'cover' : _ref3$fit;
|
|
107
102
|
var _ref4 = media || {},
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
103
|
+
_ref4$metadata = _ref4.metadata,
|
|
104
|
+
videoMetadata = _ref4$metadata === void 0 ? null : _ref4$metadata;
|
|
111
105
|
var _ref5 = videoMetadata || {},
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
106
|
+
_ref5$width = _ref5.width,
|
|
107
|
+
videoWidth = _ref5$width === void 0 ? 0 : _ref5$width,
|
|
108
|
+
_ref5$height = _ref5.height,
|
|
109
|
+
videoHeight = _ref5$height === void 0 ? 0 : _ref5$height;
|
|
117
110
|
var _getSizeWithinBounds = getSizeWithinBounds(videoWidth, videoHeight, width, height, {
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
111
|
+
cover: fit === 'cover'
|
|
112
|
+
}),
|
|
113
|
+
resizedVideoWidth = _getSizeWithinBounds.width,
|
|
114
|
+
resizedVideoHeight = _getSizeWithinBounds.height;
|
|
123
115
|
var resizedVideoLeft = -(resizedVideoWidth - width) / 2;
|
|
124
116
|
var resizedVideoTop = -(resizedVideoHeight - height) / 2;
|
|
125
117
|
videoContainerStyle = {
|
|
@@ -129,7 +121,6 @@ var Visual = function Visual(_ref) {
|
|
|
129
121
|
top: resizedVideoTop
|
|
130
122
|
};
|
|
131
123
|
}
|
|
132
|
-
|
|
133
124
|
var onLoaded = useCallback(function (e) {
|
|
134
125
|
if (onParentLoaded !== null) {
|
|
135
126
|
onParentLoaded(e);
|
|
@@ -165,7 +156,6 @@ var Visual = function Visual(_ref) {
|
|
|
165
156
|
autoPlay: true
|
|
166
157
|
})))) : null) : null;
|
|
167
158
|
};
|
|
168
|
-
|
|
169
159
|
Visual.propTypes = propTypes;
|
|
170
160
|
Visual.defaultProps = defaultProps;
|
|
171
161
|
|
package/lib/index.js
CHANGED
|
@@ -64,34 +64,31 @@ var defaultProps = {
|
|
|
64
64
|
imageClassName: null,
|
|
65
65
|
videoClassName: null
|
|
66
66
|
};
|
|
67
|
-
|
|
68
67
|
var Visual = function Visual(_ref) {
|
|
69
68
|
var media = _ref.media,
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
69
|
+
mediaRef = _ref.mediaRef,
|
|
70
|
+
width = _ref.width,
|
|
71
|
+
height = _ref.height,
|
|
72
|
+
resolution = _ref.resolution,
|
|
73
|
+
objectFit = _ref.objectFit,
|
|
74
|
+
playing = _ref.playing,
|
|
75
|
+
muted = _ref.muted,
|
|
76
|
+
shouldLoad = _ref.shouldLoad,
|
|
77
|
+
videoLoop = _ref.videoLoop;
|
|
78
|
+
_ref.videoInitialMuted;
|
|
79
|
+
var onParentLoaded = _ref.onLoaded,
|
|
80
|
+
className = _ref.className,
|
|
81
|
+
imageClassName = _ref.imageClassName,
|
|
82
|
+
videoClassName = _ref.videoClassName,
|
|
83
|
+
withoutVideo = _ref.withoutVideo,
|
|
84
|
+
props = _objectWithoutProperties__default["default"](_ref, _excluded);
|
|
87
85
|
var _ref2 = media || {},
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
_ref2$type = _ref2.type,
|
|
87
|
+
type = _ref2$type === void 0 ? null : _ref2$type,
|
|
88
|
+
_ref2$thumbnail_url = _ref2.thumbnail_url,
|
|
89
|
+
thumbnailUrl = _ref2$thumbnail_url === void 0 ? null : _ref2$thumbnail_url,
|
|
90
|
+
_ref2$url = _ref2.url,
|
|
91
|
+
url = _ref2$url === void 0 ? null : _ref2$url;
|
|
95
92
|
var isVideo = type === 'video';
|
|
96
93
|
var elProps = React.useMemo(function () {
|
|
97
94
|
return _objectSpread__default["default"](_objectSpread__default["default"]({}, props), {}, {
|
|
@@ -111,28 +108,23 @@ var Visual = function Visual(_ref) {
|
|
|
111
108
|
}) : tmpProps;
|
|
112
109
|
}, [isVideo, elProps, thumbnailUrl, url, shouldLoad]);
|
|
113
110
|
var videoContainerStyle = null;
|
|
114
|
-
|
|
115
111
|
if (type === 'video' && objectFit !== null && shouldLoad) {
|
|
116
112
|
var _ref3 = objectFit || {},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
113
|
+
_ref3$fit = _ref3.fit,
|
|
114
|
+
fit = _ref3$fit === void 0 ? 'cover' : _ref3$fit;
|
|
120
115
|
var _ref4 = media || {},
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
116
|
+
_ref4$metadata = _ref4.metadata,
|
|
117
|
+
videoMetadata = _ref4$metadata === void 0 ? null : _ref4$metadata;
|
|
124
118
|
var _ref5 = videoMetadata || {},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
119
|
+
_ref5$width = _ref5.width,
|
|
120
|
+
videoWidth = _ref5$width === void 0 ? 0 : _ref5$width,
|
|
121
|
+
_ref5$height = _ref5.height,
|
|
122
|
+
videoHeight = _ref5$height === void 0 ? 0 : _ref5$height;
|
|
130
123
|
var _getSizeWithinBounds = size.getSizeWithinBounds(videoWidth, videoHeight, width, height, {
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
124
|
+
cover: fit === 'cover'
|
|
125
|
+
}),
|
|
126
|
+
resizedVideoWidth = _getSizeWithinBounds.width,
|
|
127
|
+
resizedVideoHeight = _getSizeWithinBounds.height;
|
|
136
128
|
var resizedVideoLeft = -(resizedVideoWidth - width) / 2;
|
|
137
129
|
var resizedVideoTop = -(resizedVideoHeight - height) / 2;
|
|
138
130
|
videoContainerStyle = {
|
|
@@ -142,7 +134,6 @@ var Visual = function Visual(_ref) {
|
|
|
142
134
|
top: resizedVideoTop
|
|
143
135
|
};
|
|
144
136
|
}
|
|
145
|
-
|
|
146
137
|
var onLoaded = React.useCallback(function (e) {
|
|
147
138
|
if (onParentLoaded !== null) {
|
|
148
139
|
onParentLoaded(e);
|
|
@@ -178,7 +169,6 @@ var Visual = function Visual(_ref) {
|
|
|
178
169
|
autoPlay: true
|
|
179
170
|
})))) : null) : null;
|
|
180
171
|
};
|
|
181
|
-
|
|
182
172
|
Visual.propTypes = propTypes;
|
|
183
173
|
Visual.defaultProps = defaultProps;
|
|
184
174
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@micromag/element-visual",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.322",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"javascript"
|
|
@@ -50,15 +50,15 @@
|
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@babel/runtime": "^7.13.10",
|
|
52
52
|
"@folklore/size": "^0.1.20",
|
|
53
|
-
"@micromag/core": "^0.3.
|
|
54
|
-
"@micromag/element-image": "^0.3.
|
|
55
|
-
"@micromag/element-video": "^0.3.
|
|
53
|
+
"@micromag/core": "^0.3.322",
|
|
54
|
+
"@micromag/element-image": "^0.3.322",
|
|
55
|
+
"@micromag/element-video": "^0.3.322",
|
|
56
56
|
"classnames": "^2.2.6",
|
|
57
57
|
"prop-types": "^15.7.2",
|
|
58
|
-
"uuid": "^
|
|
58
|
+
"uuid": "^9.0.0"
|
|
59
59
|
},
|
|
60
60
|
"publishConfig": {
|
|
61
61
|
"access": "public"
|
|
62
62
|
},
|
|
63
|
-
"gitHead": "
|
|
63
|
+
"gitHead": "2dfe09ad5a9ac720e4bfbffcb6371fc31c24fa9f"
|
|
64
64
|
}
|