(expanded: boolean)
| 62 | }; |
| 63 | |
| 64 | const settleTo = (expanded: boolean) => { |
| 65 | endSettle(); |
| 66 | panel.removeAttribute('data-dragging'); |
| 67 | style.transition = `height ${motion.snap}ms ${motion.interaction}, transform ${motion.snap}ms ${motion.interaction}, padding-top ${motion.snap}ms ${motion.interaction}`; |
| 68 | style.transform = ''; |
| 69 | // The distance left to the top; a sheet that covers the status bar pads |
| 70 | // its content by how far it has entered it. |
| 71 | style.removeProperty('--sheet-gap'); |
| 72 | if (expanded) { |
| 73 | panel.setAttribute('data-expanded', 'true'); |
| 74 | // The attribute's rule carries the full height; the inline height |
| 75 | // only had to be a number for the transition to start from. |
| 76 | style.height = `${fullHeight}px`; |
| 77 | } else { |
| 78 | panel.removeAttribute('data-expanded'); |
| 79 | style.height = `${restHeight}px`; |
| 80 | } |
| 81 | // A child's transition ending (a row's press colour) is not the sheet |
| 82 | // settling; and a release exactly at a stop transitions nothing, so the |
| 83 | // timer ends the settle when no event will. |
| 84 | const onTransitionEnd = (event: TransitionEvent) => { |
| 85 | if (event.target === panel) { |
| 86 | endSettle(); |
| 87 | } |
| 88 | }; |
| 89 | const timer = setTimeout(() => endSettle(), motion.snap + 80); |
| 90 | endSettle = () => { |
| 91 | endSettle = () => undefined; |
| 92 | clearTimeout(timer); |
| 93 | panel.removeEventListener('transitionend', onTransitionEnd); |
| 94 | style.transition = ''; |
| 95 | style.maxHeight = ''; |
| 96 | if (!isExpanded()) { |
| 97 | style.height = ''; |
| 98 | } |
| 99 | }; |
| 100 | panel.addEventListener('transitionend', onTransitionEnd); |
| 101 | }; |
| 102 | |
| 103 | // A finger on a field, or inside a list that is scrolled, is not a drag. |
| 104 | const startsInContent = (target: EventTarget | null): boolean => { |
no test coverage detected