@twreporter/react-article-components 2.1.1-beta.0 → 2.1.1-rc.1

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2019 TwReporter
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -316,7 +316,8 @@ var WayPointWrapper = function WayPointWrapper(props) {
316
316
  onEnter: onEnter,
317
317
  onLeave: onLeave,
318
318
  fireOnRapidScroll: false,
319
- topOffset: "-150%"
319
+ topOffset: 5,
320
+ bottomOffset: "-100%"
320
321
  }, /*#__PURE__*/_react["default"].createElement("div", null, /*#__PURE__*/_react["default"].createElement(EmbeddedCode, _extends({}, props, {
321
322
  ref: embedRef
322
323
  }))))
@@ -25,6 +25,8 @@ var _releaseBranch = _interopRequireDefault(require("@twreporter/core/lib/consta
25
25
 
26
26
  var _zIndex = _interopRequireDefault(require("@twreporter/core/lib/constants/z-index"));
27
27
 
28
+ var _mediaQuery = require("@twreporter/core/lib/utils/media-query");
29
+
28
30
  var _image = require("../../utils/image");
29
31
 
30
32
  var _imgWithPlaceholder = _interopRequireDefault(require("../../constants/prop-types/img-with-placeholder"));
@@ -33,6 +35,8 @@ var _get = _interopRequireDefault(require("lodash/get"));
33
35
 
34
36
  var _map = _interopRequireDefault(require("lodash/map"));
35
37
 
38
+ var _debounce = _interopRequireDefault(require("lodash/debounce"));
39
+
36
40
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
37
41
 
38
42
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -79,7 +83,8 @@ PlaceholderIcon.defaultProps = {
79
83
  };
80
84
  var _ = {
81
85
  get: _get["default"],
82
- map: _map["default"]
86
+ map: _map["default"],
87
+ debounce: _debounce["default"]
83
88
  };
84
89
  var objectFitConsts = {
85
90
  contain: 'contain',
@@ -174,13 +179,24 @@ var Img = /*#__PURE__*/function (_React$PureComponent) {
174
179
  _classCallCheck(this, Img);
175
180
 
176
181
  _this = _super.call(this, props);
182
+
183
+ _defineProperty(_assertThisInitialized(_this), "_handleWindowResize", function () {
184
+ var windowWidth = window.innerWidth;
185
+
186
+ _this.setState({
187
+ isMobile: windowWidth < _mediaQuery.DEFAULT_SCREEN.tablet.minWidth
188
+ });
189
+ });
190
+
177
191
  _this.state = {
178
192
  isLoaded: false,
179
193
  toShowPlaceholder: true,
180
- showFullScreenImg: false
194
+ showFullScreenImg: false,
195
+ isMobile: false
181
196
  };
182
197
  _this._img = /*#__PURE__*/_react["default"].createRef();
183
198
  _this.handleImageLoaded = _this.handleImageLoaded.bind(_assertThisInitialized(_this));
199
+ _this.handleWindowResize = _.debounce(_this._handleWindowResize, 500).bind(_assertThisInitialized(_this));
184
200
  _this._isMounted = false;
185
201
  _this._supportObjectFit = true;
186
202
  return _this;
@@ -198,11 +214,15 @@ var Img = /*#__PURE__*/function (_React$PureComponent) {
198
214
  if (_.get(this._img.current, 'complete')) {
199
215
  this.handleImageLoaded();
200
216
  }
217
+
218
+ window.addEventListener('resize', this.handleWindowResize);
219
+ this.handleWindowResize();
201
220
  }
202
221
  }, {
203
222
  key: "componentWillUnmount",
204
223
  value: function componentWillUnmount() {
205
224
  this._isMounted = false;
225
+ window.removeEventListener('resize', this.handleWindowResize);
206
226
  }
207
227
  }, {
208
228
  key: "handleImageLoaded",
@@ -264,7 +284,8 @@ var Img = /*#__PURE__*/function (_React$PureComponent) {
264
284
 
265
285
  var _this$state = this.state,
266
286
  isLoaded = _this$state.isLoaded,
267
- showFullScreenImg = _this$state.showFullScreenImg;
287
+ showFullScreenImg = _this$state.showFullScreenImg,
288
+ isMobile = _this$state.isMobile;
268
289
  var _this$props2 = this.props,
269
290
  alt = _this$props2.alt,
270
291
  className = _this$props2.className,
@@ -278,7 +299,7 @@ var Img = /*#__PURE__*/function (_React$PureComponent) {
278
299
  var releaseBranch = (this === null || this === void 0 ? void 0 : (_this$context = this.context) === null || _this$context === void 0 ? void 0 : _this$context.releaseBranch) || _releaseBranch["default"].release;
279
300
 
280
301
  var openFullScreen = function openFullScreen() {
281
- if (!clickable) return;
302
+ if (isMobile) return;
282
303
 
283
304
  _this3.setState({
284
305
  showFullScreenImg: true
@@ -321,7 +342,7 @@ var Img = /*#__PURE__*/function (_React$PureComponent) {
321
342
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(ImgContainer, {
322
343
  className: appendedClassName,
323
344
  $heightString: isObjectFit ? "height: 100%;" : "padding-top: ".concat(heightWidthRatio * 100, "%;"),
324
- onClick: openFullScreen
345
+ onClick: clickable ? openFullScreen : undefined
325
346
  }, this._renderImagePlaceholder(), /*#__PURE__*/_react["default"].createElement(ImgBox, {
326
347
  $toShow: isLoaded
327
348
  }, isObjectFit ? /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(ImgWithObjectFit, _extends({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@twreporter/react-article-components",
3
- "version": "2.1.1-beta.0",
3
+ "version": "2.1.1-rc.1",
4
4
  "description": "The Reporter react article components, which are used in article page",
5
5
  "main": "lib/components/article-page.js",
6
6
  "repository": "https://github.com/twreporter/twreporter-npm-packages.git",
@@ -24,10 +24,10 @@
24
24
  "webpack-dev-server": "^3.7.2"
25
25
  },
26
26
  "dependencies": {
27
- "@twreporter/core": "^1.22.0",
28
- "@twreporter/react-components": "^9.0.1",
29
- "@twreporter/redux": "^8.0.1",
30
- "@twreporter/universal-header": "^3.0.1",
27
+ "@twreporter/core": "^1.22.1-rc.0",
28
+ "@twreporter/react-components": "^9.0.2-rc.0",
29
+ "@twreporter/redux": "^8.0.2-rc.0",
30
+ "@twreporter/universal-header": "^3.0.2-rc.0",
31
31
  "howler": "^2.2.3",
32
32
  "lodash": "^4.17.11",
33
33
  "memoize-one": "^5.0.5",
@@ -40,5 +40,6 @@
40
40
  },
41
41
  "files": [
42
42
  "lib"
43
- ]
43
+ ],
44
+ "gitHead": "0733bb956c03dabdd4009b1b000afa09ea2df562"
44
45
  }