Sh3ll
OdayForums


Server : LiteSpeed
System : Linux premium84.web-hosting.com 4.18.0-553.44.1.lve.el8.x86_64 #1 SMP Thu Mar 13 14:29:12 UTC 2025 x86_64
User : claqxcrl ( 523)
PHP Version : 8.1.32
Disable Function : NONE
Directory :  /home/claqxcrl/claquemagazineawards.com/wp-content/themes/lalita/js/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/claqxcrl/claquemagazineawards.com/wp-content/themes/lalita/js/back-to-top.js
( function() {
	'use strict';

    // Feature Test
	if ( 'querySelector' in document && 'addEventListener' in window ) {

		var goTopBtn = document.querySelector( '.lalita-back-to-top' );

		var trackScroll = function() {
			var scrolled = window.pageYOffset;
			var coords = goTopBtn.getAttribute( 'data-start-scroll' ) ;

			if ( scrolled > coords ) {
				goTopBtn.style.opacity = '1';
				goTopBtn.style.visibility = 'visible';
			}

			if (scrolled < coords) {
				goTopBtn.style.opacity = '0';
				goTopBtn.style.visibility = 'hidden';
			}
		};

		// Function to animate the scroll
		var smoothScroll = function (anchor, duration) {
			// Calculate how far and how fast to scroll
			var startLocation = window.pageYOffset;
			var endLocation = document.body.offsetTop;
			var distance = endLocation - startLocation;
			var increments = distance/(duration/16);
			var stopAnimation;

			// Scroll the page by an increment, and check if it's time to stop
			var animateScroll = function () {
				window.scrollBy(0, increments);
				stopAnimation();
			};

			// Stop animation when you reach the anchor OR the top of the page
			stopAnimation = function () {
				var travelled = window.pageYOffset;
				if ( travelled <= (endLocation || 0) ) {
					clearInterval(runAnimation);
				}
			};

			// Loop the animation function
			var runAnimation = setInterval(animateScroll, 16);
		};

		if ( goTopBtn ) {
			// Show the button when scrolling down.
			window.addEventListener( 'scroll', trackScroll );

			// Scroll back to top when clicked.
			goTopBtn.addEventListener( 'click', function( e ) {
				e.preventDefault();
				smoothScroll( document.body, goTopBtn.getAttribute( 'data-scroll-speed' ) || 400 );
			}, false );
		}

	}

 } )();

ZeroDay Forums Mini