forked from external-repos/squoosh
Mobile ui (#227)
* Basic grid setup * Fixing thumb on two-up * Adding margin so you can still access the two-up * Allow multi-panel to keep one open only * Edge cases for one-open * Abstracting results so it can be used as a heading. * Ordering of items in mobile view. Changing scrolling element. * Adding labels to collapsed view * Adding height animation to multi-panel * Fixing animation bugs * Expand/collapse icon * Allow two-up and pinch-zoom to work beneath controls * Range bubble now behaves properly on mobile * No longer need this. * Prevent options overflow at larger widths
This commit is contained in:
@@ -258,3 +258,43 @@ export function konami(): Promise<void> {
|
||||
window.addEventListener('keydown', listener);
|
||||
});
|
||||
}
|
||||
|
||||
interface TransitionOptions {
|
||||
from?: number;
|
||||
to?: number;
|
||||
duration?: number;
|
||||
easing?: string;
|
||||
}
|
||||
|
||||
export async function transitionHeight(el: HTMLElement, opts: TransitionOptions): Promise<void> {
|
||||
const {
|
||||
from = el.getBoundingClientRect().height,
|
||||
to = el.getBoundingClientRect().height,
|
||||
duration = 1000,
|
||||
easing = 'ease-in-out',
|
||||
} = opts;
|
||||
|
||||
if (from === to || duration === 0) {
|
||||
el.style.height = to + 'px';
|
||||
return;
|
||||
}
|
||||
|
||||
el.style.height = from + 'px';
|
||||
// Force a style calc so the browser picks up the start value.
|
||||
getComputedStyle(el).transform;
|
||||
el.style.transition = `height ${duration}ms ${easing}`;
|
||||
el.style.height = to + 'px';
|
||||
|
||||
return new Promise<void>((resolve) => {
|
||||
const listener = (event: Event) => {
|
||||
if (event.target !== el) return;
|
||||
el.style.transition = '';
|
||||
el.removeEventListener('transitionend', listener);
|
||||
el.removeEventListener('transitioncancel', listener);
|
||||
resolve();
|
||||
};
|
||||
|
||||
el.addEventListener('transitionend', listener);
|
||||
el.addEventListener('transitioncancel', listener);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user