diff --git a/package.json b/package.json index 37566562..ed755582 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "impro", - "version": "0.18.34", + "version": "0.18.35", "type": "module", "scripts": { "start": "rm -rf \"${BUILD_DIR:-build}\" && NODE_ENV=development eleventy --serve", diff --git a/src/css/style.css b/src/css/style.css index 3201d625..fd157a09 100644 --- a/src/css/style.css +++ b/src/css/style.css @@ -1045,7 +1045,7 @@ tab-bar:not([full-width]) { .sidebar::backdrop { background: var(--overlay-color); opacity: 0; - transition: opacity 0.3s ease; + transition: opacity 0.3s cubic-bezier(0.32, 0.72, 0, 1); } .sidebar { @@ -1065,7 +1065,7 @@ tab-bar:not([full-width]) { border-right: var(--hair) solid var(--post-border-color); z-index: var(--sidebar-z-index); transform: translateX(-100%); - transition: transform 0.3s ease; + transition: transform 0.3s cubic-bezier(0.32, 0.72, 0, 1); overflow-y: auto; } @@ -1140,10 +1140,18 @@ tab-bar:not([full-width]) { .sidebar[open][data-closing] { pointer-events: none; transform: translateX(-100%); + transition: transform 0.2s cubic-bezier(0.32, 0.72, 0, 1); } .sidebar[open][data-closing]::backdrop { opacity: 0; + transition: opacity 0.2s cubic-bezier(0.32, 0.72, 0, 1); +} + +@media (prefers-reduced-motion: reduce) { + .sidebar { + transition: none; + } } .sidebar-profile { @@ -5981,11 +5989,9 @@ emoji-picker-dialog emoji-picker, @keyframes slide-up { from { transform: translateY(100%); - opacity: 0; } to { transform: translateY(0); - opacity: 1; } } @@ -6001,11 +6007,9 @@ emoji-picker-dialog emoji-picker, @keyframes slide-down { from { transform: translateY(0); - opacity: 1; } to { transform: translateY(100%); - opacity: 0; } } @@ -6024,7 +6028,7 @@ emoji-picker-dialog emoji-picker, top: auto; height: auto; box-shadow: var(--shadow-color-heavy); - animation: slide-up 0.15s ease-out; + animation: slide-up 0.3s cubic-bezier(0.32, 0.72, 0, 1); transform: none; margin: 0; overflow: hidden; @@ -6048,7 +6052,7 @@ emoji-picker-dialog emoji-picker, /* Only mobile bottom sheets animate out; on desktop they close instantly. */ @media (max-width: 799px) { .bottom-sheet[data-closing] { - animation: slide-down 0.15s ease-in forwards; + animation: slide-down 0.2s cubic-bezier(0.32, 0.72, 0, 1) forwards; } } @@ -6101,6 +6105,22 @@ emoji-picker-dialog emoji-picker, animation: fade-out 0.15s ease-in forwards; } +@media (max-width: 799px) { + .bottom-sheet::backdrop { + animation-duration: 0.3s; + } + + .bottom-sheet[data-closing]::backdrop { + animation-duration: 0.2s; + } +} + +@media (prefers-reduced-motion: reduce) { + .bottom-sheet { + animation: none; + } +} + @media (max-width: 799px) { .bottom-sheet-fullscreen { top: var(--sheet-top); diff --git a/src/js/dialogHelpers.js b/src/js/dialogHelpers.js index 01aa4b01..e337e86a 100644 --- a/src/js/dialogHelpers.js +++ b/src/js/dialogHelpers.js @@ -28,7 +28,7 @@ function waitForExitMotion(dialog) { const onMotionEnd = (event) => { if (event.target === dialog) finish(); }; - const timeoutId = setTimeout(finish, 500); + const timeoutId = setTimeout(finish, 400); dialog.addEventListener("animationend", onMotionEnd); dialog.addEventListener("transitionend", onMotionEnd); @@ -83,7 +83,8 @@ export function enableDragToDismiss( const DISMISS_THRESHOLD = 75; const RESISTANCE_FACTOR = 0.6; - const SNAP_BACK_MS = 150; + const SNAP_BACK_MS = 200; + const SNAP_BACK_EASING = "cubic-bezier(0.32, 0.72, 0, 1)"; let caretRestoreTimer = null; const dragState = { @@ -166,8 +167,8 @@ export function enableDragToDismiss( const deltaY = dragState.currentY - dragState.startY; target.style.transition = allowUpwardStretch - ? `transform ${SNAP_BACK_MS}ms ease-out, height ${SNAP_BACK_MS}ms ease-out` - : `transform ${SNAP_BACK_MS}ms ease-out`; + ? `transform ${SNAP_BACK_MS}ms ${SNAP_BACK_EASING}, height ${SNAP_BACK_MS}ms ${SNAP_BACK_EASING}` + : `transform ${SNAP_BACK_MS}ms ${SNAP_BACK_EASING}`; if (deltaY > DISMISS_THRESHOLD && (await confirmDismiss())) { target.style.transform = "translateY(100%)"; diff --git a/tests/unit/specs/dialogHelpers.test.js b/tests/unit/specs/dialogHelpers.test.js index 0cad17f8..e2aef0bb 100644 --- a/tests/unit/specs/dialogHelpers.test.js +++ b/tests/unit/specs/dialogHelpers.test.js @@ -229,7 +229,7 @@ describe("enableDragToDismiss", () => { dragState = enableDragToDismiss(el, { onClose: () => closeCount++ }); await drag(50); assert.deepEqual(el.style.caretColor, "transparent"); - await wait(200); + await wait(300); assert.deepEqual(el.style.caretColor, ""); });