js-cloudimage-360-view 2.7.11 → 2.7.12

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/CHANGELOG.md CHANGED
@@ -25,6 +25,10 @@ Types of changes:
25
25
  - ...
26
26
 
27
27
  -------------
28
+ ## 2.7.12 - 2022-03-19
29
+ ### Changed
30
+ - hotspots init method
31
+
28
32
  ## 2.7.11 - 2022-03-17
29
33
  ### Fixed
30
34
  - canvas aspect ratio
package/README.md CHANGED
@@ -1,4 +1,4 @@
1
- [![Release](https://img.shields.io/badge/release-v2.7.11-blue.svg)](https://github.com/scaleflex/js-cloudimage-360-view/releases)
1
+ [![Release](https://img.shields.io/badge/release-v2.7.12-blue.svg)](https://github.com/scaleflex/js-cloudimage-360-view/releases)
2
2
  [![Contributions welcome](https://img.shields.io/badge/contributions-welcome-orange.svg)](#contributing)
3
3
  [![License](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)
4
4
  [![Scaleflex team](https://img.shields.io/badge/%3C%2F%3E%20with%20%E2%99%A5%20by-the%20Scaleflex%20team-6986fa.svg)](https://www.scaleflex.it/en/home)
@@ -23,12 +23,14 @@ require("./static/css/hotspots.css");
23
23
 
24
24
  var _utils = require("./utils");
25
25
 
26
+ var _togglePopupEvents = require("./utils/hotspots/toggle-popup-events");
27
+
26
28
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
27
29
 
28
30
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
29
31
 
30
32
  var CI360Viewer = /*#__PURE__*/function () {
31
- function CI360Viewer(container, fullscreen, hotspotConfig) {
33
+ function CI360Viewer(container, fullscreen, hotspotsConfigs) {
32
34
  (0, _classCallCheck2.default)(this, CI360Viewer);
33
35
  this.container = container;
34
36
  this.movementStart = {
@@ -52,7 +54,7 @@ var CI360Viewer = /*#__PURE__*/function () {
52
54
  this.devicePixelRatio = Math.round(window.devicePixelRatio || 1);
53
55
  this.isMobile = !!('ontouchstart' in window || navigator.msMaxTouchPoints);
54
56
  this.id = container.id;
55
- this.hotspotConfig = hotspotConfig && (0, _utils.generateHotspotsConfigs)(hotspotConfig);
57
+ this.hotspotsConfigs = hotspotsConfigs && (0, _utils.generateHotspotsConfigs)(hotspotsConfigs);
56
58
  this.isMagnifyOpen = false;
57
59
  this.isDragged = false;
58
60
  this.startPointerZoom = false;
@@ -108,6 +110,10 @@ var CI360Viewer = /*#__PURE__*/function () {
108
110
  this.isClicked = true;
109
111
  this.isDragged = false;
110
112
 
113
+ if (this.hotspotsConfigs) {
114
+ (0, _togglePopupEvents.togglePopupEvents)(this.hotspotsConfigs, event, true);
115
+ }
116
+
111
117
  if (isMouseOnHotspotElement) {
112
118
  this.isClicked = false;
113
119
  }
@@ -129,6 +135,10 @@ var CI360Viewer = /*#__PURE__*/function () {
129
135
  this.show360ViewCircleIcon();
130
136
  }
131
137
 
138
+ if (this.hotspotsConfigs) {
139
+ (0, _togglePopupEvents.togglePopupEvents)(this.hotspotsConfigs);
140
+ }
141
+
132
142
  if (this.pointerZoom && !this.fullscreenView) {
133
143
  setTimeout(function () {
134
144
  _this.isZoomReady = true;
@@ -234,7 +244,7 @@ var CI360Viewer = /*#__PURE__*/function () {
234
244
 
235
245
  var _zoomSteps = (0, _utils.generateZoomInSteps)(this.pointerZoom);
236
246
 
237
- if (this.hotspotConfig) {
247
+ if (this.hotspotsConfigs) {
238
248
  (0, _utils.hideHotspotsIcons)();
239
249
  }
240
250
 
@@ -766,8 +776,8 @@ var CI360Viewer = /*#__PURE__*/function () {
766
776
  if (this.mouseTracked) {
767
777
  this.updateImageScale(ctx);
768
778
  } else {
769
- if (this.hotspotConfig && !this.autoplay) {
770
- (0, _utils.updateHotspots)(this.container, this.hotspotConfig, this.activeImageX, this.activeImageY, this.movingDirection);
779
+ if (this.hotspotsConfigs && !this.autoplay) {
780
+ (0, _utils.updateHotspots)(this.container, this.hotspotsConfigs, this.activeImageX, this.activeImageY, this.movingDirection, this.isClicked);
771
781
  }
772
782
 
773
783
  ctx.drawImage(image, 0, 0, this.canvas.width, this.canvas.height);
@@ -852,8 +862,8 @@ var CI360Viewer = /*#__PURE__*/function () {
852
862
  this.addFullscreenIcon();
853
863
  }
854
864
 
855
- if (this.hotspotConfig && !this.autoplay) {
856
- (0, _utils.updateHotspots)(this.container, this.hotspotConfig, this.activeImageX, this.activeImageY, this.movingDirection);
865
+ if (this.hotspotsConfigs && !this.autoplay) {
866
+ (0, _utils.updateHotspots)(this.container, this.hotspotsConfigs, this.activeImageX, this.activeImageY, this.movingDirection);
857
867
  }
858
868
  }
859
869
  }, {
@@ -885,6 +895,10 @@ var CI360Viewer = /*#__PURE__*/function () {
885
895
  }
886
896
 
887
897
  this.initControls();
898
+
899
+ if (this.hotspotsConfigs && !this.autoplay) {
900
+ (0, _utils.updateHotspots)(this.container, this.hotspotsConfigs, this.activeImageX, this.activeImageY, this.movingDirection);
901
+ }
888
902
  }
889
903
  }, {
890
904
  key: "magnify",
@@ -921,7 +935,7 @@ var CI360Viewer = /*#__PURE__*/function () {
921
935
  event.stopPropagation();
922
936
  if (this.mouseTracked) this.togglePointerZoom();
923
937
  var fullscreenContainer = (0, _utils.createFullscreenModal)(this.container);
924
- new CI360Viewer(fullscreenContainer, true, this.hotspotConfig);
938
+ new CI360Viewer(fullscreenContainer, true, this.hotspotsConfigs);
925
939
  }
926
940
  }, {
927
941
  key: "setFullscreenEvents",
@@ -1342,8 +1356,8 @@ var CI360Viewer = /*#__PURE__*/function () {
1342
1356
  this.canvas = (0, _utils.createCanvas)(this.innerBox);
1343
1357
  this.loader = (0, _utils.createLoader)(this.innerBox);
1344
1358
 
1345
- if (this.hotspotConfig && !this.fullscreenView) {
1346
- (0, _utils.createHotspots)(container, this.hotspotConfig);
1359
+ if (this.hotspotsConfigs && !this.fullscreenView) {
1360
+ (0, _utils.createHotspots)(container, this.hotspotsConfigs);
1347
1361
  }
1348
1362
 
1349
1363
  (0, _utils.applyStylesToContainer)(this.container);
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.setView360Icon = exports.get360ViewProps = exports.debounce = exports.attr = void 0;
6
+ exports.setView360Icon = exports.isTrue = exports.get360ViewProps = exports.debounce = exports.attr = void 0;
7
7
 
8
8
  var _constants = require("./constants");
9
9
 
@@ -59,6 +59,8 @@ var isTrue = function isTrue(image, type) {
59
59
  return imgProp !== null && imgProp !== 'false' || imgDataProp !== null && imgDataProp !== 'false';
60
60
  };
61
61
 
62
+ exports.isTrue = isTrue;
63
+
62
64
  var attr = function attr(element, attribute) {
63
65
  return element.getAttribute(attribute);
64
66
  };
package/dist/index.js CHANGED
@@ -12,7 +12,7 @@ var _ci = _interopRequireDefault(require("./ci360.service"));
12
12
 
13
13
  var _ci2 = require("./ci360.utils");
14
14
 
15
- function setContainerId(container) {
15
+ function getContainerWithId(container) {
16
16
  var containerId = container.id;
17
17
 
18
18
  if (!containerId) {
@@ -27,12 +27,13 @@ function setContainerId(container) {
27
27
  function init() {
28
28
  var viewers = [];
29
29
  var view360Array = document.querySelectorAll('.cloudimage-360:not(.initialized)');
30
- var hotspotsConfigs = window.CI360.hotspots || {};
31
- [].slice.call(view360Array).forEach(function (container) {
32
- var containerWithId = setContainerId(container);
33
- var hotspotInstanceName = (0, _ci2.attr)(containerWithId, 'hotspot-instance') || (0, _ci2.attr)(containerWithId, 'data-hotspot-instance');
34
- var hotspotConfig = hotspotsConfigs === null || hotspotsConfigs === void 0 ? void 0 : hotspotsConfigs[hotspotInstanceName];
35
- viewers.push(new _ci.default(containerWithId, false, hotspotConfig));
30
+ [].slice.call(view360Array).forEach(function (_container) {
31
+ var container = getContainerWithId(_container);
32
+ var isHotspotsEnabled = (0, _ci2.isTrue)(container, 'hotspots');
33
+
34
+ if (!isHotspotsEnabled) {
35
+ viewers.push(new _ci.default(container));
36
+ }
36
37
  });
37
38
  window.CI360._viewers = viewers;
38
39
  }
@@ -93,12 +94,24 @@ function isNoViewers() {
93
94
  return !(window.CI360._viewers && window.CI360._viewers.length > 0);
94
95
  }
95
96
 
97
+ function addHotspots(instanceId, config) {
98
+ var view360Array = document.querySelectorAll('.cloudimage-360:not(.initialized)');
99
+ var container = Array.from(view360Array).find(function (view) {
100
+ return view.id === instanceId;
101
+ });
102
+
103
+ if (container) {
104
+ window.CI360._viewers.push(new _ci.default(container, false, config));
105
+ }
106
+ }
107
+
96
108
  window.CI360 = window.CI360 || {};
97
109
  window.CI360.init = init;
98
110
  window.CI360.destroy = destroy;
99
111
  window.CI360.getActiveIndexByID = getActiveIndexByID;
100
112
  window.CI360.update = update;
101
113
  window.CI360.add = add;
114
+ window.CI360.addHotspots = addHotspots;
102
115
 
103
116
  if (!window.CI360.notInitOnLoad) {
104
117
  init();
@@ -35,7 +35,7 @@
35
35
  border: 1px solid #FFFFFF33;
36
36
  border-radius: 50%;
37
37
  box-sizing: border-box;
38
- transition: opacity 800ms ease-in-out;
38
+ transition: opacity 300ms ease-in-out;
39
39
  cursor: auto;
40
40
  }
41
41
 
@@ -61,7 +61,7 @@
61
61
  .cloudimage-360-hotspot-custom-icon::after {
62
62
  content: '+';
63
63
  position: absolute;
64
- width: 8px;
64
+ line-height: 20px;
65
65
  left: 50%;
66
66
  top: 100%;
67
67
  color: #FFF;
@@ -131,6 +131,8 @@
131
131
  .cloudimage-360-images-carousel .cloudimage-360-carousel-image {
132
132
  display: none;
133
133
  min-height: 187px;
134
+ max-width: 100%;
135
+ max-height: 100%;
134
136
  }
135
137
 
136
138
  .cloudimage-360-images-carousel .cloudimage-360-carousel-image.active-image {
@@ -194,10 +196,10 @@
194
196
  padding: 4px 8px;
195
197
  transition: background-color 200ms ease-in-out;
196
198
  border-radius: 2px;
199
+ text-decoration: none;
197
200
  }
198
201
 
199
202
  .cloudimage-360-modal-more-details:hover {
200
- text-decoration: none;
201
203
  color: #76AD01;
202
204
  background-color: #e1f5d8;
203
205
  }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.hidePopup = void 0;
7
+
8
+ var hidePopup = function hidePopup(popup, isVisible) {
9
+ if (!isVisible) {
10
+ popup.removeAttribute('data-show');
11
+ popup.removeAttribute('data-cloudimage-360-show');
12
+ }
13
+ };
14
+
15
+ exports.hidePopup = hidePopup;
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.showPopup = void 0;
7
+
8
+ var showPopup = function showPopup(popup, popperInstance) {
9
+ popup.setAttribute('data-show', '');
10
+ popup.setAttribute('data-cloudimage-360-show', '');
11
+ popperInstance.update();
12
+ };
13
+
14
+ exports.showPopup = showPopup;
@@ -5,34 +5,59 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createHotspotIcon = void 0;
7
7
 
8
+ var _hidePopup = require("../attach-events/hide-popup");
9
+
10
+ var _showPopup = require("../attach-events/show-popup");
11
+
8
12
  var _hideHotspotIcon = require("../hide-hotspot-icon");
9
13
 
10
- var createHotspotIcon = function createHotspotIcon(container, hotspotConfig) {
14
+ var createHotspotIcon = function createHotspotIcon(container, hotspotConfig, popup, popperInstance) {
11
15
  var indicatorSelector = hotspotConfig.indicatorSelector,
12
16
  variant = hotspotConfig.variant;
13
17
  var url = variant.url,
14
18
  anchorId = variant.anchorId;
19
+ var _hotspotConfig$popupP = hotspotConfig.popupProps.open,
20
+ open = _hotspotConfig$popupP === void 0 ? false : _hotspotConfig$popupP;
21
+ var isVisible;
15
22
  var hotspotIcon = document.createElement('div');
16
-
17
- var mouseEnterHotspot = function mouseEnterHotspot() {
18
- hotspotIcon.setAttribute('data-cloudimage-360-show', '');
19
- };
20
-
21
- var mouseLeaveHotspot = function mouseLeaveHotspot() {
22
- hotspotIcon.removeAttribute('data-cloudimage-360-show');
23
- };
24
-
25
23
  hotspotIcon.style.position = 'absolute';
26
24
  hotspotIcon.className = "cloudimage-360-hotspot-".concat(url ? 'link' : 'custom', "-icon ").concat(indicatorSelector);
27
25
  hotspotIcon.setAttribute('data-hotspot-icon-id', anchorId);
28
26
  hotspotIcon.setAttribute('data-cloudimage-360-hotspot', '');
29
- hotspotIcon.addEventListener('mouseenter', mouseEnterHotspot);
30
- hotspotIcon.addEventListener('mouseleave', mouseLeaveHotspot);
27
+
28
+ var popupMouseEnter = function popupMouseEnter() {
29
+ isVisible = true;
30
+ };
31
+
32
+ var popupMouseLeave = function popupMouseLeave() {
33
+ isVisible = false;
34
+ !open && (0, _hidePopup.hidePopup)(popup, isVisible);
35
+ };
31
36
 
32
37
  hotspotIcon.onclick = function (e) {
33
38
  return e.stopPropagation();
34
39
  };
35
40
 
41
+ var showEvents = ['mouseenter', 'touchstart', 'focus'];
42
+ var hideEvents = ['mouseleave', 'blur'];
43
+ showEvents.forEach(function (event) {
44
+ hotspotIcon.addEventListener(event, function () {
45
+ return (0, _showPopup.showPopup)(popup, popperInstance);
46
+ });
47
+ });
48
+
49
+ if (!open) {
50
+ hideEvents.forEach(function (event) {
51
+ hotspotIcon.addEventListener(event, function () {
52
+ return setTimeout(function () {
53
+ return (0, _hidePopup.hidePopup)(popup, isVisible);
54
+ }, 160);
55
+ });
56
+ });
57
+ }
58
+
59
+ popup.addEventListener('mouseenter', popupMouseEnter);
60
+ popup.addEventListener('mouseleave', popupMouseLeave);
36
61
  (0, _hideHotspotIcon.hideHotspotIcon)(hotspotIcon);
37
62
  container.appendChild(hotspotIcon);
38
63
  return hotspotIcon;
@@ -5,6 +5,8 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.createHotspots = void 0;
7
7
 
8
+ var _createPopperInstace = require("../create-popper-instace");
9
+
8
10
  var _createHotspotIcon = require("./create-hotspot-icon");
9
11
 
10
12
  var _createPopup = require("./create-popup");
@@ -12,8 +14,11 @@ var _createPopup = require("./create-popup");
12
14
  var createHotspots = function createHotspots(container, hotspotsProps) {
13
15
  hotspotsProps.forEach(function (hotspotProps) {
14
16
  var popupProps = hotspotProps.popupProps;
15
- (0, _createPopup.createPopup)(container, hotspotProps, popupProps);
16
- (0, _createHotspotIcon.createHotspotIcon)(container, hotspotProps);
17
+ var popup = (0, _createPopup.createPopup)(container, hotspotProps, popupProps);
18
+ var popperInstance = (0, _createPopperInstace.createPopperInstance)(popup, popupProps, container);
19
+ var hotspotIcon = (0, _createHotspotIcon.createHotspotIcon)(container, hotspotProps, popup, popperInstance);
20
+ popperInstance.state.elements.reference = hotspotIcon;
21
+ popperInstance.update();
17
22
  });
18
23
  };
19
24
 
@@ -5,16 +5,9 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.getHotspotPopupNode = void 0;
7
7
 
8
- var getHotspotPopupNode = function getHotspotPopupNode(anchorId, open, currentPosition) {
8
+ var getHotspotPopupNode = function getHotspotPopupNode(anchorId) {
9
9
  var hotspotPopupSelector = "[data-hotspot-popup-id=".concat(anchorId, "]");
10
10
  var hotspotPopup = document.querySelector(hotspotPopupSelector);
11
-
12
- if (open && currentPosition) {
13
- hotspotPopup.setAttribute('data-show', '');
14
- } else {
15
- hotspotPopup.removeAttribute('data-show');
16
- }
17
-
18
11
  return hotspotPopup;
19
12
  };
20
13
 
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.togglePopupEvents = void 0;
7
+
8
+ var _ci = require("../../ci360.utils");
9
+
10
+ var _getHotspotIcon = require("./get-hotspot-icon");
11
+
12
+ var togglePopupEvents = function togglePopupEvents(hotspotsProps, event, isMouseDown) {
13
+ var iClickOnHotspotIcon = event && (0, _ci.isTrue)(event.target, 'data-cloudimage-360-hotspot');
14
+ if (iClickOnHotspotIcon) return;
15
+ hotspotsProps.forEach(function (hotspotProps) {
16
+ var variant = hotspotProps.variant;
17
+ var anchorId = variant.anchorId;
18
+ var hotspotIcon = (0, _getHotspotIcon.getHotspotIcon)(anchorId);
19
+ hotspotIcon.style.pointerEvents = isMouseDown ? 'none' : 'all';
20
+ });
21
+ };
22
+
23
+ exports.togglePopupEvents = togglePopupEvents;
@@ -5,12 +5,6 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.updateHotspots = void 0;
7
7
 
8
- var _getHotspotPopupNode = require("./get-hotspot-popup-node");
9
-
10
- var _createPopperInstace = require("./create-popper-instace");
11
-
12
- var _attachPopupEvents = require("./attach-popup-events");
13
-
14
8
  var _prepareHotspotsPositions = require("./prepare-hotspots-positions");
15
9
 
16
10
  var _getHotspotIcon = require("./get-hotspot-icon");
@@ -26,25 +20,18 @@ var updateHotspots = function updateHotspots(container, hotspotsProps) {
26
20
  var activeImageY = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 0;
27
21
  var movingDirection = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 'x-axis';
28
22
  hotspotsProps.forEach(function (hotspotProps) {
29
- var popupProps = hotspotProps.popupProps,
30
- hotspots = hotspotProps.hotspots,
23
+ var hotspots = hotspotProps.hotspots,
31
24
  initialDimensions = hotspotProps.initialDimensions,
32
25
  orientation = hotspotProps.orientation,
33
26
  variant = hotspotProps.variant;
27
+ var anchorId = variant.anchorId;
34
28
  var hotspotOriantaion = (0, _getHotspotOrientation.getHotspotOriantaion)(movingDirection);
35
29
  var currentImageIndex = orientation === 'x' ? activeImageX : activeImageY;
36
- var open = popupProps.open;
37
- var anchorId = variant.anchorId;
38
30
  var hotspotsPositions = (0, _prepareHotspotsPositions.prepareHotspotsPositions)(hotspots);
39
31
  var currentPosition = hotspotsPositions.find(function (hotspotPosition) {
40
32
  return hotspotPosition.imageIndex === currentImageIndex;
41
33
  });
42
- var popup = (0, _getHotspotPopupNode.getHotspotPopupNode)(anchorId, open, currentPosition);
43
34
  var hotspotIcon = (0, _getHotspotIcon.getHotspotIcon)(anchorId);
44
- var popperInstance = (0, _createPopperInstace.createPopperInstance)(popup, popupProps, container);
45
- popperInstance.state.elements.reference = hotspotIcon;
46
- popperInstance.update();
47
- (0, _attachPopupEvents.attachPopupEvents)(hotspotIcon, popup, popperInstance, open);
48
35
 
49
36
  if (currentPosition && hotspotOriantaion === orientation) {
50
37
  var _currentPosition$xCoo = currentPosition.xCoord,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "js-cloudimage-360-view",
3
- "version": "2.7.11",
3
+ "version": "2.7.12",
4
4
  "main": "dist/index.js",
5
5
  "description": "",
6
6
  "author": "scaleflex",
@@ -1,63 +0,0 @@
1
- "use strict";
2
-
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
-
5
- Object.defineProperty(exports, "__esModule", {
6
- value: true
7
- });
8
- exports.attachPopupEvents = void 0;
9
-
10
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
11
-
12
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
-
14
- function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
15
-
16
- function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
-
18
- var attachPopupEvents = function attachPopupEvents(reference, popper, popperInstance, open) {
19
- if (open) return;
20
- var showEvents = ['mouseenter', 'touchstart', 'focus'];
21
- var hideEvents = ['mouseleave', 'blur'];
22
- var isVisible;
23
-
24
- var showPopup = function showPopup() {
25
- popper.setAttribute('data-show', '');
26
- popper.setAttribute('data-cloudimage-360-show', '');
27
- popperInstance.update();
28
- };
29
-
30
- var hidePopup = function hidePopup() {
31
- setTimeout(function () {
32
- if (!isVisible) {
33
- popper.removeAttribute('data-show');
34
- popper.removeAttribute('data-cloudimage-360-show');
35
- popperInstance.setOptions(function (options) {
36
- return _objectSpread(_objectSpread({}, options), {}, {
37
- modifiers: [].concat((0, _toConsumableArray2.default)(options.modifiers), [{
38
- name: 'eventListeners',
39
- enabled: false
40
- }])
41
- });
42
- });
43
- } else {
44
- isVisible = false;
45
- }
46
- }, 160);
47
- };
48
-
49
- var keepPopupShown = function keepPopupShown() {
50
- isVisible = true;
51
- };
52
-
53
- showEvents.forEach(function (event) {
54
- reference.addEventListener(event, showPopup);
55
- });
56
- hideEvents.forEach(function (event) {
57
- reference.addEventListener(event, hidePopup);
58
- });
59
- popper.addEventListener('mouseenter', keepPopupShown);
60
- popper.addEventListener('mouseleave', hidePopup);
61
- };
62
-
63
- exports.attachPopupEvents = attachPopupEvents;