+/**
+ * Used in the function below to store references of clean-up functions.
+ * Used to ensure only one transitionend function exists at any time.
+ * @type {WeakMap<object, any>}
+ */
+const animateStylesCleanupMap = new WeakMap();
+
+/**
+ * Fade in the given element.
+ * @param {Element} element
+ * @param {Number} animTime
+ * @param {Function|null} onComplete
+ */
+export function fadeIn(element, animTime = 400, onComplete = null) {
+ cleanupExistingElementAnimation(element);
+ element.style.display = 'block';
+ animateStyles(element, {
+ opacity: ['0', '1']
+ }, animTime, () => {
+ if (onComplete) onComplete();
+ });
+}
+