66A small web component to enhance scrollable elements with dynamic scroll
77indicators.
88
9- 🔎 [ See the demo] [ demo-href ]
9+ - Easy to use: Just wrap your element with ` <scroll-shadow> `
10+ - Customizable scroll indicators
11+ - [ See the demo] [ demo-href ] 🔎
1012
1113## Installation
1214
@@ -45,13 +47,12 @@ Wrap any element for dynamically added scroll indicators. For example:
4547
4648``` html
4749<scroll-shadow >
48- <nav >Long navigation…</nav >
50+ <nav >Long navigation…</nav >
4951</scroll-shadow >
5052```
5153
52- > ** Note**
53- > When wrapping a non-scrollable ` <table> ` element, then its first ` <tbody> `
54- > will be used.
54+ ** Note** : When wrapping a non-scrollable ` <table> ` element, then its first
55+ ` <tbody> ` will be used.
5556
5657## Configuration
5758
@@ -61,25 +62,25 @@ You can change the default appearance with CSS.
6162
6263``` css
6364scroll-shadow {
64- display : inline-block ;
65- --scroll-shadow-size : 14 ;
66- --scroll-shadow-top : radial-gradient (farthest-side at 50% 0% , #0003 , #0000 );
67- --scroll-shadow-bottom : radial-gradient (farthest-side at 50% 100% , #0003 , #0000 );
68- --scroll-shadow-left : radial-gradient (farthest-side at 0% , #0003 , #0000 );
69- --scroll-shadow-right : radial-gradient (farthest-side at 100% , #0003 , #0000 );
65+ display : inline-block ;
66+ --scroll-shadow-size : 14 ;
67+ --scroll-shadow-top : radial-gradient (farthest-side at 50% 0% , #0003 , #0000 );
68+ --scroll-shadow-bottom : radial-gradient (farthest-side at 50% 100% , #0003 , #0000 );
69+ --scroll-shadow-left : radial-gradient (farthest-side at 0% , #0003 , #0000 );
70+ --scroll-shadow-right : radial-gradient (farthest-side at 100% , #0003 , #0000 );
7071}
7172```
7273
7374### Example: dark mode
7475
7576``` css
7677@media (prefers-color-scheme: dark) {
77- scroll-shadow {
78- --scroll-shadow-top : radial-gradient (farthest-side at 50% 0% , #fff3 , #0000 );
79- --scroll-shadow-bottom : radial-gradient (farthest-side at 50% 100% , #fff3 , #0000 );
80- --scroll-shadow-left : radial-gradient (farthest-side at 0% , #fff3 , #0000 );
81- --scroll-shadow-right : radial-gradient (farthest-side at 100% , #fff3 , #0000 );
82- }
78+ scroll-shadow {
79+ --scroll-shadow-top : radial-gradient (farthest-side at 50% 0% , #fff3 , #0000 );
80+ --scroll-shadow-bottom : radial-gradient (farthest-side at 50% 100% , #fff3 , #0000 );
81+ --scroll-shadow-left : radial-gradient (farthest-side at 0% , #fff3 , #0000 );
82+ --scroll-shadow-right : radial-gradient (farthest-side at 100% , #fff3 , #0000 );
83+ }
8384}
8485```
8586
@@ -97,8 +98,9 @@ scroll-shadow {
9798
9899` scroll-shadow-element ` works in all major browsers: all browsers that support
99100[ Custom Elements] [ custom-elementsv1 ] , [ Resize Observer] [ resizeobserver ] and the
100- [ ` min() ` CSS function] [ css-math-functions ] . In older browsers, the element just
101- won’t add scroll indicators.
101+ [ ` min() ` CSS function] [ css-math-functions ] (Chrome/Edge 79+, Safari 13.1+, iOS
102+ Safari 13.4+, Firefox 75+). In older browsers, the element just won’t add
103+ scroll indicators.
102104
103105The package is written with ES6 syntax. If you need to support older browsers,
104106you can configure your bundler to compile it to ES5 syntax.
@@ -107,11 +109,11 @@ you can configure your bundler to compile it to ES5 syntax.
107109
108110``` json
109111{
110- "jest" : {
111- "moduleNameMapper" : {
112- "^scroll-shadow-element$" : " jest-transform-stub"
113- }
114- }
112+ "jest" : {
113+ "moduleNameMapper" : {
114+ "^scroll-shadow-element$" : " jest-transform-stub"
115+ }
116+ }
115117}
116118```
117119
0 commit comments