@teleporthq/react-components
Advanced tools
Comparing version 1.0.8 to 1.0.9
@@ -5,2 +5,3 @@ (function(global, factory) { | ||
"use strict"; | ||
const style = ""; | ||
const DEV_COMPONENT_TAG_NAME = "animate-on-reveal"; | ||
@@ -49,4 +50,4 @@ const _AnimateOnElementReveal = class _AnimateOnElementReveal2 extends HTMLElement { | ||
findObservableNodeFromTree(node) { | ||
const style = window.getComputedStyle(node); | ||
if (style.getPropertyValue("display") !== "contents") { | ||
const style2 = window.getComputedStyle(node); | ||
if (style2.getPropertyValue("display") !== "contents") { | ||
return node; | ||
@@ -53,0 +54,0 @@ } |
import dayjs from 'dayjs'; | ||
import React, { useRef, useEffect, useState } from 'react'; | ||
const style = ''; | ||
const DateTimePrimitive = ({ date, format }) => { | ||
@@ -127,100 +125,2 @@ const dateTime = dayjs.unix(new Date(date).getTime() / 1e3); | ||
const DEV_COMPONENT_TAG_NAME = "animate-on-reveal"; | ||
const _AnimateOnElementReveal = class _AnimateOnElementReveal extends HTMLElement { | ||
constructor() { | ||
super(); | ||
if (!this.firstElementChild) { | ||
return; | ||
} | ||
this.nodeToObserve = this.findObservableNodeFromTree( | ||
this.firstElementChild | ||
); | ||
this.intersectionObserver = new IntersectionObserver( | ||
(entries) => { | ||
entries.forEach((entry) => { | ||
if (entry.isIntersecting) { | ||
this.setAttribute("revealed", ""); | ||
} else { | ||
this.removeAttribute("revealed"); | ||
} | ||
}); | ||
}, | ||
{ threshold: 0.5 } | ||
); | ||
this.style.display = "contents"; | ||
} | ||
static registerSelf() { | ||
if (!window.customElements.get(DEV_COMPONENT_TAG_NAME)) { | ||
window.customElements.define( | ||
DEV_COMPONENT_TAG_NAME, | ||
_AnimateOnElementReveal | ||
); | ||
} | ||
} | ||
connectedCallback() { | ||
if (!this.nodeToObserve) { | ||
return; | ||
} | ||
this.nodeToObserve.style.animationPlayState = "paused"; | ||
this.intersectionObserver.observe(this.nodeToObserve); | ||
} | ||
disconnectedCallback() { | ||
this.intersectionObserver.disconnect(); | ||
} | ||
findObservableNodeFromTree(node) { | ||
const style = window.getComputedStyle(node); | ||
if (style.getPropertyValue("display") !== "contents") { | ||
return node; | ||
} | ||
const children = node.children; | ||
for (let i = 0; i < children.length; i++) { | ||
const descendant = this.findObservableNodeFromTree(children[i]); | ||
if (descendant) { | ||
return descendant; | ||
} | ||
} | ||
return null; | ||
} | ||
attributeChangedCallback(name) { | ||
switch (name) { | ||
case "animation": | ||
this.nodeToObserve.style.animationName = this.getAttribute("animation") || ""; | ||
break; | ||
case "duration": | ||
this.nodeToObserve.style.animationDuration = this.getAttribute(name) || "0s"; | ||
break; | ||
case "delay": | ||
this.nodeToObserve.style.animationDelay = this.getAttribute(name) || "0s"; | ||
break; | ||
case "easing": | ||
this.nodeToObserve.style.animationTimingFunction = this.getAttribute(name) || "ease"; | ||
break; | ||
case "iteration": | ||
this.nodeToObserve.style.animationIterationCount = this.getAttribute(name) || "1"; | ||
break; | ||
case "direction": | ||
this.nodeToObserve.style.animationDirection = this.getAttribute(name) || "normal"; | ||
break; | ||
case "revealed": | ||
this.nodeToObserve.style.animationPlayState = this.hasAttribute( | ||
"revealed" | ||
) ? "running" : "paused"; | ||
break; | ||
} | ||
} | ||
}; | ||
_AnimateOnElementReveal.observedAttributes = [ | ||
"animation", | ||
"duration", | ||
"delay", | ||
"direction", | ||
"easing", | ||
"revealed", | ||
"class", | ||
"classname", | ||
"iteration" | ||
]; | ||
let AnimateOnElementReveal = _AnimateOnElementReveal; | ||
AnimateOnElementReveal.registerSelf(); | ||
export { AnimateOnElementReveal, CMSMixedType, CaisyDocumentLink, DangerousHTML, DataProvider, DateTimePrimitive, Repeater }; | ||
export { CMSMixedType, CaisyDocumentLink, DangerousHTML, DataProvider, DateTimePrimitive, Repeater }; |
{ | ||
"name": "@teleporthq/react-components", | ||
"version": "1.0.8", | ||
"version": "1.0.9", | ||
"description": "", | ||
@@ -12,3 +12,6 @@ "main": "dist/react-components.js", | ||
}, | ||
"./animate-on-reveal": "./dist/animate-on-reveal.umd.js", | ||
"./animate-on-reveal": { | ||
"import": "./dist/animate-on-reveal.es.js", | ||
"umd": "./dist/animate-on-reveal.umd.js" | ||
}, | ||
"./style": "./style.css" | ||
@@ -15,0 +18,0 @@ }, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
21
37374
1078