@cocreate/scroll 1.3.3 → 1.3.6

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
@@ -1,3 +1,24 @@
1
+ ## [1.3.6](https://github.com/CoCreate-app/CoCreate-scroll/compare/v1.3.5...v1.3.6) (2022-06-22)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * compare datetime to break infinite loop on scroll up and scroll down ([c86b317](https://github.com/CoCreate-app/CoCreate-scroll/commit/c86b3170a9335acf895006de54d10b2cc3fc2ab0))
7
+
8
+ ## [1.3.5](https://github.com/CoCreate-app/CoCreate-scroll/compare/v1.3.4...v1.3.5) (2022-06-19)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * removed scroll-element support as it was causing a loop. Moved to branch newScroll fordebugging ([f8d99c7](https://github.com/CoCreate-app/CoCreate-scroll/commit/f8d99c707b0e87032f7dd547b3342d308182c6d6))
14
+
15
+ ## [1.3.4](https://github.com/CoCreate-app/CoCreate-scroll/compare/v1.3.3...v1.3.4) (2022-06-18)
16
+
17
+
18
+ ### Bug Fixes
19
+
20
+ * bump dependencies ([0bd768f](https://github.com/CoCreate-app/CoCreate-scroll/commit/0bd768fb982758e6daa62bfd3724a3dec1618f88))
21
+
1
22
  ## [1.3.3](https://github.com/CoCreate-app/CoCreate-scroll/compare/v1.3.2...v1.3.3) (2022-06-18)
2
23
 
3
24
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/scroll",
3
- "version": "1.3.3",
3
+ "version": "1.3.6",
4
4
  "description": "A simple scroll component in vanilla javascript. Easily configured using HTML5 attributes and/or JavaScript API.",
5
5
  "keywords": [
6
6
  "scroll",
@@ -61,7 +61,7 @@
61
61
  "webpack-log": "^3.0.1"
62
62
  },
63
63
  "dependencies": {
64
- "@cocreate/docs": "^1.3.2",
65
- "@cocreate/observer": "^1.5.2"
64
+ "@cocreate/docs": "^1.3.3",
65
+ "@cocreate/observer": "^1.5.3"
66
66
  }
67
67
  }
package/src/index.js CHANGED
@@ -25,7 +25,7 @@ const CoCreateScroll = {
25
25
  const targetSelector = element.getAttribute('scroll-target');
26
26
  const scrollSelector = element.getAttribute('scroll-element');
27
27
  const intersectValue = element.getAttribute('scroll-intersect');
28
-
28
+
29
29
  let values = element.getAttribute('scroll') || "";
30
30
  values = values.split(",").map(x => x.trim());
31
31
 
@@ -88,7 +88,7 @@ const CoCreateScroll = {
88
88
 
89
89
  elements.forEach((el) => {
90
90
  self.__setScrolling(el, scrollInfo, false);
91
- // self.__runScrollEvent(el, scrollInfo, scrollableEl);
91
+ self.__runScrollEvent(el, scrollInfo, scrollableEl);
92
92
 
93
93
  });
94
94
 
@@ -97,18 +97,6 @@ const CoCreateScroll = {
97
97
  self.__setScrolling(el, scrollInfo, true);
98
98
  });
99
99
  }, 500);
100
-
101
- if (!self.firedEvents.has(element)) {
102
- self.firedEvents.set(element, element)
103
- elements.forEach((el) => {
104
- self.__runScrollEvent(el, scrollInfo, scrollableEl);
105
- });
106
- setTimeout(function() {
107
- self.firedEvents.delete(element)
108
- // clearTimeout(eventTimer)
109
- }, 300);
110
- }
111
-
112
100
  },
113
101
 
114
102
  __initIntersectionObserver: function() {
@@ -159,15 +147,19 @@ const CoCreateScroll = {
159
147
  }
160
148
  const { upSize, downSize, attrName, values, scrollTop, scrollBottom, scrollLimbo } = info;
161
149
 
162
- if (upSize < (currentPos - scrollY)) {
163
- this.__addAttributeValue(element, attrName, values[0]);
164
- this.__removeAttrbuteValue(element, attrName, values[1]);
165
- }
166
- else if (downSize < (scrollY - currentPos)) {
167
- this.__removeAttrbuteValue(element, attrName, values[0]);
168
- this.__addAttributeValue(element, attrName, values[1]);
169
- }
150
+ let newTime = new Date().getTime()
151
+ if (!info.datetime || (newTime - info.datetime) > 200 ) {
152
+ info['datetime'] = newTime
170
153
 
154
+ if (upSize <= (currentPos - scrollY)) {
155
+ this.__addAttributeValue(element, attrName, values[0]);
156
+ this.__removeAttrbuteValue(element, attrName, values[1]);
157
+ }
158
+ else if (downSize <= (scrollY - currentPos)) {
159
+ this.__removeAttrbuteValue(element, attrName, values[0]);
160
+ this.__addAttributeValue(element, attrName, values[1]);
161
+ }
162
+ }
171
163
  //. scroll top case
172
164
  if (scrollY <= this.delta) {
173
165
  this.__removeAttrbuteValue(element, attrName, values[0]);