@iris.interactive/handcook 2.6.11 → 2.6.14

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/README.md CHANGED
@@ -1,5 +1,5 @@
1
1
  # Welcome to HandCook 👨‍🍳
2
- ![Version](https://img.shields.io/badge/version-2.6.3-blue.svg?cacheSeconds=2592000)
2
+ ![Version](https://img.shields.io/badge/version-2.6.14-blue.svg?cacheSeconds=2592000)
3
3
  ![Prerequisite](https://img.shields.io/badge/node-%3E%3D%2012.14.0-blue.svg)
4
4
  [![License: UNLICENSED](https://img.shields.io/badge/License-UNLICENSED-yellow.svg)](#)
5
5
  [![Twitter: captain\_iris](https://img.shields.io/twitter/follow/captain\_iris.svg?style=social)](https://twitter.com/captain\_iris)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iris.interactive/handcook",
3
- "version": "2.6.11",
3
+ "version": "2.6.14",
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;
@@ -25,11 +25,11 @@ export class HcSlider {
25
25
  // Options
26
26
  options = {};
27
27
 
28
- constructor(elements = ElementEnum.slider) {
28
+ constructor(elements = ElementEnum.slider, options = {}) {
29
29
  this.initOptions();
30
30
  document.querySelectorAll(elements).forEach(element => {
31
31
  this.slider = element;
32
- this.setOptions();
32
+ this.setOptions(options);
33
33
  this.buildDom();
34
34
  const instance = new Swiper(element, this.options);
35
35
  this.instances.push(instance);
@@ -37,7 +37,7 @@ export class HcSlider {
37
37
  });
38
38
  }
39
39
 
40
- setOptions() {
40
+ setOptions(options) {
41
41
  const attr = this.slider.getAttribute('data-hc-slider-autoplay');
42
42
  if (attr !== null) {
43
43
  this.options['autoplay'] = {
@@ -87,6 +87,9 @@ export class HcSlider {
87
87
  enabled: true
88
88
  }
89
89
  }
90
+
91
+ // Override option passing in function js
92
+ Object.assign( this.options, options );
90
93
  }
91
94
 
92
95
  buildDom() {
@@ -157,6 +160,7 @@ export class HcSlider {
157
160
 
158
161
  // layout
159
162
  swiper.$el.find('.swiper-wrapper').addClass('hc-slider-wrapper');
163
+ swiper.$el.addClass('hc-slider-initialized');
160
164
 
161
165
  // slide item
162
166
  swiper.$el.find('.swiper-slide').addClass('hc-slider-slide');
@@ -185,7 +189,7 @@ export class HcSlider {
185
189
  }
186
190
  }
187
191
 
188
- const hc_slider = function (trigger) {
189
- return new HcSlider(trigger);
192
+ const hc_slider = function (trigger, options) {
193
+ return new HcSlider(trigger, options);
190
194
  }
191
195
  export default hc_slider;
@@ -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