Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove Safari theme animation for now #119

Merged
merged 3 commits into from
Sep 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions src/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ interface DrawerContextValue {
dismissible: boolean;
isOpen: boolean;
keyboardIsOpen: React.MutableRefObject<boolean>;
experimentalSafariThemeAnimation?: boolean;
snapPointsOffset: number[] | null;
snapPoints?: (number | string)[] | null;
modal: boolean;
Expand All @@ -38,7 +37,6 @@ export const DrawerContext = React.createContext<DrawerContextValue>({
dismissible: false,
isOpen: false,
keyboardIsOpen: { current: false },
experimentalSafariThemeAnimation: false,
snapPointsOffset: null,
snapPoints: null,
modal: false,
Expand Down
21 changes: 2 additions & 19 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { DrawerContext, useDrawerContext } from './context';
import './style.css';
import { usePreventScroll, isInput, isIOS } from './use-prevent-scroll';
import { useComposedRefs } from './use-composed-refs';
import { useSafariThemeColor } from './use-safari-theme-color';
import { usePositionFixed } from './use-position-fixed';
import { useSnapPoints } from './use-snap-points';
import { set, reset, getTranslateY, dampenValue } from './helpers';
Expand Down Expand Up @@ -45,7 +44,6 @@ type DialogProps = {
dismissible?: boolean;
onDrag?: (event: React.PointerEvent<HTMLDivElement>, percentageDragged: number) => void;
onRelease?: (event: React.PointerEvent<HTMLDivElement>, open: boolean) => void;
experimentalSafariThemeAnimation?: boolean;
modal?: boolean;
nested?: boolean;
onClose?: () => void;
Expand All @@ -58,7 +56,6 @@ function Root({
shouldScaleBackground,
onDrag: onDragProp,
onRelease: onReleaseProp,
experimentalSafariThemeAnimation,
snapPoints,
nested,
closeThreshold = CLOSE_THRESHOLD,
Expand Down Expand Up @@ -89,12 +86,6 @@ function Root({
const previousDiffFromInitial = React.useRef(0);
const drawerRef = React.useRef<HTMLDivElement>(null);
const drawerHeightRef = React.useRef(drawerRef.current?.getBoundingClientRect().height || 0);
const { onDrag: changeThemeColorOnDrag, onRelease: themeTransitionOnRelease } = useSafariThemeColor(
drawerRef,
overlayRef,
isOpen,
experimentalSafariThemeAnimation,
);

const onSnapPointChange = useCallback((activeSnapPointIndex: number) => {
// Change openTime ref when we reach the last snap point to prevent dragging for 500ms incase it's scrollable.
Expand Down Expand Up @@ -258,7 +249,6 @@ function Root({
const opacityValue = 1 - percentageDragged;

if (shouldFade || (fadeFromIndex && activeSnapPointIndex === fadeFromIndex - 1)) {
changeThemeColorOnDrag(percentageDragged);
onDragProp?.(event, percentageDragged);

set(
Expand Down Expand Up @@ -379,8 +369,8 @@ function Root({
}

setTimeout(() => {
setIsOpen(false);
setVisible(false);
setIsOpen(false);
}, 300);

setTimeout(() => {
Expand Down Expand Up @@ -498,14 +488,12 @@ function Root({
if (distMoved > 0) {
resetDrawer();
onReleaseProp?.(event, true);
themeTransitionOnRelease(true);
return;
}

if (velocity > VELOCITY_THRESHOLD) {
closeDrawer();
onReleaseProp?.(event, false);
themeTransitionOnRelease(false);
return;
}

Expand All @@ -514,12 +502,10 @@ function Root({
if (swipeAmount >= visibleDrawerHeight * closeThreshold) {
closeDrawer();
onReleaseProp?.(event, false);
themeTransitionOnRelease(false);
return;
}

onReleaseProp?.(event, true);
themeTransitionOnRelease(true);
resetDrawer();
}

Expand Down Expand Up @@ -649,7 +635,6 @@ function Root({
keyboardIsOpen,
modal,
snapPointsOffset,
experimentalSafariThemeAnimation,
}}
>
{children}
Expand All @@ -660,8 +645,7 @@ function Root({

const Overlay = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<typeof DialogPrimitive.Overlay>>(
function ({ children, style, ...rest }, ref) {
const { overlayRef, snapPoints, onRelease, experimentalSafariThemeAnimation, shouldFade, isOpen, visible } =
useDrawerContext();
const { overlayRef, snapPoints, onRelease, shouldFade, isOpen, visible } = useDrawerContext();
const composedRef = useComposedRefs(ref, overlayRef);
const hasSnapPoints = snapPoints && snapPoints.length > 0;

Expand All @@ -673,7 +657,6 @@ const Overlay = React.forwardRef<HTMLDivElement, React.ComponentPropsWithoutRef<
vaul-overlay=""
vaul-snap-points={isOpen && hasSnapPoints ? 'true' : 'false'}
vaul-snap-points-overlay={isOpen && shouldFade ? 'true' : 'false'}
vaul-theme-transition={experimentalSafariThemeAnimation ? 'true' : 'false'}
{...rest}
/>
);
Expand Down
18 changes: 0 additions & 18 deletions src/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,6 @@
}
}

@keyframes show-theme-overlay {
from {
background: var(--vaul-overlay-background-start);
}
to {
background: var(--vaul-overlay-background-end);
}
}

@keyframes hide-theme-overlay {
from {
background: var(--vaul-overlay-background-end);
}
to {
background: var(--vaul-overlay-background-start);
}
}

@media (hover: hover) and (pointer: fine) {
[vaul-drawer] {
user-select: none;
Expand Down
207 changes: 0 additions & 207 deletions src/use-safari-theme-color.ts

This file was deleted.