()
| 453 | let virtualY: number | null = null; |
| 454 | let glideTarget: number | null = null; |
| 455 | const update = () => { |
| 456 | frame = 0; |
| 457 | if (opening || closed) { |
| 458 | return; |
| 459 | } |
| 460 | const y = virtualY ?? restingY(); |
| 461 | headElement.style.setProperty( |
| 462 | '--reading-fold', |
| 463 | `${Math.min(1, Math.max(0, y / current.card))}`, |
| 464 | ); |
| 465 | // What the finger sees follows the height continuously: the controls |
| 466 | // and the chevron over the first stretch of a lift, the dim over the |
| 467 | // page up to the top, the page's block over the last stretch there. |
| 468 | // Nothing at the top of the screen flips on a threshold. |
| 469 | const lifted = y - current.card; |
| 470 | const liftAmount = Math.min( |
| 471 | 1, |
| 472 | Math.max(0, (lifted - liftDead) / liftRun), |
| 473 | ); |
| 474 | const dimAmount = Math.min( |
| 475 | 1, |
| 476 | Math.max(0, lifted / Math.max(1, current.full - current.card)), |
| 477 | ); |
| 478 | const riseAmount = Math.min( |
| 479 | 1, |
| 480 | Math.max(0, (y - (current.full - riseRun)) / riseRun), |
| 481 | ); |
| 482 | root.style.setProperty('--reading-lift', liftAmount.toFixed(3)); |
| 483 | root.style.setProperty('--reading-dim', dimAmount.toFixed(3)); |
| 484 | root.style.setProperty('--reading-rise', riseAmount.toFixed(3)); |
| 485 | // The hand-off of touches to the page behind, and the controls' own |
| 486 | // taps, switch once the post is clearly lifted, with room so a drag |
| 487 | // held around the card never flips them. |
| 488 | const up = root.classList.contains('reading-up') |
| 489 | ? lifted > scroll.revealTolerance |
| 490 | : lifted > liftHold; |
| 491 | const full = layout === 'full'; |
| 492 | root.classList.toggle('reading-up', up); |
| 493 | setReadingUp(up); |
| 494 | root.classList.toggle('reading-rising', riseAmount > 0); |
| 495 | root.classList.toggle('reading-past', y > current.full + head); |
| 496 | const boundary = up || hasOpenLayer() ? null : current.edge - controls; |
| 497 | // A toast over the page keeps its own touches. |
| 498 | const islands = Array.from( |
| 499 | document.querySelectorAll('[role="alert"]'), |
| 500 | (element) => element.getBoundingClientRect(), |
| 501 | ) |
| 502 | .filter( |
| 503 | (rect) => |
| 504 | rect.width > 1 && |
| 505 | rect.height > 1 && |
| 506 | rect.bottom > 0 && |
| 507 | rect.top < window.innerHeight, |
| 508 | ) |
| 509 | .map(({ x, y: top, width, height }) => |
| 510 | [x, top, width, height].map(Math.round), |
| 511 | ); |
| 512 | // Where the drawer's head rests, from the bottom of the screen: the |
no test coverage detected