motiondivision / motiondivision/motion

[BUG]display: 'none' can not be set

Open
#2,563 8 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

bug
Dominant language
TypeScript
Stars
33.7k
Forks
1.4k
Avg merge
1d 10h
Merged PRs (30d)
14

Description

when use 'useAnimate', the 'display:none' can not be set ,but other e.g.'display:inline' is ok.

package version "framer-motion": "^11.0.14"

import React, { useState, useEffect } from "react"
import { useAnimate } from "framer-motion"
...
const FlowPanel = () => {
  const [showMenu, setShowMenu] = useState(false)
  const [scope, animate] = useAnimate()
  
  useEffect(() => {
          const menus = document.getElementsByClassName("flow-panel-menu")
          if (menus.length <= 0) {
              return
          }
  
          const enterAnimation = () => {
              const current = menus[0]
              if (showMenu) {
                  animate(current, { opacity: 1, display: 'inline' }, { duration: 0.7 })
              } else {
                  animate(current, { opacity: 0, display: 'none' }, { duration: 0.7 })
              }
          }
  
          enterAnimation()
      }, [showMenu])

 return (
<div className="flow-panel-menu" ref={scope} >
                    ...
</div>
    )
}

when i set showMenu state to 'false', the 'opacity: 0' will be set correctly, but 'display' will still 'inline'.
if i write the else code like animate(current, { opacity: 0, display: 'contents' }, { duration: 0.7 }), the 'display' will set 'contents'.
i means only display: 'none' cannot be set correctly.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the provided useAnimate reproduction and inspect how display values are applied during animation, comparing 'none' with 'inline' and 'contents'. Confirm the behavior with the supplied React example and ensure that setting display to 'none' takes effect after the opacity animation.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.