@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 +23 -0
- package/demo/index.html +2 -1
- package/docs/index.html +363 -393
- package/package.json +3 -2
- package/prettier.config.js +16 -0
- package/src/index.js +91 -23
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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
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
|
-
<
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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"><script>https://cdn.cocreate.app/scroll/latest/overflow:auto.min.js</script></code></pre>
|
|
145
155
|
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
-
|
|
170
|
-
|
|
177
|
+
<div class="flex-grow:1 min-width:300px width:100%">
|
|
178
|
+
<pre>
|
|
171
179
|
<code class="language-html">
|
|
172
180
|
<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"></code>
|
|
173
181
|
</pre>
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
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
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
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
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
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
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
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
|
-
|
|
408
|
-
|
|
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.
|
|
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
|
}
|
package/src/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
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
|
-
|
|
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());
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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;
|