hart-estate-widget 0.0.62 → 0.0.63

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.
@@ -10,10 +10,10 @@
10
10
  display: flex
11
11
  align-items: center
12
12
  justify-content: flex-end
13
- @media #{$tablet}
13
+ @include media($tablet)
14
14
  right: 20px
15
15
  bottom: 35px
16
- @media #{$w-374}
16
+ @include media($smallMobile)
17
17
  bottom: 30px
18
18
  .widget-tab-button
19
19
  @include customButton
@@ -29,17 +29,17 @@
29
29
  line-height: 120%
30
30
  font-weight: bold
31
31
  margin-left: 40px
32
- @media #{$tablet}
32
+ @include media($tablet)
33
33
  margin-left: 20px
34
34
  width: 60px
35
35
  height: 60px
36
36
  font-size: 22px
37
- @media #{$mobile}
37
+ @include media($mobile)
38
38
  margin-left: 10px
39
39
  font-size: 17px
40
40
  width: 44px
41
41
  height: 44px
42
- @media #{$w-374}
42
+ @include media($smallMobile)
43
43
  width: 36px
44
44
  height: 36px
45
45
  font-size: 14px
@@ -53,114 +53,8 @@
53
53
  align-items: center
54
54
  justify-content: center
55
55
  padding: 60px 30px
56
- @media (max-width: 630px)
56
+ @include media($smallMobile)
57
57
  padding: 60px 20px
58
- &__image
59
- max-width: 100%
60
- max-height: 100%
61
- object-fit: contain
62
- display: block
63
- &__threesixty
64
- width: 100%
65
- height: 100%
66
- @include noTouch
67
- &-start
68
- @include customButton
69
- position: absolute
70
- left: 50%
71
- bottom: 35px
72
- transform: translateX(-50%)
73
- display: flex
74
- align-items: center
75
- justify-content: center
76
- padding: 0 25px 0 10px
77
- background-color: $gray
78
- border-radius: 38px
79
- height: 72px
80
- width: 202px
81
- @media #{$tablet}
82
- height: 60px
83
- width: 166px
84
- padding: 0 20px 0 8px
85
- bottom: 35px
86
- @media #{$mobile}
87
- height: 44px
88
- width: 115px
89
- padding: 0 10px 0 6px
90
- @media #{$w-374}
91
- height: 36px
92
- width: 94px
93
- padding: 0 8px 0 6px
94
- bottom: 30px
95
- &-icon
96
- display: flex
97
- align-items: center
98
- justify-content: center
99
- border-radius: 50%
100
- background-color: $white
101
- margin-right: 18px
102
- padding: 10px
103
- @media #{$tablet}
104
- padding: 7px
105
- margin-right: 15px
106
- @media #{$mobile}
107
- margin-right: 7px
108
- @media #{$w-374}
109
- padding: 6px
110
- margin-right: 5px
111
- img
112
- display: block
113
- position: relative
114
- top: 2px
115
- width: 34px
116
- @media #{$tablet}
117
- width: 30px
118
- top: 1px
119
- @media #{$mobile}
120
- width: 19px
121
- top: 0
122
- @media #{$w-374}
123
- width: 15px
124
- span
125
- font-size: 24px
126
- font-weight: bold
127
- color: $text-dark
128
- text-transform: uppercase
129
- width: 100%
130
- display: block
131
- text-align: center
132
- position: relative
133
- top: 1px
134
- @media #{$tablet}
135
- font-size: 20px
136
- @media #{$mobile}
137
- font-size: 14px
138
- @media #{$w-374}
139
- font-size: 12px
140
- &-container
141
- width: 100% !important
142
- height: 100% !important
143
- position: relative
144
- background-image: none !important
145
- img
146
- position: absolute
147
- left: 50%
148
- top: 50%
149
- transform: translate(-50%, -50%)
150
- max-width: 100%
151
- max-height: 100%
152
- width: 600px
153
- height: 600px
154
- object-fit: contain
155
- opacity: 0
156
- pointer-events: none
157
- @include noSelect
158
- &.active
159
- opacity: 1
160
- &--active
161
- .widget-tab__threesixty-container
162
- cursor: move
163
-
164
58
  &-menu
165
59
  position: absolute
166
60
  z-index: 3
@@ -6,6 +6,7 @@
6
6
 
7
7
  width: 100%
8
8
  height: calc(100 * var(--vh))
9
+ flex: none
9
10
  overflow: hidden
10
11
  position: relative
11
12
  z-index: 1
@@ -30,10 +31,10 @@
30
31
  left: 45px
31
32
  top: 30px
32
33
  z-index: 3
33
- @media #{$tablet}
34
+ @include media($tablet)
34
35
  left: 20px
35
36
  top: 30px
36
- @media #{$w-374}
37
+ @include media($smallMobile)
37
38
  top: 25px
38
39
  img
39
40
  display: block
@@ -41,52 +42,26 @@
41
42
  height: 82px
42
43
  object-fit: contain
43
44
  object-position: center
44
- @media #{$tablet}
45
+ @include media($tablet)
45
46
  width: 65px
46
47
  height: 65px
47
- @media #{$mobile}
48
+ @include media($mobile)
48
49
  width: 42px
49
50
  height: 42px
50
- @media #{$w-374}
51
+ @include media($smallMobile)
51
52
  width: 36px
52
53
  height: 36px
53
54
 
54
- .widget-tab__panorama-close-map,
55
- .widget-enter-fullscreen,
55
+ .widget-tab__panorama-close-map
56
+ @include rightActionButton
57
+ .widget-enter-fullscreen
58
+ @include rightActionButton
56
59
  .widget-exit-fullscreen
57
- position: absolute
58
- right: 45px
59
- top: 36px
60
- z-index: 3
61
- padding: 10px
62
- touch-action: none
63
- @include customButton
64
- @media #{$tablet}
65
- right: 17px
66
- top: 35px
67
- @media #{$mobile}
68
- padding: 5px
69
- right: 20px
70
- @media #{$w-374}
71
- top: 25px
72
- img
73
- display: block
74
- width: 50px
75
- height: 50px
76
- object-fit: contain
77
- object-position: center
78
- @media #{$tablet}
79
- width: 40px
80
- height: 40px
81
- @media #{$mobile}
82
- width: 32px
83
- height: 32px
84
- @media #{$w-374}
85
- width: 26px
86
- height: 26px
60
+ @include rightActionButton
87
61
 
88
62
  @import './components/tabs'
89
63
  @import './components/instructions'
90
64
  @import './components/panorama'
65
+ @import './components/rotation'
91
66
  @import './components/loader'
92
67
  @import './components/model'
@@ -9,4 +9,40 @@
9
9
  backdrop-filter: blur($blur)
10
10
  -moz-backdrop-filter: blur($blur)
11
11
  -webkit-backdrop-filter: blur($blur)
12
-
12
+
13
+ @mixin media($device)
14
+ $this: &
15
+ @at-root .widget-application--#{$device}#{$this}
16
+ @content
17
+
18
+ @mixin rightActionButton
19
+ position: absolute
20
+ right: 45px
21
+ top: 36px
22
+ z-index: 3
23
+ padding: 10px
24
+ touch-action: none
25
+ @include customButton
26
+ @include media($tablet)
27
+ right: 17px
28
+ top: 35px
29
+ @include media($mobile)
30
+ padding: 5px
31
+ right: 20px
32
+ @include media($smallMobile)
33
+ top: 25px
34
+ img
35
+ display: block
36
+ width: 50px
37
+ height: 50px
38
+ object-fit: contain
39
+ object-position: center
40
+ @include media($tablet)
41
+ width: 40px
42
+ height: 40px
43
+ @include media($mobile)
44
+ width: 32px
45
+ height: 32px
46
+ @include media($smallMobile)
47
+ width: 26px
48
+ height: 26px
@@ -1,8 +1,7 @@
1
- $w-374: "only screen and (max-width: 374px)"
2
- $mobile: "only screen and (max-width: 545px)"
3
- $tablet: "only screen and (max-width: 900px)"
4
- $laptop: "only screen and (max-width: 1440px)"
5
- $desktop: "only screen and (min-width: 1441px)"
1
+ $smallMobile: "smallMobile"
2
+ $mobile: "mobile"
3
+ $tablet: "tablet"
4
+ $laptop: "laptop"
6
5
 
7
6
  $white: #FFFFFF
8
7
  $black: #000000
@@ -15,6 +15,8 @@ var _store = _interopRequireDefault(require("../store"));
15
15
 
16
16
  var _fullScreenStore = _interopRequireDefault(require("../store/fullScreenStore"));
17
17
 
18
+ var _deviceWidth = require("../enums/deviceWidth");
19
+
18
20
  var _RotationTab = _interopRequireDefault(require("./RotationTab"));
19
21
 
20
22
  var _PanoramaTab = _interopRequireDefault(require("./PanoramaTab"));
@@ -43,13 +45,12 @@ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Sy
43
45
 
44
46
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
45
47
 
46
- var Application = (0, _mobxReactLite.observer)(function (_ref) {
47
- var width = _ref.width,
48
- height = _ref.height;
48
+ var Application = (0, _mobxReactLite.observer)(function () {
49
49
  var config = _store.default.config;
50
50
  var appStyle = {
51
- width: width,
52
- height: height
51
+ width: config.width,
52
+ height: config.height,
53
+ '--vh': "".concat(window.innerHeight / 100, "px")
53
54
  };
54
55
 
55
56
  var _useState = (0, _react.useState)(config.tabs[0]),
@@ -80,16 +81,8 @@ var Application = (0, _mobxReactLite.observer)(function (_ref) {
80
81
  tab: 'panorama',
81
82
  text: '3D'
82
83
  }];
83
-
84
- var setWindowHeight = function setWindowHeight() {
85
- document.querySelector('.widget-application').style.setProperty('--vh', window.innerHeight / 100 + 'px');
86
- };
87
-
88
84
  (0, _react.useEffect)(function () {
89
85
  _fullScreenStore.default.init();
90
-
91
- window.addEventListener('resize', setWindowHeight);
92
- setWindowHeight();
93
86
  }, []);
94
87
  (0, _react.useEffect)(function () {
95
88
  if (config.tabs.some(function (tab) {
@@ -111,8 +104,15 @@ var Application = (0, _mobxReactLite.observer)(function (_ref) {
111
104
  });
112
105
  };
113
106
 
107
+ var getAppClass = function getAppClass() {
108
+ var className = (0, _deviceWidth.getDevicesByWidth)(config.width).reduce(function (acc, device) {
109
+ return acc += " widget-application--".concat(device);
110
+ }, 'widget-application');
111
+ return className;
112
+ };
113
+
114
114
  return /*#__PURE__*/_react.default.createElement("main", {
115
- className: "widget-application",
115
+ className: getAppClass(),
116
116
  id: "widget-application",
117
117
  style: appStyle
118
118
  }, /*#__PURE__*/_react.default.createElement("section", {
@@ -268,63 +268,55 @@ var PanoramaTab = function PanoramaTab(_ref4) {
268
268
  setLoadingState = _useState6[1];
269
269
 
270
270
  var _useState7 = (0, _react.useState)({
271
- width: 0,
272
- height: 0
273
- }),
274
- _useState8 = _slicedToArray(_useState7, 2),
275
- windowSize = _useState8[0],
276
- setWindowSize = _useState8[1];
277
-
278
- var _useState9 = (0, _react.useState)({
279
271
  width: '200px',
280
272
  height: 'auto'
281
273
  }),
282
- _useState10 = _slicedToArray(_useState9, 2),
283
- mapSize = _useState10[0],
284
- setMapSize = _useState10[1];
274
+ _useState8 = _slicedToArray(_useState7, 2),
275
+ mapSize = _useState8[0],
276
+ setMapSize = _useState8[1];
285
277
 
286
- var _useState11 = (0, _react.useState)(false),
287
- _useState12 = _slicedToArray(_useState11, 2),
288
- mapOpen = _useState12[0],
289
- setMapState = _useState12[1];
278
+ var _useState9 = (0, _react.useState)(false),
279
+ _useState10 = _slicedToArray(_useState9, 2),
280
+ mapOpen = _useState10[0],
281
+ setMapState = _useState10[1];
290
282
 
291
- var _useState13 = (0, _react.useState)({
283
+ var _useState11 = (0, _react.useState)({
292
284
  X: 1,
293
285
  Y: 1
294
286
  }),
287
+ _useState12 = _slicedToArray(_useState11, 2),
288
+ planScale = _useState12[0],
289
+ setPlanScale = _useState12[1];
290
+
291
+ var _useState13 = (0, _react.useState)(true),
295
292
  _useState14 = _slicedToArray(_useState13, 2),
296
- planScale = _useState14[0],
297
- setPlanScale = _useState14[1];
293
+ isMapDisabled = _useState14[0],
294
+ setMapDisabledState = _useState14[1];
298
295
 
299
- var _useState15 = (0, _react.useState)(true),
296
+ var _useState15 = (0, _react.useState)(false),
300
297
  _useState16 = _slicedToArray(_useState15, 2),
301
- isMapDisabled = _useState16[0],
302
- setMapDisabledState = _useState16[1];
298
+ autoplayEnabled = _useState16[0],
299
+ setAutoplayState = _useState16[1];
303
300
 
304
- var _useState17 = (0, _react.useState)(false),
301
+ var _useState17 = (0, _react.useState)(cameraFovValues.x1),
305
302
  _useState18 = _slicedToArray(_useState17, 2),
306
- autoplayEnabled = _useState18[0],
307
- setAutoplayState = _useState18[1];
303
+ cameraFov = _useState18[0],
304
+ setCameraFov = _useState18[1];
308
305
 
309
- var _useState19 = (0, _react.useState)(cameraFovValues.x1),
306
+ var _useState19 = (0, _react.useState)(0),
310
307
  _useState20 = _slicedToArray(_useState19, 2),
311
- cameraFov = _useState20[0],
312
- setCameraFov = _useState20[1];
308
+ currentRoomIndex = _useState20[0],
309
+ setCurrentRoomIndex = _useState20[1];
313
310
 
314
- var _useState21 = (0, _react.useState)(0),
311
+ var _useState21 = (0, _react.useState)([]),
315
312
  _useState22 = _slicedToArray(_useState21, 2),
316
- currentRoomIndex = _useState22[0],
317
- setCurrentRoomIndex = _useState22[1];
313
+ panoramas = _useState22[0],
314
+ setPanoramas = _useState22[1];
318
315
 
319
- var _useState23 = (0, _react.useState)([]),
316
+ var _useState23 = (0, _react.useState)(null),
320
317
  _useState24 = _slicedToArray(_useState23, 2),
321
- panoramas = _useState24[0],
322
- setPanoramas = _useState24[1];
323
-
324
- var _useState25 = (0, _react.useState)(null),
325
- _useState26 = _slicedToArray(_useState25, 2),
326
- viewer = _useState26[0],
327
- setViewer = _useState26[1];
318
+ viewer = _useState24[0],
319
+ setViewer = _useState24[1];
328
320
 
329
321
  var changePanorama = function changePanorama(panorama) {
330
322
  setCurrentRoomIndex(panorama['panorama_index']);
@@ -334,14 +326,11 @@ var PanoramaTab = function PanoramaTab(_ref4) {
334
326
  var setScale = function setScale() {
335
327
  if (!viewer) return;
336
328
  var image = document.querySelector('.widget-tab__panorama-map img');
337
- var _viewer$container = viewer.container,
338
- clientWidth = _viewer$container.clientWidth,
339
- clientHeight = _viewer$container.clientHeight;
340
329
  var imageWidth = image.naturalWidth;
341
330
  var imageHeight = image.naturalHeight;
342
331
  var imageDelta = imageWidth / imageHeight;
343
332
  var maxWidth = 200;
344
- var maxHeight = clientHeight - 200;
333
+ var maxHeight = _store.default.config.height - 200;
345
334
  var width = maxWidth;
346
335
  var height = width / imageDelta;
347
336
 
@@ -358,7 +347,7 @@ var PanoramaTab = function PanoramaTab(_ref4) {
358
347
  width: width,
359
348
  height: height
360
349
  }, json));
361
- viewer.onWindowResize(clientWidth, clientHeight);
350
+ viewer.onWindowResize(_store.default.config.width, _store.default.config.height);
362
351
  };
363
352
 
364
353
  var onImageLoaded = function onImageLoaded() {
@@ -419,21 +408,6 @@ var PanoramaTab = function PanoramaTab(_ref4) {
419
408
  viewer.enableAutoRate();
420
409
  };
421
410
 
422
- (0, _react.useEffect)(function () {
423
- var onResize = function onResize() {
424
- setWindowSize({
425
- width: window.innerWidth,
426
- height: window.innerHeight
427
- });
428
- closeMap();
429
- };
430
-
431
- onResize();
432
- window.addEventListener('resize', onResize);
433
- return function cleanup() {
434
- window.removeEventListener('resize', onResize);
435
- };
436
- }, []);
437
411
  (0, _react.useEffect)(function () {
438
412
  if (!panoramas.length) return;
439
413
  var container = document.querySelector('.widget-tab__panorama-overlay');
@@ -479,7 +453,7 @@ var PanoramaTab = function PanoramaTab(_ref4) {
479
453
 
480
454
  animate();
481
455
  }, [panoramas]);
482
- (0, _react.useEffect)(setScale, [json, windowSize, viewer]);
456
+ (0, _react.useEffect)(setScale, [json, viewer, _store.default.config.width, _store.default.config.height]);
483
457
  (0, _react.useEffect)(function () {
484
458
  return setPanoramas(getPanoramas(json, images, setLoadingState));
485
459
  }, [json, images]);
@@ -546,7 +520,7 @@ var PanoramaTab = function PanoramaTab(_ref4) {
546
520
  var onMapClick = function onMapClick(event) {
547
521
  if (loadingState) return;
548
522
 
549
- if (windowSize.width <= _deviceWidth.deviceWidth.tablet) {
523
+ if (_store.default.config.width <= _deviceWidth.deviceWidth.tablet) {
550
524
  if (!mapOpen) {
551
525
  openMap();
552
526
  return;
@@ -94,7 +94,7 @@ var RotationTab = function RotationTab(_ref) {
94
94
  speed: 150
95
95
  });
96
96
  newRotation._update = updateRotation;
97
- newRotation.play();
97
+ newRotation.play(true);
98
98
  var lastIndex = 0;
99
99
  var controller = (0, _panzoom.default)(container, {
100
100
  maxZoom: 3,
@@ -11,9 +11,9 @@ var _reactDom = _interopRequireDefault(require("react-dom"));
11
11
 
12
12
  var _store = _interopRequireDefault(require("../store"));
13
13
 
14
- var _modelStore = _interopRequireDefault(require("../store/modelStore"));
14
+ var _fullScreenStore = _interopRequireDefault(require("../store/fullScreenStore"));
15
15
 
16
- var _locale = _interopRequireDefault(require("../locale"));
16
+ var _modelStore = _interopRequireDefault(require("../store/modelStore"));
17
17
 
18
18
  var _Application = _interopRequireDefault(require("./Application"));
19
19
 
@@ -45,16 +45,22 @@ var Widget = /*#__PURE__*/function () {
45
45
 
46
46
  var widgetContainer = document.querySelector(container);
47
47
  if (!widgetContainer) throw new Error("\u041D\u0435 \u0443\u0434\u0430\u043B\u043E\u0441\u044C \u043D\u0430\u0439\u0442\u0438 \u044D\u043B\u0435\u043C\u0435\u043D\u0442: #".concat(container));
48
+
49
+ if (!options.width) {
50
+ config.width = widgetContainer.offsetWidth;
51
+ }
52
+
53
+ if (!options.height) {
54
+ config.height = widgetContainer.offsetHeight;
55
+ }
56
+
48
57
  config.containerElement = widgetContainer;
49
58
 
50
59
  _store.default.setConfig(config);
51
60
 
52
- _locale.default.setCurrentLocale(config.locale);
61
+ _fullScreenStore.default.resize(config);
53
62
 
54
- _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_Application.default, {
55
- width: config.width,
56
- height: config.height
57
- }), widgetContainer);
63
+ _reactDom.default.render( /*#__PURE__*/_react.default.createElement(_Application.default, null), widgetContainer);
58
64
  }
59
65
 
60
66
  _createClass(Widget, [{
@@ -78,7 +84,18 @@ var Widget = /*#__PURE__*/function () {
78
84
 
79
85
  _store.default.setConfig(newConfig);
80
86
 
81
- _locale.default.setCurrentLocale(config.locale);
87
+ _fullScreenStore.default.resize(newConfig);
88
+ }
89
+ }, {
90
+ key: "updateSize",
91
+ value: function updateSize(size) {
92
+ var newConfig = _objectSpread(_objectSpread({}, this.options), size);
93
+
94
+ _modelStore.default.removeHouse();
95
+
96
+ _store.default.setConfig(newConfig);
97
+
98
+ _fullScreenStore.default.resize(newConfig);
82
99
  }
83
100
  }, {
84
101
  key: "on",
@@ -11,13 +11,14 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
11
11
 
12
12
  var defaultConfig = {
13
13
  tabs: ['rotation', 'panorama'],
14
+ name: null,
14
15
  logo: null,
15
16
  logoUrl: null,
16
- width: null,
17
- height: null,
17
+ width: 1920,
18
+ height: 1080,
18
19
  planImage: null,
19
- topView: null,
20
- topDownView: null,
20
+ topViewImage: null,
21
+ rotationMode: 'default',
21
22
  rotationImages: [],
22
23
  panoramaImages: [],
23
24
  json: null,
@@ -3,10 +3,19 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.deviceWidth = void 0;
6
+ exports.getDevicesByWidth = exports.deviceWidth = void 0;
7
7
  var deviceWidth = {
8
+ smallMobile: 374,
8
9
  mobile: 545,
9
- tablet: 900,
10
+ tablet: 1100,
10
11
  laptop: 1440
11
12
  };
12
- exports.deviceWidth = deviceWidth;
13
+ exports.deviceWidth = deviceWidth;
14
+
15
+ var getDevicesByWidth = function getDevicesByWidth(width) {
16
+ return Object.keys(deviceWidth).filter(function (key) {
17
+ return width <= deviceWidth[key];
18
+ });
19
+ };
20
+
21
+ exports.getDevicesByWidth = getDevicesByWidth;
package/build/index.js CHANGED
@@ -9,12 +9,6 @@ Object.defineProperty(exports, "ApiStore", {
9
9
  return _apiStore.default;
10
10
  }
11
11
  });
12
- Object.defineProperty(exports, "ImageTab", {
13
- enumerable: true,
14
- get: function get() {
15
- return _ImageTab.default;
16
- }
17
- });
18
12
  Object.defineProperty(exports, "Instructions", {
19
13
  enumerable: true,
20
14
  get: function get() {
@@ -58,8 +52,6 @@ require("./index.css");
58
52
 
59
53
  var _apiStore = _interopRequireDefault(require("./store/apiStore"));
60
54
 
61
- var _ImageTab = _interopRequireDefault(require("./components/ImageTab"));
62
-
63
55
  var _Instructions = _interopRequireDefault(require("./components/Instructions"));
64
56
 
65
57
  var _Loader = _interopRequireDefault(require("./components/Loader"));