first commit
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
import React, { useEffect, useState } from 'react';
|
||||
import CountUp from 'react-countup';
|
||||
|
||||
function CounterUpCom({ endValue = 0, sectionSelect }) {
|
||||
const [showCount, setShowCountValue] = useState(false);
|
||||
useEffect(() => {
|
||||
const rec = document.getElementById(sectionSelect);
|
||||
if (rec) {
|
||||
const currentPosition = rec.offsetTop - document.body.scrollTop;
|
||||
window.addEventListener('scroll', () => {
|
||||
const currentScrollPosition =
|
||||
window.pageYOffset || document.documentElement.scrollTop;
|
||||
if (currentScrollPosition + 500 > currentPosition) {
|
||||
setShowCountValue(true);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, [sectionSelect, showCount]);
|
||||
return <>{showCount ? <CountUp delay={0} duration={3} end={endValue} /> : 0}</>;
|
||||
}
|
||||
|
||||
export default CounterUpCom;
|
||||
@@ -0,0 +1,12 @@
|
||||
export default function StickyMenu(selector = '.appie-sticky') {
|
||||
document.addEventListener('scroll', () => {
|
||||
const element = document.querySelector(selector);
|
||||
if (element) {
|
||||
if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
|
||||
element.classList.add('sticky');
|
||||
} else {
|
||||
element.classList.remove('sticky');
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
export default function TopToBottom(value) {
|
||||
const result = document.querySelector(value);
|
||||
if (result) {
|
||||
document.addEventListener('scroll', () => {
|
||||
if (
|
||||
document.body.scrollTop > window.innerHeight ||
|
||||
document.documentElement.scrollTop > window.innerHeight
|
||||
) {
|
||||
result.style.display = 'block';
|
||||
} else {
|
||||
result.style.display = 'none';
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user