Skip to content

"Reversing" a reveal animation #2

@gillesdm

Description

@gillesdm

I can't seem to figure out how to "reverse" an animation.
Currently, I am trying to use this to open and close a full-screen menu. Opening it works perfectly fine, but creating a second RevealFx with reversed properties breaks the whole thing. (I don't get any errors, but the menu would not open anymore).

I was wondering if there was a way to do the same animation, but in reverse.

main.js:

var mainMenu = document.querySelector("#main-menu");

  var menuOpenReveal = new RevealFx(mainMenu, {
    layers: 1,
    isContentHidden: true,
    revealSettings: {
      bgColors: ["#1B1C21"],
      duration: 600,
      delay: 0,
      easing: "easeInOutExpo",
      direction: "bt",
      onStart: function(contentEl, revealerEl) {
        contentEl.style.opacity = 0;
      },
      onHalfway: function(contentEl, revealerEl) {
        contentEl.style.opacity = 1;
      }
    }
  });

I run the menuOpenReveal.reveal() on click of a button in my header.

Thanks for the library by the way, really love how good and smooth it is! ❤️

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions