@cocreate/scroll 1.11.3 → 1.13.0

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,26 @@
1
+ # [1.13.0](https://github.com/CoCreate-app/CoCreate-scroll/compare/v1.12.0...v1.13.0) (2024-11-04)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * observer taget has been renamed to selector ([c29bc49](https://github.com/CoCreate-app/CoCreate-scroll/commit/c29bc49a623dd66f5aee115636b77eae0b0ea27f))
7
+ * pretier.config.js and file formating ([a6b0297](https://github.com/CoCreate-app/CoCreate-scroll/commit/a6b0297dea674108e47f92afaabc4d0954686703))
8
+ * support for scrollable-y and scrollable-x attributes to detect if the element has a scroll ([2240d2f](https://github.com/CoCreate-app/CoCreate-scroll/commit/2240d2fec057b6d7dd036ad750e42d308f537b3c))
9
+
10
+
11
+ ### Features
12
+
13
+ * add prettier.config.js and format files ([d96636c](https://github.com/CoCreate-app/CoCreate-scroll/commit/d96636cbf7eafb546ac789f9d093b8a1cb148c9d))
14
+ * add prettier.config.js and format files ([3f15adc](https://github.com/CoCreate-app/CoCreate-scroll/commit/3f15adc4c96c171119012168e8d60297fb2b37dd))
15
+
16
+ # [1.12.0](https://github.com/CoCreate-app/CoCreate-scroll/compare/v1.11.3...v1.12.0) (2024-09-21)
17
+
18
+
19
+ ### Features
20
+
21
+ * added CoCreate-actions ([e2c2a6a](https://github.com/CoCreate-app/CoCreate-scroll/commit/e2c2a6a3071ea691244874495f5d2426906e192d))
22
+ * scroll-to to set a scroll position top | bottom | left | right ([0c42fc1](https://github.com/CoCreate-app/CoCreate-scroll/commit/0c42fc1ce81b1bf585d5fd5508e1e1ff97de04c5))
23
+
1
24
  ## [1.11.3](https://github.com/CoCreate-app/CoCreate-scroll/compare/v1.11.2...v1.11.3) (2024-06-12)
2
25
 
3
26
 
package/demo/index.html CHANGED
@@ -66,7 +66,8 @@
66
66
  scroll-bottom="scroll_bottom"
67
67
  scroll="hidden, sticky-nav"
68
68
  scroll-up="10"
69
- scroll-down="5">
69
+ scroll-down="5"
70
+ scroll-to="top | bottom | left | right">
70
71
  <!--<a href="#" class="logo">Navbar</a>-->
71
72
  <div
72
73
  class="margin:0px_15px display:flex flex-wrap:wrap justify-content:space-between flex-direction:row align-items:center width:100%">
package/docs/index.html CHANGED
@@ -1,409 +1,379 @@
1
1
  <!DOCTYPE html>
2
2
  <html lang="en">
3
- <head>
4
- <meta charset="utf-8" />
5
- <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
- <meta name="viewport" content="width=device-width, initial-scale=1" />
7
- <title>overflow:auto Documentation | CoCreateJS</title>
8
- <link
9
- rel="icon"
10
- type="image/png"
11
- sizes="32x32"
12
- href="https://cocreate.app/images/favicon.ico" />
13
- <meta
14
- name="description"
15
- content="A simple HTML5 and pure javascript component. Easy configuration using HTML5 attributes or Javscript api and highly styleable." />
16
- <meta
17
- name="keywords"
18
- content="helper classes, utility classes, css framework, css library, inline style classes" />
19
- <meta name="robots" content="index,follow" />
20
- <meta
21
- property="og:image"
22
- content="https://cdn.cocreate.app/docs/scroll.png" />
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <meta http-equiv="X-UA-Compatible" content="IE=edge" />
6
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
7
+ <title>overflow:auto Documentation | CoCreateJS</title>
8
+ <link
9
+ rel="icon"
10
+ type="image/png"
11
+ sizes="32x32"
12
+ href="https://cocreate.app/images/favicon.ico"
13
+ />
14
+ <meta
15
+ name="description"
16
+ content="A simple HTML5 and pure javascript component. Easy configuration using HTML5 attributes or Javscript api and highly styleable."
17
+ />
18
+ <meta
19
+ name="keywords"
20
+ content="helper classes, utility classes, css framework, css library, inline style classes"
21
+ />
22
+ <meta name="robots" content="index,follow" />
23
+ <meta
24
+ property="og:image"
25
+ content="https://cdn.cocreate.app/docs/scroll.png"
26
+ />
23
27
 
24
- <link
25
- rel="stylesheet"
26
- href="../index.css"
27
- array="files"
28
- object="60888216117c640e7596303f"
29
- key="src"
30
- type="text/css"
31
- save="true" />
32
- <link rel="manifest" href="/manifest.webmanifest" />
33
- </head>
28
+ <link
29
+ rel="stylesheet"
30
+ href="../index.css"
31
+ array="files"
32
+ object="60888216117c640e7596303f"
33
+ key="src"
34
+ type="text/css"
35
+ save="true"
36
+ />
37
+ <link rel="manifest" href="/manifest.webmanifest" />
38
+ </head>
34
39
 
35
- <body>
36
- <!-- Navbar -->
37
- <nav
38
- class="width:100% display:flex align-items:center background:transparent padding-top:10px padding-bottom:10px"
39
- content_id="content"
40
- scroll="sticky-nav,"
41
- scroll-up="5"
42
- scroll-down="5"
43
- path="../"
44
- src="../components/navbar.html"></nav>
45
- <sidenav
46
- id="menuL"
47
- class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
48
- resizable
49
- resize-selector="[content_id='content']"
50
- resize-property="margin-left"
51
- resize-value="width">
52
- <menu
53
- array="files"
54
- object="603717b07de7fb350ae9fec8"
55
- key="src"></menu>
56
- <div resize="right"></div>
57
- </sidenav>
58
- <main
59
- class="padding-top:15px padding:15px@lg@xl"
60
- content_id="content"
61
- id="overflow:auto">
62
- <div
63
- class="display:flex flex-wrap:wrap justify-content:space-between position:relative margin:10px">
64
- <div class="display:flex align-items:center">
65
- <h2>overflow:auto</h2>
66
- </div>
67
- <div
68
- class="display:flex align-items:center font-size:20px position:absolute right:0 padding:5px background:white">
69
- <div
70
- class="display:flex align-items:center transition:0.3s padding-left:10px"
71
- share-network="true"
72
- share-text="Enter decription here"
73
- share-title="testing im a title"
74
- share-height="600"
75
- share-width="700"
76
- share-media="https://cdn.cocreate.app/docs/scroll.png"
77
- hover="display:block!important"
78
- hover-selector=".social-networks">
79
- <div class="display:none social-networks">
80
- <a
81
- class="margin-right:15px"
82
- share-network="twitter"
83
- title="Share on twitter"
84
- ><i src="/assets/svg/twitter.svg"></i
85
- ></a>
86
- <a
87
- class="margin-right:15px"
88
- share-network="facebook"
89
- title="Share on Facebook"
90
- ><i src="/assets/svg/facebook.svg"></i
91
- ></a>
92
- <a
93
- class="margin-right:15px"
94
- share-network="instagram"
95
- title="Share on instagram"
96
- ><i src="/assets/svg/instagram.svg"></i
97
- ></a>
98
- </div>
99
- <a
100
- class="margin-right:15px"
101
- share-network="share"
102
- title="Share on share"
103
- ><i src="/assets/svg/share-alt.svg"></i
104
- ></a>
105
- </div>
106
- <a
107
- href="https://github.com/CoCreate-app/overflow:auto"
108
- target="_blank"
109
- class="margin-right:15px"
110
- ><i src="/assets/svg/github.svg"></i
111
- ></a>
112
- </div>
40
+ <body>
41
+ <!-- Navbar -->
42
+ <nav
43
+ class="width:100% display:flex align-items:center background:transparent padding-top:10px padding-bottom:10px"
44
+ content_id="content"
45
+ scroll="sticky-nav,"
46
+ scroll-up="5"
47
+ scroll-down="5"
48
+ path="../"
49
+ src="../components/navbar.html"
50
+ ></nav>
51
+ <sidenav
52
+ id="menuL"
53
+ class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl"
54
+ resizable
55
+ resize-selector="[content_id='content']"
56
+ resize-property="margin-left"
57
+ resize-value="width"
58
+ >
59
+ <menu array="files" object="603717b07de7fb350ae9fec8" key="src"></menu>
60
+ <div resize="right"></div>
61
+ </sidenav>
62
+ <main
63
+ class="padding-top:15px padding:15px@lg@xl"
64
+ content_id="content"
65
+ id="overflow:auto"
66
+ >
67
+ <div
68
+ class="display:flex flex-wrap:wrap justify-content:space-between position:relative margin:10px"
69
+ >
70
+ <div class="display:flex align-items:center">
71
+ <h2>overflow:auto</h2>
72
+ </div>
73
+ <div
74
+ class="display:flex align-items:center font-size:20px position:absolute right:0 padding:5px background:white"
75
+ >
76
+ <div
77
+ class="display:flex align-items:center transition:0.3s padding-left:10px"
78
+ share-network="true"
79
+ share-text="Enter decription here"
80
+ share-title="testing im a title"
81
+ share-height="600"
82
+ share-width="700"
83
+ share-media="https://cdn.cocreate.app/docs/scroll.png"
84
+ hover="display:block!important"
85
+ hover-selector=".social-networks"
86
+ >
87
+ <div class="display:none social-networks">
88
+ <a
89
+ class="margin-right:15px"
90
+ share-network="twitter"
91
+ title="Share on twitter"
92
+ ><i src="/assets/svg/twitter.svg"></i
93
+ ></a>
94
+ <a
95
+ class="margin-right:15px"
96
+ share-network="facebook"
97
+ title="Share on Facebook"
98
+ ><i src="/assets/svg/facebook.svg"></i
99
+ ></a>
100
+ <a
101
+ class="margin-right:15px"
102
+ share-network="instagram"
103
+ title="Share on instagram"
104
+ ><i src="/assets/svg/instagram.svg"></i
105
+ ></a>
113
106
  </div>
114
- <h1
115
- class="max-width:500px margin:20px_10px line-height:1.5 font-size:16px font-weight:100">
116
- A headless vinilla javascript micro component. Easy
117
- configuration using HTML5 attributes or Javscript api.
118
- </h1>
119
- <div id="scroll-section" class="display:flex flex-wrap:wrap">
120
- <div
121
- class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px">
122
- <div
123
- id="scroll-install"
124
- class="border-bottom:1px_solid_lightgrey"
125
- scroll
126
- scroll-intersect="color:dodgerblue"
127
- scroll-selector="#scroll-install-section">
128
- <span
129
- class="display:flex align-items:center width:fit-content"
130
- hover="display:block!important"
131
- hover-selector="[href='#scroll-install']">
132
- <h2 class="padding:5px_0px">Install</h2>
133
- <a
134
- class="margin-left:10px display:none"
135
- href="#scroll-install"
136
- ><i src="/assets/svg/link.svg"></i
137
- ></a>
138
- </span>
139
- </div>
140
- <pre><code class="language-bash">npm i @cocreate/scroll</code></pre>
141
- <p class="padding:10px_0px line-height:1.5">
142
- Or you can use cdn link:
143
- </p>
144
- <pre><code class="language-html">&lt;script&gt;https://cdn.cocreate.app/scroll/latest/overflow:auto.min.js&lt;/script&gt;</code></pre>
107
+ <a
108
+ class="margin-right:15px"
109
+ share-network="share"
110
+ title="Share on share"
111
+ ><i src="/assets/svg/share-alt.svg"></i
112
+ ></a>
113
+ </div>
114
+ <a
115
+ href="https://github.com/CoCreate-app/overflow:auto"
116
+ target="_blank"
117
+ class="margin-right:15px"
118
+ ><i src="/assets/svg/github.svg"></i
119
+ ></a>
120
+ </div>
121
+ </div>
122
+ <h1
123
+ class="max-width:500px margin:20px_10px line-height:1.5 font-size:16px font-weight:100"
124
+ >
125
+ A headless vinilla javascript micro component. Easy configuration using
126
+ HTML5 attributes or Javscript api.
127
+ </h1>
128
+ <div id="scroll-section" class="display:flex flex-wrap:wrap">
129
+ <div
130
+ class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px"
131
+ >
132
+ <div
133
+ id="scroll-install"
134
+ class="border-bottom:1px_solid_lightgrey"
135
+ scroll
136
+ scroll-intersect="color:dodgerblue"
137
+ scroll-selector="#scroll-install-section"
138
+ >
139
+ <span
140
+ class="display:flex align-items:center width:fit-content"
141
+ hover="display:block!important"
142
+ hover-selector="[href='#scroll-install']"
143
+ >
144
+ <h2 class="padding:5px_0px">Install</h2>
145
+ <a class="margin-left:10px display:none" href="#scroll-install"
146
+ ><i src="/assets/svg/link.svg"></i
147
+ ></a>
148
+ </span>
149
+ </div>
150
+ <pre><code class="language-bash">npm i @cocreate/scroll</code></pre>
151
+ <p class="padding:10px_0px line-height:1.5">
152
+ Or you can use cdn link:
153
+ </p>
154
+ <pre><code class="language-html">&lt;script&gt;https://cdn.cocreate.app/scroll/latest/overflow:auto.min.js&lt;/script&gt;</code></pre>
145
155
 
146
- <div
147
- id="scroll-usage"
148
- class="margin-top:80px border-bottom:1px_solid_lightgrey"
149
- scroll
150
- scroll-intersect="color:dodgerblue"
151
- scroll-selector="#scroll-usage-section">
152
- <span
153
- class="display:flex align-items:center width:fit-content"
154
- hover="display:block!important"
155
- hover-selector="[href='#scroll-usage']">
156
- <h2 class="padding:5px_0px">Usage</h2>
157
- <a
158
- class="margin-left:10px display:none"
159
- href="#scroll-usage"
160
- ><i src="/assets/svg/link.svg"></i
161
- ></a>
162
- </span>
163
- </div>
164
- <div class="">
165
- <p class="padding:10px_0px line-height:1.5">
166
- This is scroll usage
167
- </p>
156
+ <div
157
+ id="scroll-usage"
158
+ class="margin-top:80px border-bottom:1px_solid_lightgrey"
159
+ scroll
160
+ scroll-intersect="color:dodgerblue"
161
+ scroll-selector="#scroll-usage-section"
162
+ >
163
+ <span
164
+ class="display:flex align-items:center width:fit-content"
165
+ hover="display:block!important"
166
+ hover-selector="[href='#scroll-usage']"
167
+ >
168
+ <h2 class="padding:5px_0px">Usage</h2>
169
+ <a class="margin-left:10px display:none" href="#scroll-usage"
170
+ ><i src="/assets/svg/link.svg"></i
171
+ ></a>
172
+ </span>
173
+ </div>
174
+ <div class="">
175
+ <p class="padding:10px_0px line-height:1.5">This is scroll usage</p>
168
176
 
169
- <div class="flex-grow:1 min-width:300px width:100%">
170
- <pre>
177
+ <div class="flex-grow:1 min-width:300px width:100%">
178
+ <pre>
171
179
  <code class="language-html">
172
180
  &lt;div scroll-up_class="up" scroll-down_class="down" scroll-ing_class="scrolling" scroll-range_class="range" scroll-range_begin="1000" scroll-range_end="1500" scroll-intersect="intersect"&gt;</code>
173
181
  </pre>
174
- </div>
175
- <p class="padding:10px_0px line-height:1.5">
176
- This is scroll usage
177
- </p>
178
- <p class="padding:10px_0px line-height:1.5">
179
- This is scroll usage
180
- </p>
181
- </div>
182
- <div
183
- id="scroll-attributes"
184
- class="margin-top:80px border-bottom:1px_solid_lightgrey"
185
- scroll
186
- scroll-intersect="color:dodgerblue"
187
- scroll-selector="#scroll-attributes-section">
188
- <span
189
- class="display:flex align-items:center width:fit-content"
190
- hover="display:block!important"
191
- hover-selector="[href='#scroll-attributes']">
192
- <h2 class="padding:5px_0px">Attributes</h2>
193
- <a
194
- class="margin-left:10px display:none"
195
- href="#scroll-attributes"
196
- ><i src="/assets/svg/link.svg"></i
197
- ></a>
198
- </span>
199
- </div>
200
- <ul class="list-style-type:none">
201
- <li
202
- class="padding:15px_0px border-bottom:1px_solid_lightgrey">
203
- <h4>
204
- <span>scroll-up_class</span>
205
- <span class="cocreate-badge success"
206
- >string</span
207
- >
208
- <span class="cocreate-badge warning"
209
- >optional</span
210
- >
211
- </h4>
212
- <p>Scroll-Up-Class</p>
213
- </li>
214
- <li
215
- class="padding:15px_0px border-bottom:1px_solid_lightgrey">
216
- <h4>
217
- <span>scroll-down_class</span>
218
- <span class="cocreate-badge success"
219
- >string</span
220
- >
221
- <span class="cocreate-badge warning"
222
- >optional</span
223
- >
224
- </h4>
225
- <p>Scroll-Down-Class</p>
226
- </li>
227
- <li
228
- class="padding:15px_0px border-bottom:1px_solid_lightgrey">
229
- <h4>
230
- <span>scroll-ing_class</span>
231
- <span class="cocreate-badge success"
232
- >string</span
233
- >
234
- <span class="cocreate-badge warning"
235
- >optional</span
236
- >
237
- </h4>
238
- <p>Scroll-Range-Class</p>
239
- </li>
240
- <li
241
- class="padding:15px_0px border-bottom:1px_solid_lightgrey">
242
- <h4>
243
- <span>scroll-range_class</span>
244
- <span class="cocreate-badge success"
245
- >string</span
246
- >
247
- <span class="cocreate-badge warning"
248
- >optional</span
249
- >
250
- </h4>
251
- <p>Scroll-Range-Class</p>
252
- </li>
253
- <li
254
- class="padding:15px_0px border-bottom:1px_solid_lightgrey">
255
- <h4>
256
- <span>scroll-range_begin</span>
257
- <span class="cocreate-badge success"
258
- >number</span
259
- >
260
- <span class="cocreate-badge warning"
261
- >optional</span
262
- >
263
- </h4>
264
- <p>Scroll-Range-Begin</p>
265
- </li>
266
- <li
267
- class="padding:15px_0px border-bottom:1px_solid_lightgrey">
268
- <h4>
269
- <span>scroll-range_end</span>
270
- <span class="cocreate-badge success"
271
- >number</span
272
- >
273
- <span class="cocreate-badge warning"
274
- >optional</span
275
- >
276
- </h4>
277
- <p>Scroll-Range-End</p>
278
- </li>
279
- <li
280
- class="padding:15px_0px border-bottom:1px_solid_lightgrey">
281
- <h4>
282
- <span>scroll-intersect</span>
283
- <span class="cocreate-badge success"
284
- >string</span
285
- >
286
- <span class="cocreate-badge warning"
287
- >optional</span
288
- >
289
- </h4>
290
- <p>Scroll-Intersect</p>
291
- </li>
292
- </ul>
293
- </div>
182
+ </div>
183
+ <p class="padding:10px_0px line-height:1.5">This is scroll usage</p>
184
+ <p class="padding:10px_0px line-height:1.5">This is scroll usage</p>
185
+ </div>
186
+ <div
187
+ id="scroll-attributes"
188
+ class="margin-top:80px border-bottom:1px_solid_lightgrey"
189
+ scroll
190
+ scroll-intersect="color:dodgerblue"
191
+ scroll-selector="#scroll-attributes-section"
192
+ >
193
+ <span
194
+ class="display:flex align-items:center width:fit-content"
195
+ hover="display:block!important"
196
+ hover-selector="[href='#scroll-attributes']"
197
+ >
198
+ <h2 class="padding:5px_0px">Attributes</h2>
199
+ <a class="margin-left:10px display:none" href="#scroll-attributes"
200
+ ><i src="/assets/svg/link.svg"></i
201
+ ></a>
202
+ </span>
203
+ </div>
204
+ <ul class="list-style-type:none">
205
+ <li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
206
+ <h4>
207
+ <span>scroll-up_class</span>
208
+ <span class="cocreate-badge success">string</span>
209
+ <span class="cocreate-badge warning">optional</span>
210
+ </h4>
211
+ <p>Scroll-Up-Class</p>
212
+ </li>
213
+ <li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
214
+ <h4>
215
+ <span>scroll-down_class</span>
216
+ <span class="cocreate-badge success">string</span>
217
+ <span class="cocreate-badge warning">optional</span>
218
+ </h4>
219
+ <p>Scroll-Down-Class</p>
220
+ </li>
221
+ <li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
222
+ <h4>
223
+ <span>scroll-ing_class</span>
224
+ <span class="cocreate-badge success">string</span>
225
+ <span class="cocreate-badge warning">optional</span>
226
+ </h4>
227
+ <p>Scroll-Range-Class</p>
228
+ </li>
229
+ <li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
230
+ <h4>
231
+ <span>scroll-range_class</span>
232
+ <span class="cocreate-badge success">string</span>
233
+ <span class="cocreate-badge warning">optional</span>
234
+ </h4>
235
+ <p>Scroll-Range-Class</p>
236
+ </li>
237
+ <li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
238
+ <h4>
239
+ <span>scroll-range_begin</span>
240
+ <span class="cocreate-badge success">number</span>
241
+ <span class="cocreate-badge warning">optional</span>
242
+ </h4>
243
+ <p>Scroll-Range-Begin</p>
244
+ </li>
245
+ <li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
246
+ <h4>
247
+ <span>scroll-range_end</span>
248
+ <span class="cocreate-badge success">number</span>
249
+ <span class="cocreate-badge warning">optional</span>
250
+ </h4>
251
+ <p>Scroll-Range-End</p>
252
+ </li>
253
+ <li class="padding:15px_0px border-bottom:1px_solid_lightgrey">
254
+ <h4>
255
+ <span>scroll-intersect</span>
256
+ <span class="cocreate-badge success">string</span>
257
+ <span class="cocreate-badge warning">optional</span>
258
+ </h4>
259
+ <p>Scroll-Intersect</p>
260
+ </li>
261
+ </ul>
262
+ </div>
294
263
 
295
- <div
296
- class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey">
297
- <!-- SandBox -->
298
- <div
299
- id="scroll-demo"
300
- class="border-bottom:1px_solid_lightgrey"
301
- scroll
302
- scroll-intersect="color:dodgerblue"
303
- scroll-selector="#scroll-demo-section">
304
- <span
305
- class="display:flex align-items:center width:fit-content"
306
- hover="display:block!important"
307
- hover-selector="[href='#scroll-demo']">
308
- <h2 class="padding:5px_0px">Demo</h2>
309
- <a
310
- class="margin-left:10px display:none"
311
- href="#scroll-demo"
312
- ><i src="/assets/svg/link.svg"></i
313
- ></a>
314
- </span>
315
- </div>
316
- <div
317
- class="position:sticky top:0 padding:15px_0px height:100vh">
318
- <!-- SandBox -->
319
- <div
320
- class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px"
321
- id="playground">
322
- <div
323
- id="demo-code"
324
- resizable
325
- class="position:relative height:50%">
326
- <textarea
327
- type="code"
328
- lang="html"
329
- array="demos"
330
- object=""
331
- key="demo"
332
- save="false"
333
- id="demo"
334
- input-selector=".demopreview"
335
- input-attribute="value"
336
- input-events="input, onload"
337
- class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
338
- <div
339
- resize="bottom"
340
- class="background:lightgrey"></div>
341
- </div>
264
+ <div
265
+ class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey"
266
+ >
267
+ <!-- SandBox -->
268
+ <div
269
+ id="scroll-demo"
270
+ class="border-bottom:1px_solid_lightgrey"
271
+ scroll
272
+ scroll-intersect="color:dodgerblue"
273
+ scroll-selector="#scroll-demo-section"
274
+ >
275
+ <span
276
+ class="display:flex align-items:center width:fit-content"
277
+ hover="display:block!important"
278
+ hover-selector="[href='#scroll-demo']"
279
+ >
280
+ <h2 class="padding:5px_0px">Demo</h2>
281
+ <a class="margin-left:10px display:none" href="#scroll-demo"
282
+ ><i src="/assets/svg/link.svg"></i
283
+ ></a>
284
+ </span>
285
+ </div>
286
+ <div class="position:sticky top:0 padding:15px_0px height:100vh">
287
+ <!-- SandBox -->
288
+ <div
289
+ class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px"
290
+ id="playground"
291
+ >
292
+ <div
293
+ id="demo-code"
294
+ resizable
295
+ class="position:relative height:50%"
296
+ >
297
+ <textarea
298
+ type="code"
299
+ lang="html"
300
+ array="demos"
301
+ object=""
302
+ key="demo"
303
+ save="false"
304
+ id="demo"
305
+ input-selector=".demopreview"
306
+ input-attribute="value"
307
+ input-events="input, onload"
308
+ class="height:100% width:100% outline:none border:none resize:none padding:5px"
309
+ ></textarea>
310
+ <div resize="bottom" class="background:lightgrey"></div>
311
+ </div>
342
312
 
343
- <div
344
- id="demo-preview"
345
- class="position:relative overflow:auto background-color:white">
346
- <div class="demopreview padding:20px"></div>
347
- </div>
313
+ <div
314
+ id="demo-preview"
315
+ class="position:relative overflow:auto background-color:white"
316
+ >
317
+ <div class="demopreview padding:20px"></div>
318
+ </div>
348
319
 
349
- <div
350
- class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
351
- <a
352
- class="margin-right:10px"
353
- id="eye"
354
- show="#eye-slash"
355
- hide="#eye, #demo-preview"
356
- toggle="code-height"
357
- toggle-selector="#demo-code"
358
- ><i
359
- class="height:18px"
360
- src="/assets/svg/eye.svg"></i
361
- ></a>
362
- <a
363
- class="margin-right:10px"
364
- hidden
365
- id="eye-slash"
366
- show="#eye, #demo-preview"
367
- hide="#eye-slash"
368
- toggle="code-height"
369
- toggle-selector="#demo-code"
370
- ><i src="/assets/svg/eye-slash.svg"></i
371
- ></a>
372
- <a
373
- class="margin-right:10px"
374
- id="code"
375
- show="#code-slash"
376
- hide="#code, #demo-code"
377
- ><i src="/assets/svg/code.svg"></i
378
- ></a>
379
- <a
380
- class="margin-right:10px"
381
- hidden
382
- id="code-slash"
383
- show="#code, #demo-code"
384
- hide="#code-slash"
385
- ><i
386
- class="height:18px"
387
- src="/assets/svg/code.svg"></i
388
- ></a>
389
- <a
390
- class="margin-right:5px"
391
- fullscreen
392
- fullscreen-selector="#playground"></a>
393
- </div>
394
- </div>
395
- <!-- End SandBox -->
396
- </div>
397
- </div>
320
+ <div
321
+ class="font-size:20px position:absolute top:10px right:10px opacity:0.6"
322
+ >
323
+ <a
324
+ class="margin-right:10px"
325
+ id="eye"
326
+ show="#eye-slash"
327
+ hide="#eye, #demo-preview"
328
+ toggle="code-height"
329
+ toggle-selector="#demo-code"
330
+ ><i class="height:18px" src="/assets/svg/eye.svg"></i
331
+ ></a>
332
+ <a
333
+ class="margin-right:10px"
334
+ hidden
335
+ id="eye-slash"
336
+ show="#eye, #demo-preview"
337
+ hide="#eye-slash"
338
+ toggle="code-height"
339
+ toggle-selector="#demo-code"
340
+ ><i src="/assets/svg/eye-slash.svg"></i
341
+ ></a>
342
+ <a
343
+ class="margin-right:10px"
344
+ id="code"
345
+ show="#code-slash"
346
+ hide="#code, #demo-code"
347
+ ><i src="/assets/svg/code.svg"></i
348
+ ></a>
349
+ <a
350
+ class="margin-right:10px"
351
+ hidden
352
+ id="code-slash"
353
+ show="#code, #demo-code"
354
+ hide="#code-slash"
355
+ ><i class="height:18px" src="/assets/svg/code.svg"></i
356
+ ></a>
357
+ <a
358
+ class="margin-right:5px"
359
+ fullscreen
360
+ fullscreen-selector="#playground"
361
+ ></a>
362
+ </div>
398
363
  </div>
399
- <button
400
- href="https://github.com/CoCreate-app/overflow:auto/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..."
401
- target="_blank"
402
- class="display:flex justify-content:center align-items:center position:fixed bottom:15px right:15px height:50px width:50px border-radius:50% box-shadow:0px_2px_10px_0px_rgba(0,_0,_0,_0.4)">
403
- <i class="height:20px" src="../assets/svg/pencil-alt.svg"></i>
404
- </button>
405
- </main>
364
+ <!-- End SandBox -->
365
+ </div>
366
+ </div>
367
+ </div>
368
+ <button
369
+ href="https://github.com/CoCreate-app/overflow:auto/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..."
370
+ target="_blank"
371
+ class="display:flex justify-content:center align-items:center position:fixed bottom:15px right:15px height:50px width:50px border-radius:50% box-shadow:0px_2px_10px_0px_rgba(0,_0,_0,_0.4)"
372
+ >
373
+ <i src="../assets/svg/pencil-alt.svg"></i>
374
+ </button>
375
+ </main>
406
376
 
407
- <script src="https://CoCreate.app/dist/CoCreate.js"></script>
408
- </body>
377
+ <script src="https://CoCreate.app/dist/CoCreate.js"></script>
378
+ </body>
409
379
  </html>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cocreate/scroll",
3
- "version": "1.11.3",
3
+ "version": "1.13.0",
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",
@@ -58,6 +58,7 @@
58
58
  "webpack-log": "^3.0.1"
59
59
  },
60
60
  "dependencies": {
61
- "@cocreate/observer": "^1.16.1"
61
+ "@cocreate/observer": "^1.16.1",
62
+ "@cocreate/actions": "^1.19.1"
62
63
  }
63
64
  }
@@ -0,0 +1,16 @@
1
+ module.exports = {
2
+ tabWidth: 4,
3
+ semi: true,
4
+ trailingComma: "none",
5
+ bracketSameLine: true,
6
+ useTabs: true,
7
+ overrides: [
8
+ {
9
+ files: ["*.json", "*.yml", "*.yaml"],
10
+ options: {
11
+ tabWidth: 2,
12
+ useTabs: false
13
+ },
14
+ }
15
+ ],
16
+ };
package/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
- import observer from '@cocreate/observer';
1
+ import Observer from '@cocreate/observer';
2
+ import Actions from '@cocreate/actions';
2
3
 
3
4
  const CoCreateScroll = {
4
5
  delta: 3,
@@ -7,7 +8,7 @@ const CoCreateScroll = {
7
8
  firedEvents: new Map(),
8
9
 
9
10
  init: function () {
10
- let elements = document.querySelectorAll(`[scroll]`);
11
+ let elements = document.querySelectorAll(`[scroll], [scroll-to], [scrollable-x], [scrollable-y]`);
11
12
  this.__initIntersectionObserver();
12
13
  this.initElements(elements);
13
14
  },
@@ -25,9 +26,14 @@ const CoCreateScroll = {
25
26
  const targetSelector = element.getAttribute('scroll-selector');
26
27
  const scrollSelector = element.getAttribute('scroll-element');
27
28
  const intersectValue = element.getAttribute('scroll-intersect');
29
+ const scrollTo = element.getAttribute('scroll-to');
28
30
 
29
- let values = element.getAttribute('scroll') || "";
30
- values = values.split(",").map(x => x.trim());
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());
31
37
 
32
38
  let scrollInfo = {
33
39
  attrName: attrName,
@@ -37,7 +43,8 @@ const CoCreateScroll = {
37
43
  scrollTop: element.getAttribute('scroll-top'),
38
44
  scrollLimbo: element.getAttribute('scroll-limbo'),
39
45
  scrollBottom: element.getAttribute('scroll-bottom'),
40
- scrolling: element.getAttribute('scrolling')
46
+ scrolling: element.getAttribute('scrolling'),
47
+ scrollTo
41
48
  };
42
49
 
43
50
  let elements = [element];
@@ -54,6 +61,8 @@ const CoCreateScroll = {
54
61
  let scrollableElements;
55
62
  if (scrollSelector)
56
63
  scrollableElements = document.querySelectorAll(scrollSelector);
64
+ else if (element.hasAttribute('scroll-element'))
65
+ scrollableElements = [element]
57
66
 
58
67
  if (scrollableElements) {
59
68
  for (let scrollableEl of scrollableElements) {
@@ -71,6 +80,10 @@ const CoCreateScroll = {
71
80
  if (intersectValue && window.IntersectionObserver && this.observer) {
72
81
  this.observer.observe(element);
73
82
  }
83
+
84
+ if (scrollTo) {
85
+ this.setScrollPosition(element, scrollTo)
86
+ }
74
87
  },
75
88
 
76
89
  _scrollEvent: function (elements, element, scrollInfo, scrollableEl) {
@@ -99,6 +112,22 @@ const CoCreateScroll = {
99
112
  }, 500);
100
113
  },
101
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
+
102
131
  __initIntersectionObserver: function () {
103
132
  const self = this;
104
133
  this.observer = new IntersectionObserver(entries => {
@@ -114,8 +143,7 @@ const CoCreateScroll = {
114
143
  }
115
144
  if (entry.isIntersecting > 0) {
116
145
  targetElements.forEach((el) => self.__addAttributeValue(el, attrName, intersectValue));
117
- }
118
- else {
146
+ } else {
119
147
  targetElements.forEach((el) => self.__removeAttrbuteValue(el, attrName, intersectValue));
120
148
  }
121
149
  });
@@ -126,8 +154,7 @@ const CoCreateScroll = {
126
154
  const { scrolling, attrName } = info;
127
155
  if (stopped) {
128
156
  this.__removeAttrbuteValue(element, attrName, scrolling);
129
- }
130
- else {
157
+ } else {
131
158
  this.__addAttributeValue(element, attrName, scrolling);
132
159
  }
133
160
  },
@@ -154,20 +181,19 @@ const CoCreateScroll = {
154
181
  if (upSize <= (currentPos - scrollY)) {
155
182
  this.__addAttributeValue(element, attrName, values[0]);
156
183
  this.__removeAttrbuteValue(element, attrName, values[1]);
157
- }
158
- else if (downSize <= (scrollY - currentPos)) {
184
+ } else if (downSize <= (scrollY - currentPos)) {
159
185
  this.__removeAttrbuteValue(element, attrName, values[0]);
160
186
  this.__addAttributeValue(element, attrName, values[1]);
161
187
  }
162
188
  }
189
+
163
190
  //. scroll top case
164
191
  if (scrollY <= this.delta) {
165
192
  this.__removeAttrbuteValue(element, attrName, values[0]);
166
193
  this.__removeAttrbuteValue(element, attrName, values[1]);
167
194
 
168
195
  this.__addAttributeValue(element, attrName, scrollTop);
169
- }
170
- else {
196
+ } else {
171
197
  this.__removeAttrbuteValue(element, attrName, scrollTop);
172
198
  }
173
199
 
@@ -178,16 +204,14 @@ const CoCreateScroll = {
178
204
  // this.__removeAttrbuteValue(element, attrName, values[1]);
179
205
 
180
206
  this.__addAttributeValue(element, attrName, scrollBottom);
181
- }
182
- else {
207
+ } else {
183
208
  this.__removeAttrbuteValue(element, attrName, scrollBottom);
184
209
  }
185
210
 
186
211
  // if (scrollY != 0 && (scrollY + window.innerHeight) != document.body.scrollHeight){
187
212
  if (scrollY != 0 && (scrollY + innerHeight) != scrollHeight) {
188
213
  this.__addAttributeValue(element, attrName, scrollLimbo);
189
- }
190
- else {
214
+ } else {
191
215
  this.__removeAttrbuteValue(element, attrName, scrollLimbo);
192
216
  }
193
217
 
@@ -200,7 +224,10 @@ const CoCreateScroll = {
200
224
  let attrValue = element.getAttribute(attrName) || "";
201
225
 
202
226
  if (!check.test(attrValue)) {
203
- attrValue += " " + value;
227
+ if (attrName === 'class')
228
+ attrValue += " " + value;
229
+ else
230
+ attrValue = value
204
231
  element.setAttribute(attrName, attrValue);
205
232
  }
206
233
  },
@@ -228,8 +255,7 @@ const CoCreateScroll = {
228
255
 
229
256
  size = isWidth ? window.innerWidth / size : window.innerHeight / size;
230
257
 
231
- }
232
- else {
258
+ } else {
233
259
  size = attrValue.replace('px', '').trim();
234
260
  size = Number(size) || 0;
235
261
  }
@@ -239,16 +265,58 @@ const CoCreateScroll = {
239
265
 
240
266
  };
241
267
 
242
- observer.init({
268
+ 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
+ }
282
+ }
283
+
284
+ Observer.init({
243
285
  name: 'CoCreateScrollCreate',
244
286
  observe: ['addedNodes'],
245
- target: '[scroll]',
287
+ selector: '[scroll], [scroll-to], [scrollable-x], [scrollable-y]',
246
288
  callback: function (mutation) {
247
-
248
289
  CoCreateScroll.initElement(mutation.target);
249
290
  }
250
291
  });
251
292
 
293
+ 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
+ }
301
+ });
302
+ 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
+ }
311
+ });
312
+
313
+ Actions.init({
314
+ name: "scroll-to",
315
+ callback: (action) => {
316
+ // CoCreateScroll.setScrollPosition(mutation.target)
317
+ }
318
+ });
319
+
252
320
  CoCreateScroll.init();
253
321
 
254
322
  export default CoCreateScroll;