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

Create useFlip hook #183 #215

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

Conversation

leroykorterink
Copy link
Collaborator

No description provided.

@leroykorterink leroykorterink added enhancement New feature or request good first issue Good for newcomers labels Oct 20, 2023
@leroykorterink leroykorterink requested a review from a team October 20, 2023 14:24
@leroykorterink leroykorterink self-assigned this Oct 20, 2023
const [isFlipped, toggle] = useToggle(false);

const divRef = useRef<HTMLDivElement>(null);
useFlip(divRef, flipOptions);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

flipOptions is not defined anywhere

const flipStateRef = useRef<Flip.FlipState>();

// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
if (globalThis.window !== undefined) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful (for others, or future self), to add some comments explaining how/why this works.

I assume that:

  • the if executes before potentially new style vars are set, capturing the "current" state.
  • the useEffect executes after applying and rendering the new style vars, and then transitioning to them from the previously captured state.


<Meta title="components/useFlip" of={stories} />

# useFlip
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unclear from the (non-existing) api docs:

  • what I can pass as first parameter (can it be both an element, or also a ref around an element?)
  • what I can pass as second parameter (some gsap flip props?)
  • If the second param is optional or required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants