@micromag/element-background 0.2.327 → 0.2.333

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
@@ -68,11 +68,23 @@ var Background = function Background(_ref) {
68
68
 
69
69
  var finalStyle = _objectSpread(_objectSpread({}, sizeStyle), getStyleFromColor(color));
70
70
 
71
+ var _ref3 = image || {},
72
+ imageMetadata = _ref3.metadata,
73
+ imageThumbnailUrl = _ref3.thumbnail_url,
74
+ imageUrl = _ref3.url;
75
+
76
+ var _ref4 = imageMetadata || {},
77
+ imageMIME = _ref4.mime;
78
+
79
+ var isImageGIF = imageMIME === 'image/gif';
80
+ var tmpImage = isImageGIF ? {
81
+ url: playing ? imageUrl : imageThumbnailUrl
82
+ } : image;
71
83
  var finalImage = hasVideo && !playing && videoThumbnail !== null ? {
72
84
  url: videoThumbnail
73
- } : image; // image
85
+ } : tmpImage; // image
74
86
 
75
- if (finalImage !== null) {
87
+ if (finalImage !== null && (!hasVideo || !playing)) {
76
88
  var finalUrl = getOptimalImageUrl(finalImage, width, height);
77
89
  finalStyle.backgroundImage = "url(\"".concat(finalUrl, "\")");
78
90
  finalStyle.backgroundRepeat = repeat ? 'repeat' : 'no-repeat';
@@ -90,11 +102,11 @@ var Background = function Background(_ref) {
90
102
 
91
103
  if (hasVideo && playing) {
92
104
  if (hasSize) {
93
- var _ref3 = videoMetadata || {},
94
- _ref3$width = _ref3.width,
95
- videoWidth = _ref3$width === void 0 ? 0 : _ref3$width,
96
- _ref3$height = _ref3.height,
97
- videoHeight = _ref3$height === void 0 ? 0 : _ref3$height;
105
+ var _ref5 = videoMetadata || {},
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;
98
110
 
99
111
  var _getSizeWithinBounds = getSizeWithinBounds(videoWidth, videoHeight, width, height, {
100
112
  cover: fit === 'cover' || fit === null
package/lib/index.js CHANGED
@@ -79,11 +79,23 @@ var Background = function Background(_ref) {
79
79
 
80
80
  var finalStyle = _objectSpread__default['default'](_objectSpread__default['default']({}, sizeStyle), utils.getStyleFromColor(color));
81
81
 
82
+ var _ref3 = image || {},
83
+ imageMetadata = _ref3.metadata,
84
+ imageThumbnailUrl = _ref3.thumbnail_url,
85
+ imageUrl = _ref3.url;
86
+
87
+ var _ref4 = imageMetadata || {},
88
+ imageMIME = _ref4.mime;
89
+
90
+ var isImageGIF = imageMIME === 'image/gif';
91
+ var tmpImage = isImageGIF ? {
92
+ url: playing ? imageUrl : imageThumbnailUrl
93
+ } : image;
82
94
  var finalImage = hasVideo && !playing && videoThumbnail !== null ? {
83
95
  url: videoThumbnail
84
- } : image; // image
96
+ } : tmpImage; // image
85
97
 
86
- if (finalImage !== null) {
98
+ if (finalImage !== null && (!hasVideo || !playing)) {
87
99
  var finalUrl = utils.getOptimalImageUrl(finalImage, width, height);
88
100
  finalStyle.backgroundImage = "url(\"".concat(finalUrl, "\")");
89
101
  finalStyle.backgroundRepeat = repeat ? 'repeat' : 'no-repeat';
@@ -101,11 +113,11 @@ var Background = function Background(_ref) {
101
113
 
102
114
  if (hasVideo && playing) {
103
115
  if (hasSize) {
104
- var _ref3 = videoMetadata || {},
105
- _ref3$width = _ref3.width,
106
- videoWidth = _ref3$width === void 0 ? 0 : _ref3$width,
107
- _ref3$height = _ref3.height,
108
- videoHeight = _ref3$height === void 0 ? 0 : _ref3$height;
116
+ var _ref5 = videoMetadata || {},
117
+ _ref5$width = _ref5.width,
118
+ videoWidth = _ref5$width === void 0 ? 0 : _ref5$width,
119
+ _ref5$height = _ref5.height,
120
+ videoHeight = _ref5$height === void 0 ? 0 : _ref5$height;
109
121
 
110
122
  var _getSizeWithinBounds = size.getSizeWithinBounds(videoWidth, videoHeight, width, height, {
111
123
  cover: fit === 'cover' || fit === null
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/element-background",
3
- "version": "0.2.327",
3
+ "version": "0.2.333",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "javascript"
@@ -48,8 +48,8 @@
48
48
  "dependencies": {
49
49
  "@babel/runtime": "^7.13.10",
50
50
  "@folklore/size": "^0.1.14",
51
- "@micromag/core": "^0.2.327",
52
- "@micromag/element-video": "^0.2.327",
51
+ "@micromag/core": "^0.2.330",
52
+ "@micromag/element-video": "^0.2.330",
53
53
  "classnames": "^2.2.6",
54
54
  "lodash": "^4.17.20",
55
55
  "prop-types": "^15.7.2",
@@ -59,5 +59,5 @@
59
59
  "publishConfig": {
60
60
  "access": "public"
61
61
  },
62
- "gitHead": "2051023f216b19695acf83053ef3bdca24f96932"
62
+ "gitHead": "f4cc0b72ff60c80cd5628963a7e5ad82edf6acba"
63
63
  }