@cocreate/scroll 1.13.0 → 1.13.1

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.
Files changed (3) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/package.json +1 -1
  3. package/src/index.js +326 -301
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.13.1](https://github.com/CoCreate-app/CoCreate-scroll/compare/v1.13.0...v1.13.1) (2025-04-11)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * update observer observe param to type and and attributeName to attributeFilter ([38c28e8](https://github.com/CoCreate-app/CoCreate-scroll/commit/38c28e8ccef5153cd4f6369ff7586c9d7b342922))
7
+
1
8
  # [1.13.0](https://github.com/CoCreate-app/CoCreate-scroll/compare/v1.12.0...v1.13.0) (2024-11-04)
2
9
 
3
10
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/scroll",
3
- "version": "1.13.0",
3
+ "version": "1.13.1",
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",
package/src/index.js CHANGED
@@ -1,320 +1,345 @@
1
- import Observer from '@cocreate/observer';
2
- import Actions from '@cocreate/actions';
1
+ import Observer from "@cocreate/observer";
2
+ import Actions from "@cocreate/actions";
3
3
 
4
4
  const CoCreateScroll = {
5
- delta: 3,
6
- observer: null,
7
- timer: null,
8
- firedEvents: new Map(),
9
-
10
- init: function () {
11
- let elements = document.querySelectorAll(`[scroll], [scroll-to], [scrollable-x], [scrollable-y]`);
12
- this.__initIntersectionObserver();
13
- this.initElements(elements);
14
- },
15
-
16
- initElements: function (elements) {
17
- for (let el of elements)
18
- this.initElement(el);
19
- },
20
-
21
- initElement: function (element) {
22
- const self = this;
23
- const upSize = this.__getSize(element.getAttribute('scroll-up'));
24
- const downSize = this.__getSize(element.getAttribute('scroll-down'));
25
- const attrName = element.getAttribute('scroll-attribute') || 'class';
26
- const targetSelector = element.getAttribute('scroll-selector');
27
- const scrollSelector = element.getAttribute('scroll-element');
28
- const intersectValue = element.getAttribute('scroll-intersect');
29
- const scrollTo = element.getAttribute('scroll-to');
30
-
31
- updateScrollableAttributes(element)
32
-
33
-
34
- let values = element.getAttribute('scroll') || element.getAttribute('scroll-value');
35
- if (values || values === '')
36
- values = values.split(",").map(x => x.trim());
37
-
38
- let scrollInfo = {
39
- attrName: attrName,
40
- values: values,
41
- upSize: upSize,
42
- downSize: downSize,
43
- scrollTop: element.getAttribute('scroll-top'),
44
- scrollLimbo: element.getAttribute('scroll-limbo'),
45
- scrollBottom: element.getAttribute('scroll-bottom'),
46
- scrolling: element.getAttribute('scrolling'),
47
- scrollTo
48
- };
49
-
50
- let elements = [element];
51
- if (targetSelector) {
52
- elements = document.querySelectorAll(targetSelector);
53
- }
54
-
55
- elements.forEach(el => {
56
- el.scrollStatus = { currentPos: 0 };
57
- });
58
-
59
- // this.__runScrollEvent(element, scrollInfo);
60
-
61
- let scrollableElements;
62
- if (scrollSelector)
63
- scrollableElements = document.querySelectorAll(scrollSelector);
64
- else if (element.hasAttribute('scroll-element'))
65
- scrollableElements = [element]
66
-
67
- if (scrollableElements) {
68
- for (let scrollableEl of scrollableElements) {
69
- scrollableEl.addEventListener('scroll', function (event) {
70
- self._scrollEvent(elements, element, scrollInfo, scrollableEl)
71
- });
72
- }
73
- } else {
74
- // this.WindowInit = true;
75
- window.addEventListener('scroll', function (event) {
76
- self._scrollEvent(elements, element, scrollInfo)
77
- });
78
- }
79
-
80
- if (intersectValue && window.IntersectionObserver && this.observer) {
81
- this.observer.observe(element);
82
- }
83
-
84
- if (scrollTo) {
85
- this.setScrollPosition(element, scrollTo)
86
- }
87
- },
88
-
89
- _scrollEvent: function (elements, element, scrollInfo, scrollableEl) {
90
- const self = this;
91
- if (!element.scrollStatus) return;
92
- let scrollEl = scrollableEl || window;
93
- if (Math.abs(scrollEl.scrollTop || scrollEl.scrollY - element.scrollStatus.currentPos) <= self.delta) {
94
- return;
95
- }
96
-
97
- let timer = null;
98
- if (timer != null) {
99
- clearTimeout(timer);
100
- }
101
-
102
- elements.forEach((el) => {
103
- self.__setScrolling(el, scrollInfo, false);
104
- self.__runScrollEvent(el, scrollInfo, scrollableEl);
105
-
106
- });
107
-
108
- timer = setTimeout(function () {
109
- elements.forEach((el) => {
110
- self.__setScrolling(el, scrollInfo, true);
111
- });
112
- }, 500);
113
- },
114
-
115
- setScrollPosition: function (element, scrollTo) {
116
- if (!scrollTo)
117
- return
118
- if (scrollTo.includes('top')) {
119
- element.scrollTop = 0;
120
- } else if (scrollTo.includes('bottom')) {
121
- element.scrollTop = element.scrollHeight;
122
- }
123
-
124
- if (scrollTo.includes('left')) {
125
- element.scrollLeft = 0;
126
- } else if (scrollTo.includes('right')) {
127
- element.scrollLeft = element.scrollWidth;
128
- }
129
- },
130
-
131
- __initIntersectionObserver: function () {
132
- const self = this;
133
- this.observer = new IntersectionObserver(entries => {
134
- entries.forEach(entry => {
135
- let element = entry.target;
136
- const attrName = element.getAttribute('scroll-attribute') || 'class';
137
- const targetSelector = element.getAttribute('scroll-selector');
138
- const intersectValue = element.getAttribute('scroll-intersect');
139
-
140
- let targetElements = [element];
141
- if (targetSelector) {
142
- targetElements = document.querySelectorAll(targetSelector);
143
- }
144
- if (entry.isIntersecting > 0) {
145
- targetElements.forEach((el) => self.__addAttributeValue(el, attrName, intersectValue));
146
- } else {
147
- targetElements.forEach((el) => self.__removeAttrbuteValue(el, attrName, intersectValue));
148
- }
149
- });
150
- });
151
- },
152
-
153
- __setScrolling: function (element, info, stopped = false) {
154
- const { scrolling, attrName } = info;
155
- if (stopped) {
156
- this.__removeAttrbuteValue(element, attrName, scrolling);
157
- } else {
158
- this.__addAttributeValue(element, attrName, scrolling);
159
- }
160
- },
161
-
162
- __runScrollEvent: function (element, info, scrollableEl) {
163
- if (!element.scrollStatus) return
164
- const currentPos = element.scrollStatus.currentPos;
165
- let scrollY, scrollHeight, innerHeight;
166
- if (scrollableEl) {
167
- scrollY = scrollableEl.scrollTop;
168
- scrollHeight = scrollableEl.scrollHeight
169
- innerHeight = scrollableEl.clientHeight
170
- } else {
171
- scrollY = window.scrollY;
172
- scrollHeight = document.body.scrollHeight
173
- innerHeight = window.innerHeight
174
- }
175
- const { upSize, downSize, attrName, values, scrollTop, scrollBottom, scrollLimbo } = info;
176
-
177
- let newTime = new Date().getTime()
178
- if (!info.datetime || (newTime - info.datetime) > 200) {
179
- info['datetime'] = newTime
180
-
181
- if (upSize <= (currentPos - scrollY)) {
182
- this.__addAttributeValue(element, attrName, values[0]);
183
- this.__removeAttrbuteValue(element, attrName, values[1]);
184
- } else if (downSize <= (scrollY - currentPos)) {
185
- this.__removeAttrbuteValue(element, attrName, values[0]);
186
- this.__addAttributeValue(element, attrName, values[1]);
187
- }
188
- }
189
-
190
- //. scroll top case
191
- if (scrollY <= this.delta) {
192
- this.__removeAttrbuteValue(element, attrName, values[0]);
193
- this.__removeAttrbuteValue(element, attrName, values[1]);
194
-
195
- this.__addAttributeValue(element, attrName, scrollTop);
196
- } else {
197
- this.__removeAttrbuteValue(element, attrName, scrollTop);
198
- }
199
-
200
- //. scroll bottom case
201
- // if ((window.innerHeight + scrollY) >= document.body.scrollHeight) {
202
- if ((innerHeight + scrollY) >= scrollHeight) {
203
- // this.__removeAttrbuteValue(element, attrName, values[0]);
204
- // this.__removeAttrbuteValue(element, attrName, values[1]);
205
-
206
- this.__addAttributeValue(element, attrName, scrollBottom);
207
- } else {
208
- this.__removeAttrbuteValue(element, attrName, scrollBottom);
209
- }
210
-
211
- // if (scrollY != 0 && (scrollY + window.innerHeight) != document.body.scrollHeight){
212
- if (scrollY != 0 && (scrollY + innerHeight) != scrollHeight) {
213
- this.__addAttributeValue(element, attrName, scrollLimbo);
214
- } else {
215
- this.__removeAttrbuteValue(element, attrName, scrollLimbo);
216
- }
217
-
218
- element.scrollStatus.currentPos = scrollY;
219
- },
220
-
221
- __addAttributeValue: function (element, attrName, value) {
222
- if (!value) return;
223
- let check = new RegExp("(\\s|^)" + value + "(\\s|$)");
224
- let attrValue = element.getAttribute(attrName) || "";
225
-
226
- if (!check.test(attrValue)) {
227
- if (attrName === 'class')
228
- attrValue += " " + value;
229
- else
230
- attrValue = value
231
- element.setAttribute(attrName, attrValue);
232
- }
233
- },
234
-
235
- __removeAttrbuteValue: function (element, attrName, value) {
236
- if (!value) return;
237
- let check = new RegExp("(\\s|^)" + value + "(\\s|$)");
238
- let attrValue = element.getAttribute(attrName) || "";
239
-
240
- if (check.test(attrValue)) {
241
- attrValue = attrValue.replace(check, " ").trim();
242
- element.setAttribute(attrName, attrValue);
243
- }
244
- },
245
-
246
- __getSize: function (attrValue, isWidth) {
247
- let size = 0;
248
- if (!attrValue) {
249
- return 0;
250
- }
251
-
252
- if (attrValue.includes('%')) {
253
- size = attrValue.replace('%', '').trim();
254
- size = Number(size) || 0;
255
-
256
- size = isWidth ? window.innerWidth / size : window.innerHeight / size;
257
-
258
- } else {
259
- size = attrValue.replace('px', '').trim();
260
- size = Number(size) || 0;
261
- }
262
-
263
- return size;
264
- }
265
-
5
+ delta: 3,
6
+ observer: null,
7
+ timer: null,
8
+ firedEvents: new Map(),
9
+
10
+ init: function () {
11
+ let elements = document.querySelectorAll(
12
+ `[scroll], [scroll-to], [scrollable-x], [scrollable-y]`
13
+ );
14
+ this.__initIntersectionObserver();
15
+ this.initElements(elements);
16
+ },
17
+
18
+ initElements: function (elements) {
19
+ for (let el of elements) this.initElement(el);
20
+ },
21
+
22
+ initElement: function (element) {
23
+ const self = this;
24
+ const upSize = this.__getSize(element.getAttribute("scroll-up"));
25
+ const downSize = this.__getSize(element.getAttribute("scroll-down"));
26
+ const attrName = element.getAttribute("scroll-attribute") || "class";
27
+ const targetSelector = element.getAttribute("scroll-selector");
28
+ const scrollSelector = element.getAttribute("scroll-element");
29
+ const intersectValue = element.getAttribute("scroll-intersect");
30
+ const scrollTo = element.getAttribute("scroll-to");
31
+
32
+ updateScrollableAttributes(element);
33
+
34
+ let values =
35
+ element.getAttribute("scroll") ||
36
+ element.getAttribute("scroll-value");
37
+ if (values || values === "")
38
+ values = values.split(",").map((x) => x.trim());
39
+
40
+ let scrollInfo = {
41
+ attrName: attrName,
42
+ values: values,
43
+ upSize: upSize,
44
+ downSize: downSize,
45
+ scrollTop: element.getAttribute("scroll-top"),
46
+ scrollLimbo: element.getAttribute("scroll-limbo"),
47
+ scrollBottom: element.getAttribute("scroll-bottom"),
48
+ scrolling: element.getAttribute("scrolling"),
49
+ scrollTo
50
+ };
51
+
52
+ let elements = [element];
53
+ if (targetSelector) {
54
+ elements = document.querySelectorAll(targetSelector);
55
+ }
56
+
57
+ elements.forEach((el) => {
58
+ el.scrollStatus = { currentPos: 0 };
59
+ });
60
+
61
+ // this.__runScrollEvent(element, scrollInfo);
62
+
63
+ let scrollableElements;
64
+ if (scrollSelector)
65
+ scrollableElements = document.querySelectorAll(scrollSelector);
66
+ else if (element.hasAttribute("scroll-element"))
67
+ scrollableElements = [element];
68
+
69
+ if (scrollableElements) {
70
+ for (let scrollableEl of scrollableElements) {
71
+ scrollableEl.addEventListener("scroll", function (event) {
72
+ self._scrollEvent(
73
+ elements,
74
+ element,
75
+ scrollInfo,
76
+ scrollableEl
77
+ );
78
+ });
79
+ }
80
+ } else {
81
+ // this.WindowInit = true;
82
+ window.addEventListener("scroll", function (event) {
83
+ self._scrollEvent(elements, element, scrollInfo);
84
+ });
85
+ }
86
+
87
+ if (intersectValue && window.IntersectionObserver && this.observer) {
88
+ this.observer.observe(element);
89
+ }
90
+
91
+ if (scrollTo) {
92
+ this.setScrollPosition(element, scrollTo);
93
+ }
94
+ },
95
+
96
+ _scrollEvent: function (elements, element, scrollInfo, scrollableEl) {
97
+ const self = this;
98
+ if (!element.scrollStatus) return;
99
+ let scrollEl = scrollableEl || window;
100
+ if (
101
+ Math.abs(
102
+ scrollEl.scrollTop ||
103
+ scrollEl.scrollY - element.scrollStatus.currentPos
104
+ ) <= self.delta
105
+ ) {
106
+ return;
107
+ }
108
+
109
+ let timer = null;
110
+ if (timer != null) {
111
+ clearTimeout(timer);
112
+ }
113
+
114
+ elements.forEach((el) => {
115
+ self.__setScrolling(el, scrollInfo, false);
116
+ self.__runScrollEvent(el, scrollInfo, scrollableEl);
117
+ });
118
+
119
+ timer = setTimeout(function () {
120
+ elements.forEach((el) => {
121
+ self.__setScrolling(el, scrollInfo, true);
122
+ });
123
+ }, 500);
124
+ },
125
+
126
+ setScrollPosition: function (element, scrollTo) {
127
+ if (!scrollTo) return;
128
+ if (scrollTo.includes("top")) {
129
+ element.scrollTop = 0;
130
+ } else if (scrollTo.includes("bottom")) {
131
+ element.scrollTop = element.scrollHeight;
132
+ }
133
+
134
+ if (scrollTo.includes("left")) {
135
+ element.scrollLeft = 0;
136
+ } else if (scrollTo.includes("right")) {
137
+ element.scrollLeft = element.scrollWidth;
138
+ }
139
+ },
140
+
141
+ __initIntersectionObserver: function () {
142
+ const self = this;
143
+ this.observer = new IntersectionObserver((entries) => {
144
+ entries.forEach((entry) => {
145
+ let element = entry.target;
146
+ const attrName =
147
+ element.getAttribute("scroll-attribute") || "class";
148
+ const targetSelector = element.getAttribute("scroll-selector");
149
+ const intersectValue = element.getAttribute("scroll-intersect");
150
+
151
+ let targetElements = [element];
152
+ if (targetSelector) {
153
+ targetElements = document.querySelectorAll(targetSelector);
154
+ }
155
+ if (entry.isIntersecting > 0) {
156
+ targetElements.forEach((el) =>
157
+ self.__addAttributeValue(el, attrName, intersectValue)
158
+ );
159
+ } else {
160
+ targetElements.forEach((el) =>
161
+ self.__removeAttrbuteValue(el, attrName, intersectValue)
162
+ );
163
+ }
164
+ });
165
+ });
166
+ },
167
+
168
+ __setScrolling: function (element, info, stopped = false) {
169
+ const { scrolling, attrName } = info;
170
+ if (stopped) {
171
+ this.__removeAttrbuteValue(element, attrName, scrolling);
172
+ } else {
173
+ this.__addAttributeValue(element, attrName, scrolling);
174
+ }
175
+ },
176
+
177
+ __runScrollEvent: function (element, info, scrollableEl) {
178
+ if (!element.scrollStatus) return;
179
+ const currentPos = element.scrollStatus.currentPos;
180
+ let scrollY, scrollHeight, innerHeight;
181
+ if (scrollableEl) {
182
+ scrollY = scrollableEl.scrollTop;
183
+ scrollHeight = scrollableEl.scrollHeight;
184
+ innerHeight = scrollableEl.clientHeight;
185
+ } else {
186
+ scrollY = window.scrollY;
187
+ scrollHeight = document.body.scrollHeight;
188
+ innerHeight = window.innerHeight;
189
+ }
190
+ const {
191
+ upSize,
192
+ downSize,
193
+ attrName,
194
+ values,
195
+ scrollTop,
196
+ scrollBottom,
197
+ scrollLimbo
198
+ } = info;
199
+
200
+ let newTime = new Date().getTime();
201
+ if (!info.datetime || newTime - info.datetime > 200) {
202
+ info["datetime"] = newTime;
203
+
204
+ if (upSize <= currentPos - scrollY) {
205
+ this.__addAttributeValue(element, attrName, values[0]);
206
+ this.__removeAttrbuteValue(element, attrName, values[1]);
207
+ } else if (downSize <= scrollY - currentPos) {
208
+ this.__removeAttrbuteValue(element, attrName, values[0]);
209
+ this.__addAttributeValue(element, attrName, values[1]);
210
+ }
211
+ }
212
+
213
+ //. scroll top case
214
+ if (scrollY <= this.delta) {
215
+ this.__removeAttrbuteValue(element, attrName, values[0]);
216
+ this.__removeAttrbuteValue(element, attrName, values[1]);
217
+
218
+ this.__addAttributeValue(element, attrName, scrollTop);
219
+ } else {
220
+ this.__removeAttrbuteValue(element, attrName, scrollTop);
221
+ }
222
+
223
+ //. scroll bottom case
224
+ // if ((window.innerHeight + scrollY) >= document.body.scrollHeight) {
225
+ if (innerHeight + scrollY >= scrollHeight) {
226
+ // this.__removeAttrbuteValue(element, attrName, values[0]);
227
+ // this.__removeAttrbuteValue(element, attrName, values[1]);
228
+
229
+ this.__addAttributeValue(element, attrName, scrollBottom);
230
+ } else {
231
+ this.__removeAttrbuteValue(element, attrName, scrollBottom);
232
+ }
233
+
234
+ // if (scrollY != 0 && (scrollY + window.innerHeight) != document.body.scrollHeight){
235
+ if (scrollY != 0 && scrollY + innerHeight != scrollHeight) {
236
+ this.__addAttributeValue(element, attrName, scrollLimbo);
237
+ } else {
238
+ this.__removeAttrbuteValue(element, attrName, scrollLimbo);
239
+ }
240
+
241
+ element.scrollStatus.currentPos = scrollY;
242
+ },
243
+
244
+ __addAttributeValue: function (element, attrName, value) {
245
+ if (!value) return;
246
+ let check = new RegExp("(\\s|^)" + value + "(\\s|$)");
247
+ let attrValue = element.getAttribute(attrName) || "";
248
+
249
+ if (!check.test(attrValue)) {
250
+ if (attrName === "class") attrValue += " " + value;
251
+ else attrValue = value;
252
+ element.setAttribute(attrName, attrValue);
253
+ }
254
+ },
255
+
256
+ __removeAttrbuteValue: function (element, attrName, value) {
257
+ if (!value) return;
258
+ let check = new RegExp("(\\s|^)" + value + "(\\s|$)");
259
+ let attrValue = element.getAttribute(attrName) || "";
260
+
261
+ if (check.test(attrValue)) {
262
+ attrValue = attrValue.replace(check, " ").trim();
263
+ element.setAttribute(attrName, attrValue);
264
+ }
265
+ },
266
+
267
+ __getSize: function (attrValue, isWidth) {
268
+ let size = 0;
269
+ if (!attrValue) {
270
+ return 0;
271
+ }
272
+
273
+ if (attrValue.includes("%")) {
274
+ size = attrValue.replace("%", "").trim();
275
+ size = Number(size) || 0;
276
+
277
+ size = isWidth
278
+ ? window.innerWidth / size
279
+ : window.innerHeight / size;
280
+ } else {
281
+ size = attrValue.replace("px", "").trim();
282
+ size = Number(size) || 0;
283
+ }
284
+
285
+ return size;
286
+ }
266
287
  };
267
288
 
268
289
  function updateScrollableAttributes(element) {
269
- if (element.hasAttribute('scrollable-y')) {
270
- if (element.scrollWidth > element.clientWidth)
271
- element.setAttribute('scrollable-y', 'true');
272
- else
273
- element.setAttribute('scrollable-y', 'false');
274
- }
275
-
276
- if (element.hasAttribute('scrollable-x')) {
277
- if (element.scrollHeight > element.clientHeight)
278
- element.setAttribute('scrollable-x', 'true');
279
- else
280
- element.setAttribute('scrollable-x', 'false');
281
- }
290
+ if (element.hasAttribute("scrollable-y")) {
291
+ if (element.scrollWidth > element.clientWidth)
292
+ element.setAttribute("scrollable-y", "true");
293
+ else element.setAttribute("scrollable-y", "false");
294
+ }
295
+
296
+ if (element.hasAttribute("scrollable-x")) {
297
+ if (element.scrollHeight > element.clientHeight)
298
+ element.setAttribute("scrollable-x", "true");
299
+ else element.setAttribute("scrollable-x", "false");
300
+ }
282
301
  }
283
302
 
284
303
  Observer.init({
285
- name: 'CoCreateScrollCreate',
286
- observe: ['addedNodes'],
287
- selector: '[scroll], [scroll-to], [scrollable-x], [scrollable-y]',
288
- callback: function (mutation) {
289
- CoCreateScroll.initElement(mutation.target);
290
- }
304
+ name: "CoCreateScrollCreate",
305
+ types: ["addedNodes"],
306
+ selector: "[scroll], [scroll-to], [scrollable-x], [scrollable-y]",
307
+ callback: function (mutation) {
308
+ CoCreateScroll.initElement(mutation.target);
309
+ }
291
310
  });
292
311
 
293
312
  Observer.init({
294
- name: 'CoCreateScrollAttributes',
295
- observe: ['attributes'],
296
- attributeName: ['scroll-to'],
297
- // target: selector, // blocks mutations when applied
298
- callback: function (mutation) {
299
- CoCreateScroll.setScrollPosition(mutation.target, mutation.target.getAttribute('scroll-to'))
300
- }
313
+ name: "CoCreateScrollAttributes",
314
+ types: ["attributes"],
315
+ attributeFilter: ["scroll-to"],
316
+ // target: selector, // blocks mutations when applied
317
+ callback: function (mutation) {
318
+ CoCreateScroll.setScrollPosition(
319
+ mutation.target,
320
+ mutation.target.getAttribute("scroll-to")
321
+ );
322
+ }
301
323
  });
302
324
  Observer.init({
303
- name: 'CoCreateScrollAttributes',
304
- observe: ['attributes'],
305
- attributeName: ['scrollable-x', 'scrollable-y'],
306
- // target: selector, // blocks mutations when applied
307
- callback: function (mutation) {
308
- if (mutation.oldValue !== mutation.target.getAttribute(mutation.attributeName))
309
- updateScrollableAttributes(mutation.target)
310
- }
325
+ name: "CoCreateScrollAttributes",
326
+ types: ["attributes"],
327
+ attributeFilter: ["scrollable-x", "scrollable-y"],
328
+ // target: selector, // blocks mutations when applied
329
+ callback: function (mutation) {
330
+ if (
331
+ mutation.oldValue !==
332
+ mutation.target.getAttribute(mutation.attributeName)
333
+ )
334
+ updateScrollableAttributes(mutation.target);
335
+ }
311
336
  });
312
337
 
313
338
  Actions.init({
314
- name: "scroll-to",
315
- callback: (action) => {
316
- // CoCreateScroll.setScrollPosition(mutation.target)
317
- }
339
+ name: "scroll-to",
340
+ callback: (action) => {
341
+ // CoCreateScroll.setScrollPosition(mutation.target)
342
+ }
318
343
  });
319
344
 
320
345
  CoCreateScroll.init();