@cocreate/scrollbar 0.0.0-stage → 1.12.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.
@@ -0,0 +1,97 @@
1
+ # Contributing to CoCreate-overlay-scroll
2
+
3
+ This project is work of [many contributors](https://github.com/CoCreateJS/overlay-scroll/graphs/contributors).
4
+ You're encouraged to submit [pull requests](https://github.com/CoCreateJS/overlay-scroll/pulls),
5
+ [propose features and discuss issues](https://github.com/CoCreateJS/overlay-scroll/issues).
6
+
7
+ In the examples below, substitute your Github username for `contributor` in URLs.
8
+
9
+ ## Fork the Project
10
+
11
+ Fork the [project on Github](https://github.com/CoCreateJS/overlay-scroll) and check out your copy.
12
+
13
+ ```
14
+ git overlay-scroll https://github.com/contributor/CoCreate-overlay-scroll.git
15
+ cd CoCreate-overlay-scroll
16
+ git remote add upstream https://github.com/CoCreateJS/overlay-scroll.git
17
+ ```
18
+
19
+ ## Create a Topic Branch
20
+
21
+ Make sure your fork is up-to-date and create a topic branch for your feature or bug fix on dev branch.
22
+
23
+ ```
24
+ git checkout dev
25
+ git pull upstream dev
26
+ git checkout -b my-feature-branch
27
+ ```
28
+
29
+ ## Write Tests
30
+
31
+ Try to write a test that reproduces the problem you're trying to fix or describes a feature that you want to build.
32
+
33
+ We definitely appreciate pull requests that highlight or reproduce a problem, even without a fix.
34
+
35
+ ## Write Code
36
+
37
+ Implement your feature or bug fix.
38
+
39
+ ## Write Documentation
40
+
41
+ Document any external behavior in the [README](README.md).
42
+
43
+ ## Commit Changes
44
+
45
+ Make sure git knows your name and email address:
46
+
47
+ ```
48
+ git config --global user.name "Your Name"
49
+ git config --global user.email "contributor@example.com"
50
+ ```
51
+
52
+ We use [semantic-release](https://github.com/semantic-release/semantic-release) as process to generate changelog
53
+ and to release. Write meaningful commits according to
54
+ [Commit Message Formats](https://github.com/semantic-release/semantic-release#commit-message-format) is important.
55
+
56
+ ```
57
+ git add ...
58
+ git commit -am "commit-type(optional topic): a meaningful message"
59
+ ```
60
+
61
+ Here is an example of the release type that should be done based on a [semantic-release](https://github.com/semantic-release/semantic-release):
62
+
63
+ | Commit message | Release type |
64
+ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | -------------------------- |
65
+ | `fix(pencil): stop graphite breaking when too much pressure applied` | Patch Release |
66
+ | `feat(pencil): add 'graphiteWidth' option` | ~~Minor~~ Feature Release |
67
+ | `perf(pencil): remove graphiteWidth option`<br><br>`BREAKING CHANGE: The graphiteWidth option has been removed.`<br>`The default graphite width of 10mm is always used for performance reasons.` | ~~Major~~ Breaking Release |
68
+
69
+
70
+ ## Push
71
+
72
+ ```
73
+ git push origin my-feature-branch
74
+ ```
75
+
76
+ ## Make a Pull Request
77
+
78
+ Go to [https://github.com/CoCreateJS/overlay-scroll](https://github.com/CoCreateJS/overlay-scroll) and select your feature branch.
79
+ Click the 'Pull Request' button and fill out the form. Pull requests are usually reviewed within a few days.
80
+
81
+ ## Rebase
82
+
83
+ If you've been working on a change for a while, rebase with upstream/dev.
84
+
85
+ ```
86
+ git fetch upstream
87
+ git rebase upstream/dev
88
+ git push origin my-feature-branch -f
89
+ ```
90
+
91
+ ## Be Patient
92
+
93
+ It's likely that your change will not be merged and that the nitpicky maintainers will ask you to do more, or fix seemingly benign problems. Hang in there!
94
+
95
+ ## Thank You
96
+
97
+ Please do know that we really appreciate and value your time and work. We love you, really.
@@ -0,0 +1,23 @@
1
+ module.exports = {
2
+ "organization_id": "",
3
+ "key": "",
4
+ "host": "",
5
+ "sources": [
6
+ {
7
+ "array": "files",
8
+ "object": {
9
+ "_id": "6020801d3c260207bf49caba",
10
+ "name": "index.html",
11
+ "path": "/docs/overlay-scroll",
12
+ "pathname": "/docs/overlay-scroll/index.html",
13
+ "src": "{{./docs/index.html}}",
14
+ "host": [
15
+ "*"
16
+ ],
17
+ "directory": "overlay-scroll",
18
+ "content-type": "{{content-type}}",
19
+ "public": "true"
20
+ }
21
+ }
22
+ ]
23
+ };
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 CoCreate LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,148 @@
1
- # Temporary Holding Version
1
+ # CoCreate Scrollbar
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A declarative custom scrollbar for native scroll containers with configurable
4
+ axes, track positions, visibility, and automatic DOM lifecycle handling.
5
+
6
+ The component preserves browser-native scrolling, including wheel, keyboard,
7
+ touch, and programmatic scrolling. It hides the native scrollbar and adds
8
+ custom overlay tracks and draggable thumbs.
9
+
10
+ ## Installation
11
+
12
+ ```shell
13
+ npm install @cocreate/scrollbar
14
+ ```
15
+
16
+ ```shell
17
+ yarn add @cocreate/scrollbar
18
+ ```
19
+
20
+ Importing the package loads its styles and initializes every element with a
21
+ `scrollbar` attribute.
22
+
23
+ ```js
24
+ import CoCreateScrollbar from "@cocreate/scrollbar";
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ Give the scrollbar host a constrained width and height. Its first element child
30
+ becomes the native scrolling viewport.
31
+
32
+ ```html
33
+ <div scrollbar style="height: 300px">
34
+ <div>
35
+ <!-- Scrollable content -->
36
+ </div>
37
+ </div>
38
+ ```
39
+
40
+ The host owns the generated tracks. Keep asynchronously loaded content inside
41
+ the viewport rather than placing `src` on the scrollbar host:
42
+
43
+ ```html
44
+ <div scrollbar style="height: 300px">
45
+ <div>
46
+ <div src="/components/content.html"></div>
47
+ </div>
48
+ </div>
49
+ ```
50
+
51
+ This prevents fetched content from replacing the viewport and generated track
52
+ structure.
53
+
54
+ ## Attributes
55
+
56
+ | Attribute | Values | Default | Purpose |
57
+ | --- | --- | --- | --- |
58
+ | `scrollbar` | Boolean attribute | — | Initializes the component. |
59
+ | `scrollbar-type` | `scrollx`, `scrolly`, or both | `scrollx scrolly` | Enables the requested axes. |
60
+ | `scrollbar-pos` | `left` or `right`, plus `top` or `bottom` | `right bottom` | Positions the vertical and horizontal tracks. |
61
+ | `scrollbar-visible` | `auto` or `show` | `auto` | Shows tracks contextually or keeps them visible. |
62
+
63
+ ### Vertical scrolling only
64
+
65
+ ```html
66
+ <div scrollbar scrollbar-type="scrolly" style="height: 300px">
67
+ <div>...</div>
68
+ </div>
69
+ ```
70
+
71
+ ### Tracks on the top and left
72
+
73
+ ```html
74
+ <div scrollbar scrollbar-pos="top left" style="height: 300px">
75
+ <div>...</div>
76
+ </div>
77
+ ```
78
+
79
+ ### Always-visible tracks
80
+
81
+ ```html
82
+ <div scrollbar scrollbar-visible="show" style="height: 300px">
83
+ <div>...</div>
84
+ </div>
85
+ ```
86
+
87
+ Attribute changes are applied dynamically. Adding or removing the `scrollbar`
88
+ attribute initializes or destroys the instance, while changing an option
89
+ attribute refreshes it.
90
+
91
+ ## JavaScript API
92
+
93
+ ```js
94
+ const element = document.querySelector("[scrollbar]");
95
+
96
+ const instance = CoCreateScrollbar.init(element);
97
+ CoCreateScrollbar.get(element);
98
+ CoCreateScrollbar.destroy(element);
99
+ CoCreateScrollbar.initAll();
100
+ ```
101
+
102
+ `init()` accepts an element, a selector, or an array-like collection. Elements
103
+ inserted into or removed from the document are also initialized and destroyed
104
+ automatically through `@cocreate/observer`.
105
+
106
+ ## Update event
107
+
108
+ The host dispatches `cocreate-scroll-update` whenever its scrollbar geometry is
109
+ recalculated.
110
+
111
+ ```js
112
+ element.addEventListener("cocreate-scroll-update", (event) => {
113
+ console.log(event.detail.scrollTop, event.detail.maxScrollY);
114
+ });
115
+ ```
116
+
117
+ The event detail includes:
118
+
119
+ - `scrollTop` and `scrollLeft`
120
+ - `maxScrollY` and `maxScrollX`
121
+ - `clientHeight` and `clientWidth`
122
+ - `thumbVHeight` and `thumbHWidth`
123
+
124
+ ## Styling
125
+
126
+ Customize the tracks with CSS variables on the scrollbar host:
127
+
128
+ ```css
129
+ .my-scrollbar {
130
+ --cc-track-bg: rgb(0 0 0 / 8%);
131
+ --cc-thumb-bg: rgb(99 102 241 / 75%);
132
+ --cc-thumb-hover-bg: rgb(129 140 248);
133
+ }
134
+ ```
135
+
136
+ The stylesheet also includes `theme-indigo`, `theme-emerald`, `theme-rose`,
137
+ `theme-amber`, `theme-glass`, and `theme-dark` preset classes.
138
+
139
+ ## Project links
140
+
141
+ - [Documentation](https://CoCreateJS.com/docs/scrollbar)
142
+ - [Issues](https://github.com/CoCreateJS/scrollbar/issues)
143
+ - [Releases](https://github.com/CoCreateJS/scrollbar/releases)
144
+ - [Contributing](https://github.com/CoCreateJS/scrollbar/blob/master/CONTRIBUTING.md)
145
+
146
+ ## License
147
+
148
+ [MIT](https://github.com/CoCreateJS/scrollbar/blob/master/LICENSE)
@@ -0,0 +1,196 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8" />
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
6
+ <title>Scrollbar | CoCreateJS</title>
7
+
8
+ <link
9
+ rel="icon"
10
+ type="image/png"
11
+ sizes="32x32"
12
+ href="../assets/favicon.ico" />
13
+ <link
14
+ rel="stylesheet"
15
+ href="../dist/CoCreate-overlay-scroll.css"
16
+ type="text/css" />
17
+
18
+ <style>
19
+ * {
20
+ box-sizing: border-box;
21
+ }
22
+
23
+ body {
24
+ margin: 0;
25
+ padding: 32px;
26
+ color: #1f2937;
27
+ background: #f3f4f6;
28
+ font-family: Arial, sans-serif;
29
+ }
30
+
31
+ h1 {
32
+ margin: 0 0 8px;
33
+ }
34
+
35
+ .description {
36
+ margin: 0 0 32px;
37
+ color: #6b7280;
38
+ }
39
+
40
+ .examples {
41
+ display: grid;
42
+ grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
43
+ gap: 24px;
44
+ }
45
+
46
+ .example {
47
+ padding: 16px;
48
+ border: 1px solid #e5e7eb;
49
+ border-radius: 12px;
50
+ background: #ffffff;
51
+ }
52
+
53
+ .example h2 {
54
+ margin: 0 0 12px;
55
+ font-size: 16px;
56
+ }
57
+
58
+ .scrollbar-demo {
59
+ width: 100%;
60
+ height: 240px;
61
+ border: 1px solid #d1d5db;
62
+ border-radius: 8px;
63
+ background: #ffffff;
64
+ }
65
+
66
+ .scrollbar-demo.theme-dark {
67
+ border-color: #374151;
68
+ color: #f9fafb;
69
+ background: #111827;
70
+ }
71
+
72
+ .content {
73
+ display: grid;
74
+ place-items: center;
75
+ min-width: 100%;
76
+ min-height: 100%;
77
+ padding: 24px;
78
+ color: #374151;
79
+ background:
80
+ linear-gradient(135deg, rgba(99, 102, 241, 0.18), rgba(16, 185, 129, 0.18)),
81
+ repeating-linear-gradient(
82
+ 0deg,
83
+ transparent,
84
+ transparent 39px,
85
+ rgba(107, 114, 128, 0.18) 40px
86
+ ),
87
+ repeating-linear-gradient(
88
+ 90deg,
89
+ transparent,
90
+ transparent 39px,
91
+ rgba(107, 114, 128, 0.18) 40px
92
+ );
93
+ }
94
+
95
+ .theme-dark .content {
96
+ color: #f9fafb;
97
+ }
98
+
99
+ .content-both {
100
+ width: 640px;
101
+ height: 520px;
102
+ }
103
+
104
+ .content-x {
105
+ width: 720px;
106
+ height: 100%;
107
+ }
108
+
109
+ .content-y {
110
+ width: 100%;
111
+ height: 640px;
112
+ }
113
+ </style>
114
+ </head>
115
+
116
+ <body>
117
+ <h1>CoCreate Scrollbar</h1>
118
+ <p class="description">
119
+ The first child remains the native scrolling viewport. Only the
120
+ overlay tracks and thumbs are generated.
121
+ </p>
122
+
123
+ <main class="examples">
124
+ <section class="example">
125
+ <h2>Horizontal and vertical</h2>
126
+ <div class="scrollbar-demo" scrollbar>
127
+ <div>
128
+ <div class="content content-both">Scroll in either direction</div>
129
+ </div>
130
+ </div>
131
+ </section>
132
+
133
+ <section class="example">
134
+ <h2>Horizontal only</h2>
135
+ <div
136
+ class="scrollbar-demo"
137
+ scrollbar
138
+ scrollbar-type="scrollx">
139
+ <div>
140
+ <div class="content content-x">Horizontal scrolling</div>
141
+ </div>
142
+ </div>
143
+ </section>
144
+
145
+ <section class="example">
146
+ <h2>Vertical only</h2>
147
+ <div
148
+ class="scrollbar-demo"
149
+ scrollbar
150
+ scrollbar-type="scrolly">
151
+ <div>
152
+ <div class="content content-y">Vertical scrolling</div>
153
+ </div>
154
+ </div>
155
+ </section>
156
+
157
+ <section class="example">
158
+ <h2>Top and left</h2>
159
+ <div
160
+ class="scrollbar-demo"
161
+ scrollbar
162
+ scrollbar-pos="top left">
163
+ <div>
164
+ <div class="content content-both">Tracks positioned top and left</div>
165
+ </div>
166
+ </div>
167
+ </section>
168
+
169
+ <section class="example">
170
+ <h2>Always visible</h2>
171
+ <div
172
+ class="scrollbar-demo theme-emerald"
173
+ scrollbar
174
+ scrollbar-visible="show">
175
+ <div>
176
+ <div class="content content-both">Tracks remain visible</div>
177
+ </div>
178
+ </div>
179
+ </section>
180
+
181
+ <section class="example">
182
+ <h2>Dark theme</h2>
183
+ <div
184
+ class="scrollbar-demo theme-dark"
185
+ scrollbar
186
+ scrollbar-visible="show">
187
+ <div>
188
+ <div class="content content-both">Dark scrollbar theme</div>
189
+ </div>
190
+ </div>
191
+ </section>
192
+ </main>
193
+
194
+ <script src="../dist/CoCreate-overlay-scroll.js"></script>
195
+ </body>
196
+ </html>