I've been looking further into using maquette.js as a virtual DOM library.
Looking at the website the library has functionality to support animations when adding, removing, and updating DOM nodes.
But I cannot find any docs or API on what to do do achieve this.
To make it more concrete I have made a small sample below and here.
var isPopupShown = false;
var togglePopup = function(){
isPopupShown = !isPopupShown;
}
var renderMaquette = function () {
return h("div#container", [
h("button", {
onclick: togglePopup
}, ["Click me"]),
isPopupShown ? h("div#popup") : null
]);
}
In the example, clicking the button will open the popup.
What I would like is that the popup would animate a fade-in when the node is added to the DOM and a fade-out when the node is removed from the DOM.
The documentation how animations work is still in progress.
There are currently two ways to do the animation.
Velocity.js
The easiest way is to use a library like velocity.js. For this to work you need to:
h("div#popup")
toh("div#popup", {enterAnimation: fadeIn})
Code:
You can view the result here.
CSS Transitions
You can also use CSS transitions. They work the same as angularJS and react. You need to do the following:
css-transitions.min.js
script in your page. This script is also provided by maquette.h("div#popup")
toh("div#popup", {enterAnimation: "fadeIn"})
maquette.createProjector(document.body, renderMaquette, {transitions: cssTransitions});
Stylesheet:
You can view the result here