@iris.interactive/handcook 2.6.10 → 2.6.13

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iris.interactive/handcook",
3
- "version": "2.6.10",
3
+ "version": "2.6.13",
4
4
  "description": "The web cooking by IRIS Interactive",
5
5
  "main": "./public/scripts/index.js",
6
6
  "scripts": {
@@ -16,13 +16,16 @@
16
16
 
17
17
  import LazyLoad from "vanilla-lazyload";
18
18
 
19
- const hc_lazyload = function() {
20
- return new LazyLoad({
19
+ const hc_lazyload = function (options = {}) {
20
+
21
+ options = Object.assign({
21
22
  elements_selector: '[data-hc-src], [data-hc-bg], [data-hc-bg-hidpi]',
22
23
  data_src: 'hc-src',
23
24
  data_bg: 'hc-bg',
24
25
  data_bg_hidpi: 'hc-bg-hidpi'
25
- });
26
+ }, options)
27
+
28
+ return new LazyLoad(options);
26
29
  }
27
30
 
28
31
  export default hc_lazyload;
@@ -20,9 +20,12 @@ import './modal.component.scss';
20
20
 
21
21
  export class HcModal {
22
22
 
23
+ showEvent;
24
+ hideEvent;
23
25
  options = {};
24
26
 
25
27
  constructor(elements = ElementEnum.modal, overrideOptions = {}) {
28
+ this.createEvent();
26
29
  document.querySelectorAll(elements).forEach(element => {
27
30
  Fancybox.bind(element);
28
31
  element.addEventListener('click', (e) => {
@@ -31,7 +34,16 @@ export class HcModal {
31
34
  Object.assign(this.options, overrideOptions);
32
35
  this.options.src = this.options.src != '' ? this.options.src : (e.currentTarget.hasAttribute('href') ? e.currentTarget.getAttribute('href') : (e.currentTarget.hasAttribute('data-hc-src') ? e.currentTarget.dataset.hcSrc : ''));
33
36
  this.options.parentEl = this.options.parentEl !== null ? document.querySelector(this.options.parentEl) : (e.currentTarget.hasAttribute('data-hc-modal-parent') ? document.querySelector(e.currentTarget.getAttribute('data-hc-modal-parent')) : '');
34
- Fancybox.show([this.options]);
37
+ Fancybox.show([this.options], {
38
+ on: {
39
+ reveal: () => {
40
+ document.dispatchEvent(this.showEvent);
41
+ },
42
+ closing: () => {
43
+ document.dispatchEvent(this.hideEvent);
44
+ }
45
+ }
46
+ });
35
47
  });
36
48
  });
37
49
  }
@@ -48,9 +60,14 @@ export class HcModal {
48
60
  this.options = {
49
61
  src: '',
50
62
  type: 'inline',
51
- parentEl: null
63
+ parentEl: null,
52
64
  };
53
65
  }
66
+
67
+ createEvent() {
68
+ this.showEvent = new Event("show.hc.modal");
69
+ this.hideEvent = new Event("hide.hc.modal");
70
+ }
54
71
  }
55
72
 
56
73
  const hc_modal = function (trigger, options) {
@@ -157,6 +157,7 @@ export class HcSlider {
157
157
 
158
158
  // layout
159
159
  swiper.$el.find('.swiper-wrapper').addClass('hc-slider-wrapper');
160
+ swiper.$el.addClass('hc-slider-initialized');
160
161
 
161
162
  // slide item
162
163
  swiper.$el.find('.swiper-slide').addClass('hc-slider-slide');
@@ -61,10 +61,18 @@ export class HcTab {
61
61
  }
62
62
 
63
63
  createEvent() {
64
- this.showEvent = new Event("show.hc.collapse");
65
- this.shownEvent = new Event("shown.hc.collapse");
66
- this.hideEvent = new Event("hide.hc.collapse");
67
- this.hiddenEvent = new Event("hidden.hc.collapse");
64
+ this.showEvent = new Event("show.hc.tab");
65
+ this.shownEvent = new Event("shown.hc.tab");
66
+ this.hideEvent = new Event("hide.hc.tab");
67
+ this.hiddenEvent = new Event("hidden.hc.tab");
68
+ }
69
+
70
+ static show(trigger) {
71
+ var triggerTabList = [].slice.call(document.querySelectorAll(trigger));
72
+ triggerTabList.forEach(function (triggerEl) {
73
+ var tabTrigger = new Tab(triggerEl)
74
+ tabTrigger.show();
75
+ });
68
76
  }
69
77
  }
70
78