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

AnimateCSS #3113

Merged
merged 26 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 22 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
f93ca79
begin coding with animateCSS
May 27, 2023
5d554ea
testing code for AnimateCSS
May 28, 2023
0c6525a
test AnimateCSS with compliments and newsfeed default modules
May 28, 2023
7a50605
decrease default animation time for testing
May 28, 2023
bfcd079
missing AnimateCSS credit
May 28, 2023
7fc20b2
update ChangeLog
May 28, 2023
aabc2d5
delete some warnings...
May 28, 2023
ab2a28b
typo
May 28, 2023
064cb01
correct all errors / warn
May 28, 2023
80deac1
testing code purpose
May 28, 2023
7ca8d70
testing with new code
bugsounet Jun 10, 2023
d0b083c
in accord with test:e2e
bugsounet Jun 10, 2023
3a7c905
testing with new code
bugsounet Jun 10, 2023
e28d638
Merge branch 'develop' into develop
bugsounet Jun 10, 2023
a6a8ce8
add possibity to use animateIn and animateOut in module definition co…
bugsounet Jun 11, 2023
cc3c580
add possibity to use animateIn and animateOut in module definition co…
bugsounet Jun 11, 2023
15bf134
update change log // update fonctions definitions
bugsounet Jun 11, 2023
c0d1215
update change log // update fonctions definitions
bugsounet Jun 11, 2023
f5e2a8d
Apply AnimateIn rules on the first start
bugsounet Jun 11, 2023
e53cf30
Apply AnimateIn rules on the first start
bugsounet Jun 11, 2023
c3e2719
review animateCSS rules
bugsounet Sep 2, 2023
fde5168
Merge branch 'develop' into develop
bugsounet Sep 2, 2023
2f6ed13
some correct needed (see logs) and add updateDom object option
bugsounet Sep 6, 2023
a405b26
missing new definition
bugsounet Sep 6, 2023
ffa2f5d
correct var -> let
bugsounet Sep 6, 2023
2d5effc
Merge branch 'develop' into animate
rejas Sep 7, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ Special thanks to @khassel, @rejas and @sdetweil for taking over most (if not al
- updatenotification: Added `sendUpdatesNotifications` feature. Broadcast update with `UPDATES` notification to other modules
- updatenotification: allow force scanning with `SCAN_UPDATES` notification from other modules
- Added per-calendar fetchInterval
- Added optional AnimateCSS animate for `hide()`, `show()`, `updateDom()`
- Added AnimateIn and animateOut in module config definition
- Apply AnimateIn rules on the first start

### Removed

Expand Down
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
<link rel="icon" href="data:;base64,iVBORw0KGgo=" />
<link rel="stylesheet" type="text/css" href="css/main.css" />
<link rel="stylesheet" type="text/css" href="fonts/roboto.css" />
<link rel="stylesheet" type="text/css" href="vendor/node_modules/animate.css/animate.min.css" />
<!-- custom.css is loaded by the loader.js to make sure it's loaded after the module css files. -->

<script type="text/javascript">
Expand Down Expand Up @@ -52,6 +53,7 @@
<script type="text/javascript" src="js/module.js"></script>
<script type="text/javascript" src="js/loader.js"></script>
<script type="text/javascript" src="js/socketclient.js"></script>
<script type="text/javascript" src="js/animateCSS.js"></script>
<script type="text/javascript" src="js/main.js"></script>
</body>
</html>
165 changes: 165 additions & 0 deletions js/animateCSS.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
/* MagicMirror²
* AnimateCSS System from https://animate.style/
* by @bugsounet
* for Michael Teeuw https://michaelteeuw.nl
* MIT Licensed.
*/

/* enumeration of animations in Array **/
const _AnimateCSSIn = [
bugsounet marked this conversation as resolved.
Show resolved Hide resolved
// Attention seekers
"bounce",
"flash",
"pulse",
"rubberBand",
"shakeX",
"shakeY",
"headShake",
"swing",
"tada",
"wobble",
"jello",
"heartBeat",
// Back entrances
"backInDown",
"backInLeft",
"backInRight",
"backInUp",
// Bouncing entrances
"bounceIn",
"bounceInDown",
"bounceInLeft",
"bounceInRight",
"bounceInUp",
// Fading entrances
"fadeIn",
"fadeInDown",
"fadeInDownBig",
"fadeInLeft",
"fadeInLeftBig",
"fadeInRight",
"fadeInRightBig",
"fadeInUp",
"fadeInUpBig",
"fadeInTopLeft",
"fadeInTopRight",
"fadeInBottomLeft",
"fadeInBottomRight",
// Flippers
"flip",
"flipInX",
"flipInY",
// Lightspeed
"lightSpeedInRight",
"lightSpeedInLeft",
// Rotating entrances
"rotateIn",
"rotateInDownLeft",
"rotateInDownRight",
"rotateInUpLeft",
"rotateInUpRight",
// Specials
"jackInTheBox",
"rollIn",
// Zooming entrances
"zoomIn",
"zoomInDown",
"zoomInLeft",
"zoomInRight",
"zoomInUp",
// Sliding entrances
"slideInDown",
"slideInLeft",
"slideInRight",
"slideInUp"
];

const _AnimateCSSOut = [
bugsounet marked this conversation as resolved.
Show resolved Hide resolved
// Back exits
"backOutDown",
"backOutLeft",
"backOutRight",
"backOutUp",
// Bouncing exits
"bounceOut",
"bounceOutDown",
"bounceOutLeft",
"bounceOutRight",
"bounceOutUp",
// Fading exits
"fadeOut",
"fadeOutDown",
"fadeOutDownBig",
"fadeOutLeft",
"fadeOutLeftBig",
"fadeOutRight",
"fadeOutRightBig",
"fadeOutUp",
"fadeOutUpBig",
"fadeOutTopLeft",
"fadeOutTopRight",
"fadeOutBottomRight",
"fadeOutBottomLeft",
// Flippers
"flipOutX",
"flipOutY",
// Lightspeed
"lightSpeedOutRight",
"lightSpeedOutLeft",
// Rotating exits
"rotateOut",
"rotateOutDownLeft",
"rotateOutDownRight",
"rotateOutUpLeft",
"rotateOutUpRight",
// Specials
"hinge",
"rollOut",
// Zooming exits
"zoomOut",
"zoomOutDown",
"zoomOutLeft",
"zoomOutRight",
"zoomOutUp",
// Sliding exits
"slideOutDown",
"slideOutLeft",
"slideOutRight",
"slideOutUp"
];

/**
* Create an animation with Animate CSS
* resolved as Promise when done
* @param {string} [element] div element to animate.
* @param {string} [animation] animation name.
* @param {number} [animationTime] animation duration.
*/
function AnimateCSS(element, animation, animationTime) {
/* We create a Promise and return it */
return new Promise((resolve) => {
const animationName = `animate__${animation}`;
const node = document.getElementById(element);
if (!node) {
// don't execute animate and resolve
Log.warn(`AnimateCSS: node not found for`, element);
resolve();
return;
}
node.style.setProperty("--animate-duration", `${animationTime}s`);
node.classList.add("animate__animated", animationName);

/**
* When the animation ends, we clean the classes and resolve the Promise
* @param {object} event object
*/
function handleAnimationEnd(event) {
node.classList.remove("animate__animated", animationName);
node.style.removeProperty("--animate-duration", `${animationTime}s`);
event.stopPropagation();
resolve();
}

node.addEventListener("animationend", handleAnimationEnd, { once: true });
});
}
2 changes: 2 additions & 0 deletions js/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ const Loader = (function () {
path: `${moduleFolder}/`,
file: `${moduleName}.js`,
position: moduleData.position,
animateIn: moduleData.animateIn,
animateOut: moduleData.animateOut,
hiddenOnStartup: moduleData.hiddenOnStartup,
header: moduleData.header,
configDeepMerge: typeof moduleData.configDeepMerge === "boolean" ? moduleData.configDeepMerge : false,
Expand Down
Loading