@jsenv/navi 0.29.66 → 0.29.67
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/dist/jsenv_navi.js +442 -153
- package/dist/jsenv_navi.js.map +85 -50
- package/docs/route_transitions.md +71 -13
- package/package.json +1 -1
|
@@ -6,9 +6,10 @@ decides which movement (if any) a navigation deserves. The API grammar itself
|
|
|
6
6
|
(accepted forms, shipped type names) lives in the JSDoc of
|
|
7
7
|
`defineRouteTransition`; this file holds what a signature cannot say.
|
|
8
8
|
|
|
9
|
-
Demos:
|
|
10
|
-
[
|
|
11
|
-
[
|
|
9
|
+
Demos: [the movements](../src/nav/demos/route_transition/route_transition.html),
|
|
10
|
+
[a default transition](../src/nav/demos/route_transition/route_transition_default.html),
|
|
11
|
+
[pages between fixed bars](../src/nav/demos/route_transition/route_transition_fixed_bars.html),
|
|
12
|
+
[with a RouteTravel inside](../src/nav/demos/route_transition/route_transition_with_travel.html)
|
|
12
13
|
|
|
13
14
|
## What a transition is for
|
|
14
15
|
|
|
@@ -76,21 +77,63 @@ A default has no direction (nothing says which of two arbitrary pages is
|
|
|
76
77
|
"before" the other), so only directionless movements make sense there. Written
|
|
77
78
|
relations, and `"none"`, always win over it.
|
|
78
79
|
|
|
79
|
-
## Pages between fixed bars:
|
|
80
|
+
## Pages between fixed bars: the transition area
|
|
80
81
|
|
|
81
82
|
By default the movement plays on the document itself — right when pages are the
|
|
82
83
|
whole viewport. With fixed bars it is not: the root snapshot spans the viewport
|
|
83
|
-
and the bars' regions are blank in it, so
|
|
84
|
-
|
|
84
|
+
and the bars' regions are blank in it, so the moving picture drags a blank band
|
|
85
|
+
across the screen where they stand. Wrap the pages instead:
|
|
85
86
|
|
|
86
|
-
```
|
|
87
|
-
<
|
|
87
|
+
```jsx
|
|
88
|
+
<RouteTransitionArea className="app">
|
|
89
|
+
<Route>…</Route>
|
|
90
|
+
</RouteTransitionArea>
|
|
88
91
|
```
|
|
89
92
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
93
|
+
The movement then plays on that region's own pictures, and the bars never move
|
|
94
|
+
— without being named one by one. An app with fixed bars should consider this
|
|
95
|
+
part of declaring transitions at all, not an option.
|
|
96
|
+
|
|
97
|
+
The pages are cut twice: at the area's own bounds, and at the app's **safe
|
|
98
|
+
area** (see [safe_area.md](./safe_area.md)). The second cut is not a detail. A
|
|
99
|
+
fixed bar is fixed to the window while the area is a long box in the document —
|
|
100
|
+
the room the bar gives back is padding, so the content runs under it by design.
|
|
101
|
+
The pictures are drawn in the top layer, above everything the document can
|
|
102
|
+
clip, so without that cut a page taller than the screen, or a scrolled one,
|
|
103
|
+
would be watched sliding over the bars for the whole movement. The band is read
|
|
104
|
+
from the safe area rather than from the bars, so every kind of furniture is
|
|
105
|
+
covered at once and one that unmounts mid-movement is followed without anything
|
|
106
|
+
being told.
|
|
107
|
+
|
|
108
|
+
For the same reason, how far a page travels is the **window** it is seen
|
|
109
|
+
through, not the page's own size: a page is as tall as its content, and a
|
|
110
|
+
vertical movement measured on the picture would send it several screens away —
|
|
111
|
+
off screen for most of the transition, flying past at the end.
|
|
112
|
+
|
|
113
|
+
With an area marked, the page around it is left LIVE rather than photographed:
|
|
114
|
+
the bars keep answering the pointer for the whole movement, which a captured
|
|
115
|
+
element cannot do. The flip side is that anything around the area which must
|
|
116
|
+
_animate_ rather than stand still — a title that changes with the route — needs
|
|
117
|
+
a `view-transition-name` of its own; named, the browser moves it on the same
|
|
118
|
+
clock as the pages.
|
|
119
|
+
|
|
120
|
+
It is a `Box`, so the layout the pages need is written on it directly (`flex`,
|
|
121
|
+
`className`, `style`, …). An app that already has an element holding its pages
|
|
122
|
+
can mark that one with `data-navi-route-transition-area` rather than nesting
|
|
123
|
+
another — the component does exactly that.
|
|
124
|
+
|
|
125
|
+
**The area is a real box, and it has to be**: what gets photographed and
|
|
126
|
+
clipped IS its rectangle. So `display: contents` cannot be used on it — an
|
|
127
|
+
element with no box is never captured, and the movement then plays on nothing
|
|
128
|
+
(the browser also aborts the transition). This is measured behaviour, not a
|
|
129
|
+
precaution.
|
|
130
|
+
|
|
131
|
+
Three misconfigurations are silent enough to be worth a console warning, each
|
|
132
|
+
said once: an area that was not captured (the case above), several elements
|
|
133
|
+
marked at once (they would share one `view-transition-name`, and the browser
|
|
134
|
+
then refuses **every** view transition of the document), and pages travelling
|
|
135
|
+
on the document while something else is captured on its own — the blank band.
|
|
136
|
+
A warning here is a bug to fix, not a mechanism to lean on.
|
|
94
137
|
|
|
95
138
|
## Custom movements
|
|
96
139
|
|
|
@@ -111,13 +154,28 @@ shape, and the `spin` type in the demo for a working one.
|
|
|
111
154
|
- **`defineRouteTransition`** declares individual relations, with no gesture
|
|
112
155
|
and no order beyond each pair.
|
|
113
156
|
|
|
114
|
-
A given
|
|
157
|
+
A given PAIR of routes must be animated by one of the two, never both: a
|
|
115
158
|
travel's pictures can be under a finger, and a transition starting on top would
|
|
116
159
|
skip them mid-slide — and a page one can drag has promised a translation, which
|
|
117
160
|
a cross-fade would break. The runtime enforces the priority (a travel in flight
|
|
118
161
|
wins; the route transition is skipped with a console warning); the warning is
|
|
119
162
|
the sign of a misconfiguration to fix, not a mechanism to rely on.
|
|
120
163
|
|
|
164
|
+
The two DO live together in one app, on different pairs, including a
|
|
165
|
+
`<RouteTravel>` nested inside a `<RouteTransitionArea>` — a row of sections the
|
|
166
|
+
thumb pushes, inside pages one goes into. Write the relations on the routes the
|
|
167
|
+
row does not own: the tabs of the row travel, and opening something from any of
|
|
168
|
+
them plays its own movement. A relation written on a bare route covers every
|
|
169
|
+
one of its params at once, which is what makes "from any section" one line
|
|
170
|
+
rather than one per tab. Demo:
|
|
171
|
+
[../src/nav/demos/route_transition/route_transition_with_travel.html](../src/nav/demos/route_transition/route_transition_with_travel.html)
|
|
172
|
+
|
|
173
|
+
One trap that belongs to `RouteTravel` rather than to transitions, but bites
|
|
174
|
+
here first: the travelling box must stay MOUNTED across the changes it
|
|
175
|
+
animates. A `<RouteTravel>` rendered inside the `element` of each of the routes
|
|
176
|
+
it travels between is destroyed mid-travel by the router. Give the row a single
|
|
177
|
+
branch — its tabs as params of one route is the usual shape.
|
|
178
|
+
|
|
121
179
|
## The rest, briefly
|
|
122
180
|
|
|
123
181
|
- Pace: `--navi-route-transition-duration` (CSS, default 300ms) for everyone;
|