PricingBlog

popover api closing animation not working

  • alfred_66594-1492177275872088294

    Alfred

    5 hours ago

    I am working with the native Popover API to create a side panel that animates in and out. The trigger button has popovertargetaction="toggle", and the attached image shows the styling of my popover element. I cannot get the exit transition to work properly, even though I have set the @starting-style for the entry animation and explicitly set allow-discrete in my transitions. Has anyone with experience using the Popover API run into this and can help me locate the conflict? I have also set data-unset-toddle-style on the popover element to prevent the reset stylesheet from overriding the popover's display mechanism.
    1492177276069216346-image.png
  • bsr.24-1492202865698275489

    Bobby Randhawa

    3 hours ago

    Looking at your screenshot, you're not currently setup to transition opacity. It's set in both your default ('opacity: 0') and :popover-open ('opacity: 1') states, but it's missing from your transition property, which only lists translate, display, and overlay.

    That means opacity snaps instantly whenever :popover-open is added or removed. On exit, opacity drops to 0 on the same frame the popover starts closing, which hides the element before the 800ms translate can play out. The slide-out is still running, it's just invisible.

    Add opacity to your transition list:
    transition:
    translate 800ms ease-out,
    opacity 800ms ease-out,
    display 800ms allow-discrete,
    overlay 800ms allow-discrete;

    allow-discrete is only meaningful on display and overlay since those are the discrete properties. It's a no-op on translate and opacity, so you can drop it from those entries.