@configuratorware/configurator-frontendgui 1.33.2-beta.1 → 1.33.3

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.
@@ -11,6 +11,8 @@ var _react = _interopRequireDefault(require("react"));
11
11
 
12
12
  var _lodash = _interopRequireDefault(require("lodash"));
13
13
 
14
+ var _reactSwipeable = require("react-swipeable");
15
+
14
16
  var _clsx2 = _interopRequireDefault(require("clsx"));
15
17
 
16
18
  var _Button = _interopRequireDefault(require("@material-ui/core/Button"));
@@ -43,8 +45,6 @@ var _Markdown = _interopRequireDefault(require("../../../../../Framework/Compone
43
45
 
44
46
  var _ZoomImage = _interopRequireDefault(require("./ZoomImage"));
45
47
 
46
- var _Swipeable = require("../../../../../Shared/Components/Swipeable");
47
-
48
48
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
49
49
 
50
50
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
@@ -214,11 +214,14 @@ var Optiondetail = /*#__PURE__*/function (_React$Component) {
214
214
  }
215
215
  });
216
216
 
217
- _defineProperty(_assertThisInitialized(_this), "swiped", function (e) {
218
- if (e.dir === _Swipeable.LEFT) {
219
- _this.next();
220
- } else if (e.dir === _Swipeable.RIGHT) {
221
- _this.prev();
217
+ _defineProperty(_assertThisInitialized(_this), "swiped", function (e, deltaX, deltaY) {
218
+ // use only horizontal swiping
219
+ if (Math.abs(deltaX) >= Math.abs(deltaY)) {
220
+ if (deltaX > 0) {
221
+ _this.next();
222
+ } else {
223
+ _this.prev();
224
+ }
222
225
  }
223
226
  });
224
227
 
@@ -425,12 +428,12 @@ var Optiondetail = /*#__PURE__*/function (_React$Component) {
425
428
  }
426
429
  }, /*#__PURE__*/_react["default"].createElement(LoadingComponent, {
427
430
  show: loading
428
- })) : /*#__PURE__*/_react["default"].createElement(_Swipeable.Swipeable, {
429
- options: {
430
- trackMouse: true,
431
- onSwiped: showNav && this.swiped,
432
- delta: Optiondetail.swipeDelta
433
- },
431
+ })) : /*#__PURE__*/_react["default"].createElement(_reactSwipeable.Swipeable, {
432
+ disabled: !showNav,
433
+ trackMouse: true,
434
+ onSwiped: this.swiped,
435
+ delta: Optiondetail.swipeDelta
436
+ }, /*#__PURE__*/_react["default"].createElement("div", {
434
437
  ref: this.setDetailsContainerRef,
435
438
  className: showNav ? classes.detailContainerWithNav : classes.detailContainer
436
439
  }, showNav && /*#__PURE__*/_react["default"].createElement("div", {
@@ -450,7 +453,7 @@ var Optiondetail = /*#__PURE__*/function (_React$Component) {
450
453
  })), detailsContent) : detailsContent, showNav && /*#__PURE__*/_react["default"].createElement("div", {
451
454
  className: (0, _clsx2["default"])(classes.detailNav, 'next'),
452
455
  onClick: this.next
453
- }))), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, /*#__PURE__*/_react["default"].createElement("div", {
456
+ })))), /*#__PURE__*/_react["default"].createElement(_DialogActions["default"], null, /*#__PURE__*/_react["default"].createElement("div", {
454
457
  className: classes.detailFooter
455
458
  }, this.renderControls())), /*#__PURE__*/_react["default"].createElement(_ZoomImage["default"], {
456
459
  onClose: this.toggleZoomImage,
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.CreatorScreen = CreatorScreen;
9
- exports["default"] = void 0;
10
9
 
11
10
  var _react = _interopRequireWildcard(require("react"));
12
11
 
@@ -305,6 +304,4 @@ CreatorScreen.defaultProps = {
305
304
  },
306
305
  Layout: _DefaultLayout["default"],
307
306
  OptionsListContainer: _OptionsList["default"]
308
- };
309
- var _default = CreatorScreen;
310
- exports["default"] = _default;
307
+ };
@@ -242,7 +242,7 @@ var ImageEditDialog = /*#__PURE__*/function (_React$Component) {
242
242
  }
243
243
 
244
244
  var extension = file.name.toLowerCase().match(/\.([0-9a-z]+)$/i)[1];
245
- var allowedFormats = (0, _configuration.getConf)('designer.allowedImageUploadFormats');
245
+ var allowedFormats = (0, _configuration.getConf)('designer.allowedImageUploadFormats').split(',');
246
246
 
247
247
  if (allowedFormats.indexOf(extension) === -1) {
248
248
  error = (0, _i18n.t)('fileUpload.uploadFormatError', {
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
8
  exports.DesignerScreen = DesignerScreen;
9
- exports["default"] = void 0;
10
9
 
11
10
  var React = _interopRequireWildcard(require("react"));
12
11
 
@@ -253,6 +252,4 @@ DesignerScreen.defaultProps = {
253
252
  TextEditorStateProvider: _DefaultCanvasProvider.DefaultTextEditorStateProvider,
254
253
  Layout: _DefaultLayout["default"],
255
254
  PopupArea: _PopupAreaProvider.PopupArea
256
- };
257
- var _default = DesignerScreen;
258
- exports["default"] = _default;
255
+ };
@@ -634,6 +634,6 @@ function configuratorReducer() {
634
634
 
635
635
  function filterOptionsWithDetails(options) {
636
636
  return _lodash["default"].filter(options, function (option) {
637
- return !!(option["abstract"] || option.description || option.detailImage);
637
+ return !!(option["abstract"] || option.description || option.detailImageExists === true);
638
638
  });
639
639
  }
@@ -26,11 +26,9 @@ var _Reducer = require("./Reducers/Configurator/Reducer");
26
26
 
27
27
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
28
28
 
29
- var DEVELOPMENT_HOST_INT = 'http://int.configuratorware.local'; //const DEVELOPMENT_HOST_INT = 'http://int.schoeffel-corporate-wear.local';
30
- // eslint-disable-next-line no-unused-vars
31
-
32
- var DEVELOPMENT_HOST_LOCAL = DEVELOPMENT_HOST_INT; //'http://localhost:10030';
29
+ var DEVELOPMENT_HOST_INT = 'http://int.configuratorware.local'; // eslint-disable-next-line no-unused-vars
33
30
 
31
+ var DEVELOPMENT_HOST_LOCAL = 'http://localhost:10030';
34
32
  var hostsByNodeEnv = {
35
33
  production: '',
36
34
  development: DEVELOPMENT_HOST_LOCAL,
@@ -180,8 +178,8 @@ var applicationConfiguration = {
180
178
  // the default canvas dpi as project specific option
181
179
  maxColorAmount: 10,
182
180
  // the default max number of colors in the colorizing feature
183
- allowedImageUploadFormats: [// the image formats users can upload to designareas / designer items
184
- 'jpg', 'jpeg', 'svg', 'png', 'pdf', 'bmp', 'tif', 'tiff', 'eps', 'ai', 'gif']
181
+ allowedImageUploadFormats: 'jpg,jpeg,svg,png,pdf,bmp,tif,tiff,eps,ai,gif' // the image formats users can upload to designareas / designer items
182
+
185
183
  },
186
184
  vectorizeImageQuality: 45000,
187
185
  renderPreviewImagesForCheckout: true,
@@ -9,6 +9,8 @@ exports["default"] = void 0;
9
9
 
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
 
12
+ var _reactSwipeable = require("react-swipeable");
13
+
12
14
  var _lodash = _interopRequireDefault(require("lodash"));
13
15
 
14
16
  require("./Styles.scss");
@@ -19,8 +21,6 @@ var _clsx = _interopRequireDefault(require("clsx"));
19
21
 
20
22
  var _styles = require("@material-ui/core/styles");
21
23
 
22
- var _Swipeable = require("../../../Shared/Components/Swipeable");
23
-
24
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
25
 
26
26
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
@@ -186,16 +186,18 @@ var Carousel = /*#__PURE__*/function (_React$Component) {
186
186
  });
187
187
 
188
188
  _defineProperty(_assertThisInitialized(_this), "swiped", function (e) {
189
- if (_this.props.vertical) {
190
- if (e.dir === _Swipeable.UP) {
189
+ // if it's vertical deltaY should be the bigger
190
+ if (_this.props.vertical && Math.abs(e.deltaY) >= Math.abs(e.deltaX)) {
191
+ if (e.deltaY > 0) {
191
192
  _this.next();
192
- } else if (e.dir === _Swipeable.DOWN) {
193
+ } else {
193
194
  _this.prev();
194
195
  }
195
- } else {
196
- if (e.dir === _Swipeable.LEFT) {
196
+ } // if it's not vertical deltaX should be the bigger
197
+ else if (!_this.props.vertical && Math.abs(e.deltaX) >= Math.abs(e.deltaY)) {
198
+ if (e.deltaX > 0) {
197
199
  _this.next();
198
- } else if (e.dir === _Swipeable.RIGHT) {
200
+ } else {
199
201
  _this.prev();
200
202
  }
201
203
  }
@@ -229,13 +231,10 @@ var Carousel = /*#__PURE__*/function (_React$Component) {
229
231
  _createClass(Carousel, [{
230
232
  key: "componentDidMount",
231
233
  value: function componentDidMount() {
234
+ this.init();
232
235
  var carousel = this.refs.carousel;
233
-
234
- if (carousel) {
235
- this.init();
236
- var wheelEventName = 'onwheel' in carousel ? 'wheel' : 'mousewheel';
237
- carousel.addEventListener(wheelEventName, this.scrolled);
238
- }
236
+ var wheelEventName = 'onwheel' in carousel ? 'wheel' : 'mousewheel';
237
+ carousel.addEventListener(wheelEventName, this.scrolled);
239
238
  }
240
239
  }, {
241
240
  key: "componentDidUpdate",
@@ -279,13 +278,11 @@ var Carousel = /*#__PURE__*/function (_React$Component) {
279
278
  className: (0, _clsx["default"])(classes.carousel, prevClassName),
280
279
  ref: "prev",
281
280
  onClick: this.prev
282
- }), /*#__PURE__*/_react["default"].createElement(_Swipeable.Swipeable, {
281
+ }), /*#__PURE__*/_react["default"].createElement(_reactSwipeable.Swipeable, {
283
282
  className: 'carousel-frame',
284
- options: {
285
- trackMouse: true,
286
- onSwiping: this.swiping,
287
- onSwiped: this.swiped
288
- }
283
+ trackMouse: true,
284
+ onSwiping: this.swiping,
285
+ onSwiped: this.swiped
289
286
  }, /*#__PURE__*/_react["default"].createElement("div", {
290
287
  className: "carousel-slider",
291
288
  style: {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@configuratorware/configurator-frontendgui",
3
- "version": "1.33.2-beta.1",
3
+ "version": "1.33.3",
4
4
  "license": "UNLICENSED",
5
5
  "private": false,
6
6
  "main": "./index.js",
7
7
  "dependencies": {
8
8
  "@babel/polyfill": "^7.12.1",
9
- "@configuratorware/scripts": "1.33.2-beta.1",
10
- "@hot-loader/react-dom": "^17.0.2",
9
+ "@configuratorware/scripts": "1.33.3",
10
+ "@hot-loader/react-dom": "^17.0.1",
11
11
  "@material-ui/core": "^4.12.2",
12
12
  "@material-ui/icons": "^4.11.2",
13
13
  "@material-ui/lab": "^4.0.0-alpha.60",
@@ -26,9 +26,9 @@
26
26
  "path-browserify": "^1.0.1",
27
27
  "prop-types": "^15.7.2",
28
28
  "qs": "^6.10.1",
29
- "react": "^17.0.2",
29
+ "react": "^16.14.0",
30
30
  "react-custom-scrollbars": "^4.2.1",
31
- "react-dom": "^17.0.2",
31
+ "react-dom": "^16.14.0",
32
32
  "react-file-drop": "^0.2.8",
33
33
  "react-hot-loader": "^4.13.0",
34
34
  "react-hyphen": "^1.4.0",
@@ -37,10 +37,10 @@
37
37
  "react-redux-i18n": "^1.9.3",
38
38
  "react-router": "^5.2.0",
39
39
  "react-router-dom": "^5.2.0",
40
- "react-swipeable": "^6.2.2",
40
+ "react-swipeable": "^5.5.1",
41
41
  "react-zoom-pan-pinch": "^2.1.3",
42
- "redhotmagma-graphics-editor": "1.33.2-beta.1",
43
- "redhotmagma-visualization": "1.33.2-beta.1",
42
+ "redhotmagma-graphics-editor": "1.33.3",
43
+ "redhotmagma-visualization": "1.33.3",
44
44
  "redux": "^4.1.0",
45
45
  "redux-logger": "^3.0.6",
46
46
  "redux-persist": "^5.10.0",
@@ -52,22 +52,30 @@
52
52
  "uuid": "^3.4.0"
53
53
  },
54
54
  "peerDependencies": {
55
+ "@babel/plugin-proposal-class-properties": "^7.13.0",
56
+ "@babel/plugin-proposal-decorators": "^7.13.5",
57
+ "@babel/plugin-syntax-dynamic-import": "^7.8.3",
58
+ "@babel/preset-env": "^7.13.12",
59
+ "@babel/preset-react": "^7.13.13",
60
+ "@babel/preset-typescript": "^7.13.0",
55
61
  "babel-loader": "^8.2.2",
56
- "css-loader": "^5.2.7",
62
+ "babel-plugin-module-resolver": "^4.1.0",
63
+ "css-loader": "^5.2.0",
57
64
  "file-loader": "^6.2.0",
58
- "mini-css-extract-plugin": "^2.1.0",
59
- "resolve-url-loader": "^3.1.4",
60
- "sass": "^1.53.0",
61
- "sass-loader": "^13.0.2",
65
+ "mini-css-extract-plugin": "^1.4.0",
66
+ "node-sass": "^5.0.0",
67
+ "optimize-css-assets-webpack-plugin": "^5.0.4",
68
+ "resolve-url-loader": "^3.1.2",
69
+ "sass-loader": "^11.0.1",
62
70
  "style-loader": "^2.0.0",
63
- "terser-webpack-plugin": "^5.1.4",
64
71
  "url-loader": "^4.1.1",
65
- "webpack": "^5.46.0",
66
- "webpack-cli": "^4.7.2",
72
+ "webpack": "^5.28.0",
73
+ "webpack-cli": "^4.6.0",
67
74
  "webpack-dev-server": "^3.11.2"
68
75
  },
69
76
  "scripts": {
70
77
  "copy-public": "node ./scripts/cpPublic.js",
71
78
  "install": "npm run copy-public"
72
- }
79
+ },
80
+ "readme": "# configurator-frontendgui\n\n## Setup for Development\n1. Follow the \"preparation\", \"install\" and \"start development\" steps in frontend/README.md\n1. Open the core app in the browser: http://localhost:3001/identifier:softshell_designer_2d\n1. 'hostsByNodeEnv.development' in src/App/configuration.js is configurable \n thus allowing to use e.g. your local api\n\n## Ready to build the artifacts\n- run `pnpm build` from project scope (does not build workspace dependencies automatically)\n- or run `pnpm build` from workspace root\n\n## Start storybook in project \n1. `pnpm run storybook`\n1. `storybook starts on http://localhost:9001/` \n\n## [Guidelines for automated testing](docs/TestingGuidelines.md)\n"
73
81
  }
@@ -1,5 +1,6 @@
1
1
  import React from 'react';
2
2
  import _ from 'lodash';
3
+ import { Swipeable } from 'react-swipeable';
3
4
  import clsx from 'clsx';
4
5
  import Button from '@material-ui/core/Button';
5
6
  import DialogContent from '@material-ui/core/DialogContent';
@@ -16,7 +17,6 @@ import OptionlistitemAmount from '../OptionAmount';
16
17
  import getImageUrl from '../../../../Utils/getImageUrl';
17
18
  import Markdown from '../../../../../Framework/Components/Markdown';
18
19
  import ZoomImage from './ZoomImage';
19
- import { LEFT, RIGHT, Swipeable } from '../../../../../Shared/Components/Swipeable';
20
20
 
21
21
  const styles = theme => ({
22
22
  detailNav: {
@@ -189,11 +189,14 @@ class Optiondetail extends React.Component {
189
189
  }
190
190
  };
191
191
 
192
- swiped = e => {
193
- if (e.dir === LEFT) {
194
- this.next();
195
- } else if (e.dir === RIGHT) {
196
- this.prev();
192
+ swiped = (e, deltaX, deltaY) => {
193
+ // use only horizontal swiping
194
+ if (Math.abs(deltaX) >= Math.abs(deltaY)) {
195
+ if (deltaX > 0) {
196
+ this.next();
197
+ } else {
198
+ this.prev();
199
+ }
197
200
  }
198
201
  };
199
202
 
@@ -348,53 +351,55 @@ class Optiondetail extends React.Component {
348
351
  </div>
349
352
  ) : (
350
353
  <Swipeable
351
- options={{
352
- trackMouse: true,
353
- onSwiped: showNav && this.swiped,
354
- delta: Optiondetail.swipeDelta,
355
- }}
356
- ref={this.setDetailsContainerRef}
357
- className={showNav ? classes.detailContainerWithNav : classes.detailContainer}
354
+ disabled={!showNav}
355
+ trackMouse={true}
356
+ onSwiped={this.swiped}
357
+ delta={Optiondetail.swipeDelta}
358
358
  >
359
- {showNav && (
360
- <div className={clsx(classes.detailNav, 'prev')} onClick={this.prev} />
361
- )}
359
+ <div
360
+ ref={this.setDetailsContainerRef}
361
+ className={showNav ? classes.detailContainerWithNav : classes.detailContainer}
362
+ >
363
+ {showNav && (
364
+ <div className={clsx(classes.detailNav, 'prev')} onClick={this.prev} />
365
+ )}
362
366
 
363
- {detailImage ? (
364
- <div
365
- className={clsx({
366
- [classes.detailsWithImageContainer]: !showFullScreenModal,
367
- })}
368
- >
367
+ {detailImage ? (
369
368
  <div
370
- className={
371
- this.state.hasZoom
372
- ? classes.imageContainerWithZoom
373
- : classes.imageContainer
374
- }
375
- onClick={this.state.hasZoom ? this.toggleZoomImage : null}
369
+ className={clsx({
370
+ [classes.detailsWithImageContainer]: !showFullScreenModal,
371
+ })}
376
372
  >
377
- <img
378
- ref={this.setDetailsImageRef}
379
- onLoad={this.handleImageLoaded}
373
+ <div
380
374
  className={
381
- this.state.zoomImage && ['xs', 'sm'].includes(width)
382
- ? classes.imageHidden
383
- : classes.image
375
+ this.state.hasZoom
376
+ ? classes.imageContainerWithZoom
377
+ : classes.imageContainer
384
378
  }
385
- src={getImageUrl(detailImage)}
386
- alt={details.title}
387
- />
379
+ onClick={this.state.hasZoom ? this.toggleZoomImage : null}
380
+ >
381
+ <img
382
+ ref={this.setDetailsImageRef}
383
+ onLoad={this.handleImageLoaded}
384
+ className={
385
+ this.state.zoomImage && ['xs', 'sm'].includes(width)
386
+ ? classes.imageHidden
387
+ : classes.image
388
+ }
389
+ src={getImageUrl(detailImage)}
390
+ alt={details.title}
391
+ />
392
+ </div>
393
+ {detailsContent}
388
394
  </div>
389
- {detailsContent}
390
- </div>
391
- ) : (
392
- detailsContent
393
- )}
395
+ ) : (
396
+ detailsContent
397
+ )}
394
398
 
395
- {showNav && (
396
- <div className={clsx(classes.detailNav, 'next')} onClick={this.next} />
397
- )}
399
+ {showNav && (
400
+ <div className={clsx(classes.detailNav, 'next')} onClick={this.next} />
401
+ )}
402
+ </div>
398
403
  </Swipeable>
399
404
  )}
400
405
  </DialogContent>
@@ -310,5 +310,3 @@ CreatorScreen.defaultProps = {
310
310
  Layout: DefaultLayout,
311
311
  OptionsListContainer,
312
312
  };
313
-
314
- export default CreatorScreen;
@@ -209,8 +209,7 @@ class ImageEditDialog extends React.Component {
209
209
 
210
210
  const extension = file.name.toLowerCase().match(/\.([0-9a-z]+)$/i)[1];
211
211
 
212
- const allowedFormats = getConf('designer.allowedImageUploadFormats');
213
-
212
+ const allowedFormats = getConf('designer.allowedImageUploadFormats').split(',');
214
213
  if (allowedFormats.indexOf(extension) === -1) {
215
214
  error = t('fileUpload.uploadFormatError', { formats: allowedFormats.join(', ').toUpperCase() });
216
215
  }
@@ -280,5 +280,3 @@ DesignerScreen.defaultProps = {
280
280
  Layout: DefaultLayout,
281
281
  PopupArea: DefaultPopupArea,
282
282
  };
283
-
284
- export default DesignerScreen;
@@ -599,6 +599,6 @@ export default function configuratorReducer(prevState = initialState, action = {
599
599
  function filterOptionsWithDetails(options) {
600
600
  return _.filter(
601
601
  options,
602
- option => !!(option.abstract || option.description || option.detailImage)
602
+ option => !!(option.abstract || option.description || option.detailImageExists === true)
603
603
  );
604
604
  }
@@ -7,10 +7,9 @@ import hyphensEnGB from 'hyphenated-en-gb';
7
7
  import { setStateChangeReducers, setSubReducers } from './Reducers/Configurator/Reducer';
8
8
 
9
9
  const DEVELOPMENT_HOST_INT = 'http://int.configuratorware.local';
10
- //const DEVELOPMENT_HOST_INT = 'http://int.schoeffel-corporate-wear.local';
11
10
 
12
11
  // eslint-disable-next-line no-unused-vars
13
- const DEVELOPMENT_HOST_LOCAL = DEVELOPMENT_HOST_INT; //'http://localhost:10030';
12
+ const DEVELOPMENT_HOST_LOCAL = 'http://localhost:10030';
14
13
 
15
14
  const hostsByNodeEnv = {
16
15
  production: '',
@@ -194,20 +193,7 @@ let applicationConfiguration = {
194
193
  designer: {
195
194
  dpi: 300, // the default canvas dpi as project specific option
196
195
  maxColorAmount: 10, // the default max number of colors in the colorizing feature
197
- allowedImageUploadFormats: [
198
- // the image formats users can upload to designareas / designer items
199
- 'jpg',
200
- 'jpeg',
201
- 'svg',
202
- 'png',
203
- 'pdf',
204
- 'bmp',
205
- 'tif',
206
- 'tiff',
207
- 'eps',
208
- 'ai',
209
- 'gif',
210
- ],
196
+ allowedImageUploadFormats: 'jpg,jpeg,svg,png,pdf,bmp,tif,tiff,eps,ai,gif', // the image formats users can upload to designareas / designer items
211
197
  },
212
198
 
213
199
  vectorizeImageQuality: 45000,
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
+ import { Swipeable } from 'react-swipeable';
2
3
  import _ from 'lodash';
3
4
 
4
5
  import './Styles.scss';
5
6
  import PropTypes from 'prop-types';
6
7
  import clsx from 'clsx';
7
8
  import { withStyles } from '@material-ui/core/styles';
8
- import { DOWN, LEFT, RIGHT, Swipeable, UP } from '../../../Shared/Components/Swipeable';
9
9
 
10
10
  const styles = theme => ({
11
11
  carousel: {
@@ -37,12 +37,10 @@ class Carousel extends React.Component {
37
37
  }
38
38
 
39
39
  componentDidMount() {
40
+ this.init();
40
41
  const { carousel } = this.refs;
41
- if (carousel) {
42
- this.init();
43
- const wheelEventName = 'onwheel' in carousel ? 'wheel' : 'mousewheel';
44
- carousel.addEventListener(wheelEventName, this.scrolled);
45
- }
42
+ const wheelEventName = 'onwheel' in carousel ? 'wheel' : 'mousewheel';
43
+ carousel.addEventListener(wheelEventName, this.scrolled);
46
44
  }
47
45
 
48
46
  componentDidUpdate() {
@@ -142,16 +140,19 @@ class Carousel extends React.Component {
142
140
  };
143
141
 
144
142
  swiped = e => {
145
- if (this.props.vertical) {
146
- if (e.dir === UP) {
143
+ // if it's vertical deltaY should be the bigger
144
+ if (this.props.vertical && Math.abs(e.deltaY) >= Math.abs(e.deltaX)) {
145
+ if (e.deltaY > 0) {
147
146
  this.next();
148
- } else if (e.dir === DOWN) {
147
+ } else {
149
148
  this.prev();
150
149
  }
151
- } else {
152
- if (e.dir === LEFT) {
150
+ }
151
+ // if it's not vertical deltaX should be the bigger
152
+ else if (!this.props.vertical && Math.abs(e.deltaX) >= Math.abs(e.deltaY)) {
153
+ if (e.deltaX > 0) {
153
154
  this.next();
154
- } else if (e.dir === RIGHT) {
155
+ } else {
155
156
  this.prev();
156
157
  }
157
158
  }
@@ -198,11 +199,9 @@ class Carousel extends React.Component {
198
199
  )}
199
200
  <Swipeable
200
201
  className={'carousel-frame'}
201
- options={{
202
- trackMouse: true,
203
- onSwiping: this.swiping,
204
- onSwiped: this.swiped,
205
- }}
202
+ trackMouse={true}
203
+ onSwiping={this.swiping}
204
+ onSwiped={this.swiped}
206
205
  >
207
206
  <div
208
207
  className="carousel-slider"
@@ -1,56 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "UP", {
7
- enumerable: true,
8
- get: function get() {
9
- return _reactSwipeable.UP;
10
- }
11
- });
12
- Object.defineProperty(exports, "DOWN", {
13
- enumerable: true,
14
- get: function get() {
15
- return _reactSwipeable.DOWN;
16
- }
17
- });
18
- Object.defineProperty(exports, "LEFT", {
19
- enumerable: true,
20
- get: function get() {
21
- return _reactSwipeable.LEFT;
22
- }
23
- });
24
- Object.defineProperty(exports, "RIGHT", {
25
- enumerable: true,
26
- get: function get() {
27
- return _reactSwipeable.RIGHT;
28
- }
29
- });
30
- exports.Swipeable = void 0;
31
-
32
- var _react = _interopRequireDefault(require("react"));
33
-
34
- var _reactSwipeable = require("react-swipeable");
35
-
36
- var _excluded = ["options"];
37
-
38
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
39
-
40
- function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
41
-
42
- function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
43
-
44
- function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
45
-
46
- var Swipeable = /*#__PURE__*/_react["default"].forwardRef(function (_ref, ref) {
47
- var options = _ref.options,
48
- props = _objectWithoutProperties(_ref, _excluded);
49
-
50
- var handlers = (0, _reactSwipeable.useSwipeable)(options);
51
- return /*#__PURE__*/_react["default"].createElement("div", _extends({}, handlers, props, {
52
- ref: ref
53
- }));
54
- });
55
-
56
- exports.Swipeable = Swipeable;
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- import { useSwipeable, UP, DOWN, LEFT, RIGHT } from 'react-swipeable';
3
-
4
- export { UP, DOWN, LEFT, RIGHT };
5
-
6
- export const Swipeable = React.forwardRef(({ options, ...props }, ref) => {
7
- const handlers = useSwipeable(options);
8
- return <div {...handlers} {...props} ref={ref} />;
9
- });