@plusguard/anchor 0.0.0-stage → 3.3.2
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/LICENSE +21 -0
- package/README.md +625 -2
- package/dist/index.d.ts +4 -0
- package/dist/index.js +692 -0
- package/index.css +156 -0
- package/index.ts +716 -0
- package/package.json +21 -5
package/index.css
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* anchor — the CSS half.
|
|
3
|
+
*
|
|
4
|
+
* Lengths, set anywhere above the element — with media queries for each
|
|
5
|
+
* screen size:
|
|
6
|
+
* --pg-anchor-edge extra room above a section it lands on, on
|
|
7
|
+
* top of scroll-padding-top / scroll-margin-top.
|
|
8
|
+
* Default 0px
|
|
9
|
+
* --pg-anchor-show-after how far the page scrolls before a
|
|
10
|
+
* data-pg-anchor-visible element shows.
|
|
11
|
+
* Default 400px; 100svh is "one screen"
|
|
12
|
+
* --pg-anchor-avoid-space the gap kept from a data-pg-anchor-avoid area.
|
|
13
|
+
* Default 0px
|
|
14
|
+
*
|
|
15
|
+
* Keywords, the same way — they change with the screen too:
|
|
16
|
+
* --pg-anchor-when on a link, or above: when a click scrolls.
|
|
17
|
+
* always (default) · passed (only back up to a
|
|
18
|
+
* section scrolled past) · never
|
|
19
|
+
* --pg-anchor-avoid on a floating element, or above: auto
|
|
20
|
+
* (default) keeps clear of avoided areas, none
|
|
21
|
+
* ignores them
|
|
22
|
+
* --pg-anchor-stay inside a data-pg-anchor-stay box: auto
|
|
23
|
+
* (default) keeps the item clicked in place,
|
|
24
|
+
* none does not
|
|
25
|
+
* --pg-anchor-strip on a data-pg-anchor-strip row: where its
|
|
26
|
+
* current item is put. center (default) ·
|
|
27
|
+
* start · end · none
|
|
28
|
+
*
|
|
29
|
+
* The page's glide, on the link or above:
|
|
30
|
+
* --pg-anchor-duration a time. Default 1200ms; 0s is a jump
|
|
31
|
+
* --pg-anchor-easing linear, ease, ease-in, ease-out,
|
|
32
|
+
* ease-in-out or cubic-bezier(…). Default:
|
|
33
|
+
* Lenis's own curve
|
|
34
|
+
*
|
|
35
|
+
* The strip's slide:
|
|
36
|
+
* --pg-anchor-strip-duration a time. Default 500ms; 0s is at once
|
|
37
|
+
* --pg-anchor-strip-easing linear, ease, ease-in, ease-out,
|
|
38
|
+
* ease-in-out or cubic-bezier(…). Default:
|
|
39
|
+
* the page glide's own curve
|
|
40
|
+
*
|
|
41
|
+
* The ring of a data-pg-anchor-progress element — round, positioned (it
|
|
42
|
+
* is drawn by ::after, over the element's edge):
|
|
43
|
+
* --pg-anchor-progress-color the part filled. Default currentColor
|
|
44
|
+
* --pg-anchor-progress-track the rest. Default transparent
|
|
45
|
+
* --pg-anchor-progress-width its thickness. Default 2px; 0px hides it
|
|
46
|
+
*
|
|
47
|
+
* index.ts writes --pg-anchor-progress (0 to 1, on a
|
|
48
|
+
* data-pg-anchor-progress element), --pg-anchor-lift (how far the element stepped aside),
|
|
49
|
+
* --pg-anchor-clip (the part a "hide" area covers) and, on a
|
|
50
|
+
* data-pg-anchor-spy menu, --pg-anchor-current-left / -top / -width /
|
|
51
|
+
* -height.
|
|
52
|
+
*/
|
|
53
|
+
|
|
54
|
+
/* Registered as lengths so the browser resolves 1rem, 100svh, calc() to
|
|
55
|
+
pixels — index.ts reads them back. */
|
|
56
|
+
@property --pg-anchor-edge {
|
|
57
|
+
syntax: "<length>";
|
|
58
|
+
inherits: true;
|
|
59
|
+
initial-value: 0px;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
@property --pg-anchor-show-after {
|
|
63
|
+
syntax: "<length>";
|
|
64
|
+
inherits: true;
|
|
65
|
+
initial-value: 400px;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@property --pg-anchor-avoid-space {
|
|
69
|
+
syntax: "<length>";
|
|
70
|
+
inherits: true;
|
|
71
|
+
initial-value: 0px;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@property --pg-anchor-when {
|
|
75
|
+
syntax: "always | passed | never";
|
|
76
|
+
inherits: true;
|
|
77
|
+
initial-value: always;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
@property --pg-anchor-avoid {
|
|
81
|
+
syntax: "auto | none";
|
|
82
|
+
inherits: true;
|
|
83
|
+
initial-value: auto;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@property --pg-anchor-stay {
|
|
87
|
+
syntax: "auto | none";
|
|
88
|
+
inherits: true;
|
|
89
|
+
initial-value: auto;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@property --pg-anchor-strip {
|
|
93
|
+
syntax: "center | start | end | none";
|
|
94
|
+
inherits: true;
|
|
95
|
+
initial-value: center;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/* Times, so 0.3s and 300ms both read back the same. */
|
|
99
|
+
@property --pg-anchor-duration {
|
|
100
|
+
syntax: "<time>";
|
|
101
|
+
inherits: true;
|
|
102
|
+
initial-value: 1200ms;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
@property --pg-anchor-strip-duration {
|
|
106
|
+
syntax: "<time>";
|
|
107
|
+
inherits: true;
|
|
108
|
+
initial-value: 500ms;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/* Not a link or a button, but still clickable. Zero weight: yours wins. */
|
|
112
|
+
:where([data-pg-anchor]:not(a, button)) {
|
|
113
|
+
cursor: pointer;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
/* Hidden until the page has scrolled far enough — only when JS can say it
|
|
117
|
+
has. Zero weight, so a transition of your own can fade it. */
|
|
118
|
+
@media (scripting: enabled) {
|
|
119
|
+
:where([data-pg-anchor-visible="false"]) {
|
|
120
|
+
visibility: hidden;
|
|
121
|
+
opacity: 0;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/* Out of the way of an avoided area, by as much as index.ts measured. The
|
|
126
|
+
translate property, not transform: a transform of yours is kept. Under a
|
|
127
|
+
"hide" area, the covered part is cut off. */
|
|
128
|
+
[data-pg-anchor-visible] {
|
|
129
|
+
translate: 0 calc(var(--pg-anchor-lift, 0px) * -1);
|
|
130
|
+
clip-path: var(--pg-anchor-clip, none);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/* Wholly under a "hide" area: out of reach of Tab and clicks too. */
|
|
134
|
+
[data-pg-anchor-covered="true"] {
|
|
135
|
+
visibility: hidden;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/* The ring round a floating element: filled from the top, clockwise, as
|
|
139
|
+
far as the page has scrolled since the element showed. Drawn on the
|
|
140
|
+
element's own edge; a mask leaves only the ring. */
|
|
141
|
+
:where([data-pg-anchor-progress])::after {
|
|
142
|
+
content: "";
|
|
143
|
+
position: absolute;
|
|
144
|
+
inset: 0;
|
|
145
|
+
border-radius: inherit;
|
|
146
|
+
pointer-events: none;
|
|
147
|
+
background: conic-gradient(
|
|
148
|
+
var(--pg-anchor-progress-color, currentColor) calc(var(--pg-anchor-progress, 0) * 1turn),
|
|
149
|
+
var(--pg-anchor-progress-track, transparent) 0
|
|
150
|
+
);
|
|
151
|
+
mask: radial-gradient(
|
|
152
|
+
farthest-side,
|
|
153
|
+
transparent calc(100% - var(--pg-anchor-progress-width, 2px)),
|
|
154
|
+
#000 calc(100% - var(--pg-anchor-progress-width, 2px) + 0.5px)
|
|
155
|
+
);
|
|
156
|
+
}
|