Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function add_ov_preloader_script() {
- if (isset($_GET['et_fb'])) {
- return;
- }
- ?>
- <script>
- document.addEventListener('DOMContentLoaded', () => {
- const preloader = document.querySelector('.ov-preloader');
- const preloaderBg = document.querySelector('.ov-preloader-background');
- const progressElement = document.querySelector('.ov-loading-progress');
- function animateCounter() {
- const duration = 1000;
- const start = performance.now();
- function update(currentTime) {
- const elapsed = currentTime - start;
- const progress = Math.min(elapsed / duration, 1);
- const easeProgress = 1 - Math.pow(1 - progress, 3);
- const currentValue = Math.floor(easeProgress * 100);
- if (progressElement) {
- progressElement.textContent = `${currentValue}%`;
- }
- if (progress < 1) {
- requestAnimationFrame(update);
- } else {
- startReveal();
- }
- }
- requestAnimationFrame(update);
- }
- function startReveal() {
- if (preloader) {
- preloader.classList.add('ov-loaded');
- }
- setTimeout(() => {
- if (preloaderBg) {
- preloaderBg.classList.add('fade-out');
- }
- }, 1000);
- setTimeout(() => {
- if (preloader) {
- preloader.style.display = 'none';
- }
- if (preloaderBg) {
- preloaderBg.style.display = 'none';
- }
- }, 2000);
- }
- window.addEventListener('load', () => {
- animateCounter();
- });
- });
- </script>
- <?php
- }
- add_action('wp_footer', 'add_ov_preloader_script', 99);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement