MCPcopy Create free account
hub / github.com/dailydotdev/apps / moveShell

Function moveShell

packages/shared/src/components/shell/shellMove.ts:96–192  ·  view source on GitHub ↗
(
  router: NextRouter,
  move: ShellMove,
  navigate: () => void,
)

Source from the content-addressed store, hash-verified

94// screen does on iOS. The live page never moves; it is revealed where its
95// copy landed. The look of the move is in shell.css.
96export const moveShell = (
97 router: NextRouter,
98 move: ShellMove,
99 navigate: () => void,
100): void => {
101 if (!canMove()) {
102 navigate();
103 return;
104 }
105 active?.();
106
107 const root = document.documentElement;
108 const leaving = makeGhost(pageFlowRoot());
109 document.body.appendChild(leaving);
110 root.dataset.shellMove = move;
111
112 let timeout = 0;
113 let frame = 0;
114 let ending = 0;
115 let arriving: HTMLElement | undefined;
116 const listeners: Array<[RouteEvent, () => void]> = [];
117 const cleanup = () => {
118 window.clearTimeout(timeout);
119 window.clearTimeout(ending);
120 cancelAnimationFrame(frame);
121 listeners.forEach(([name, handler]) => router.events.off(name, handler));
122 leaving.remove();
123 arriving?.remove();
124 delete root.dataset.shellMove;
125 if (active === cleanup) {
126 active = undefined;
127 }
128 };
129 active = cleanup;
130
131 const travel = `${pageDuration}ms var(--shell-ease-travel)`;
132 const slide = () => {
133 if (move === ShellMove.Switch) {
134 Object.assign(leaving.style, {
135 transition: `opacity ${pageDuration / 2}ms ease-out`,
136 opacity: '0',
137 });
138 ending = window.setTimeout(cleanup, pageDuration / 2);
139 return;
140 }
141 arriving = makeGhost(pageFlowRoot());
142 document.body.appendChild(arriving);
143 leaving.classList.add('shell-ghost-over');
144 Object.assign(leaving.style, {
145 transition: 'none',
146 willChange: 'transform',
147 transform: 'translateX(0px)',
148 });
149 Object.assign(arriving.style, {
150 transition: 'none',
151 willChange: 'transform, filter',
152 transform: `translateX(${underShift})`,
153 filter: underShade,

Callers 4

activateFunction · 0.90
onPointerUpFunction · 0.90
useShellBackFunction · 0.90
shellMove.spec.tsFile · 0.90

Calls 5

pageFlowRootFunction · 0.90
canMoveFunction · 0.85
makeGhostFunction · 0.85
pushMethod · 0.80
navigateFunction · 0.50

Tested by

no test coverage detected