@iris.interactive/handcook 2.10.17 → 2.10.18

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.10.17-blue.svg?cacheSeconds=2592000)
2
+ ![Version](https://img.shields.io/badge/version-2.10.18-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.10.17",
3
+ "version": "2.10.18",
4
4
  "description": "The web cooking by IRIS Interactive",
5
5
  "main": "./public/scripts/index.js",
6
6
  "scripts": {
@@ -19,12 +19,19 @@ import ElementEnum from "../../enumerators/element.enum";
19
19
  export class HcScrollReveal {
20
20
 
21
21
  constructor() {
22
- //Config default
23
- let distance = '0px';
24
- let delay = 200;
25
- let duration = 800;
26
- let interval = 0;
27
- let origin = 'bottom';
22
+ //Default
23
+ const distanceDefault = '0px';
24
+ const distanceDelay = 200;
25
+ const distanceDuration = 800;
26
+ const distanceInterval = 0;
27
+ const distanceOrigin = 'bottom';
28
+
29
+ //Config
30
+ let distance = distanceDefault;
31
+ let delay = distanceDelay;
32
+ let duration = distanceDuration;
33
+ let interval = distanceInterval;
34
+ let origin = distanceOrigin;
28
35
 
29
36
  //Children by parent
30
37
  const parents = document.querySelectorAll(ElementEnum.scrollRevealParent);
@@ -32,26 +39,37 @@ export class HcScrollReveal {
32
39
 
33
40
  if (parent.hasAttribute('data-hc-scroll-reveal-distance')) {
34
41
  distance = parent.getAttribute('data-hc-scroll-reveal-distance');
42
+ } else {
43
+ distance = distanceDefault;
35
44
  }
36
45
 
37
46
  if (parent.hasAttribute('data-hc-scroll-reveal-delay')) {
38
47
  delay = parent.getAttribute('data-hc-scroll-reveal-delay');
48
+ } else {
49
+ delay = distanceDelay;
39
50
  }
40
51
 
41
52
  if (parent.hasAttribute('data-hc-scroll-reveal-duration')) {
42
53
  duration = parent.getAttribute('data-hc-scroll-reveal-duration');
54
+ } else {
55
+ duration = distanceDuration;
43
56
  }
44
57
 
45
58
  if (parent.hasAttribute('data-hc-scroll-reveal-interval')) {
46
59
  interval = parent.getAttribute('data-hc-scroll-reveal-interval');
60
+ } else {
61
+ interval = distanceInterval;
47
62
  }
48
63
 
49
64
  if (parent.hasAttribute('data-hc-scroll-reveal-origin')) {
50
65
  origin = parent.getAttribute('data-hc-scroll-reveal-origin');
66
+ } else {
67
+ origin = distanceOrigin;
51
68
  }
52
69
 
70
+ //Add enumerator + eviter saut au chargement
53
71
  Array.prototype.forEach.call(parent.children, child => {
54
- if (!child.hasAttribute('data-hc-noscroll-reveal')) {
72
+ if (!child.hasAttribute('data-hc-noscroll-reveal') && !child.hasAttribute('data-hc-scroll-reveal-child') && !child.hasAttribute(ElementEnum.scrollRevealParent)) {
55
73
  child.setAttribute('data-hc-scroll-reveal-child', '');
56
74
  }
57
75
  });
@@ -62,6 +80,9 @@ export class HcScrollReveal {
62
80
  duration: duration,
63
81
  interval: interval,
64
82
  origin: origin,
83
+ beforeReveal: function (element) {
84
+ element.classList.add('hc-scroll-reveal-is-visible');
85
+ },
65
86
  });
66
87
  });
67
88
 
@@ -71,22 +92,32 @@ export class HcScrollReveal {
71
92
 
72
93
  if (item.hasAttribute('data-hc-scroll-reveal-distance')) {
73
94
  distance = item.getAttribute('data-hc-scroll-reveal-distance');
95
+ } else {
96
+ distance = distanceDefault;
74
97
  }
75
98
 
76
99
  if (item.hasAttribute('data-hc-scroll-reveal-delay')) {
77
100
  delay = item.getAttribute('data-hc-scroll-reveal-delay');
101
+ } else {
102
+ delay = distanceDelay;
78
103
  }
79
104
 
80
105
  if (item.hasAttribute('data-hc-scroll-reveal-duration')) {
81
106
  duration = item.getAttribute('data-hc-scroll-reveal-duration');
107
+ } else {
108
+ duration = distanceDuration;
82
109
  }
83
110
 
84
111
  if (item.hasAttribute('data-hc-scroll-reveal-interval')) {
85
112
  interval = item.getAttribute('data-hc-scroll-reveal-interval');
113
+ } else {
114
+ interval = distanceInterval;
86
115
  }
87
116
 
88
117
  if (item.hasAttribute('data-hc-scroll-reveal-origin')) {
89
118
  origin = item.getAttribute('data-hc-scroll-reveal-origin');
119
+ } else {
120
+ origin = distanceOrigin;
90
121
  }
91
122
 
92
123
  ScrollReveal().reveal(item, {
@@ -95,6 +126,9 @@ export class HcScrollReveal {
95
126
  duration: duration,
96
127
  interval: interval,
97
128
  origin: origin,
129
+ beforeReveal: function (element) {
130
+ element.classList.add('hc-scroll-reveal-is-visible');
131
+ },
98
132
  });
99
133
  });
100
134
  }