HEX
Server: Microsoft-IIS/8.5
System: Windows NT YDAWBH120 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) AMD64
User: tentjecom_web (0)
PHP: 7.4.14
Disabled: NONE
Upload Files
File: D:/HostingSpaces/SBogers10/sportivo.komma.pro/wwwroot/js/animations.js
/**
 * Created by Pascal on 17/11/15.
 */

/**
 * Created by Pascal on 29/10/15.
 */
$(function () {

    if (!isElementInViewport($('.sidebar .social'))) {
        $('.sidebar .social').remove();
    }

    $('.header-button').click(function () {

        $('html,body').animate({
            scrollTop: $('.content-block1').offset().top - 60
        }, 800)

    });

    $(window).resize(function(){
        if (!isElementInViewport($('.sidebar .social'))) {
            $('.sidebar .social').remove();
        }
    });

    $(window).scroll(function () {

        //List Items animation in home page
        elementInViewportOnce($('#home-item1'));
        elementInViewportOnce($('#home-item2'));
        elementInViewportOnce($('#home-item3'));
        elementInViewportOnce($('#home-item4'));
        elementInViewportOnce($('#home-item5'));

        //Circle animations in the Sportdoelen page
        elementInViewport($(".button-container#healthy"));
        elementInViewport($(".button-container#condition"));
        elementInViewport($(".button-container#weight"));
        elementInViewport($(".button-container#stronger"));


        //Animation for the focus on search box
        $('.search-bar input').focus(function () {
            $(this).parent().addClass('active');
        });
        $('.search-bar input').focusout(function () {
            $(this).parent().removeClass('active');
        });

    });


    function elementInViewport(el) {
        if ($(el).length) {  //If exists in the view
            if (isElementInViewport(el)) {
                el.addClass('active');
            }
            else {
                el.removeClass('active');
            }
        }
    }

    function elementInViewportOnce(el) {
        if ($(el).length) {   //If exists in the view
            if (isElementInViewport(el)) {
                el.addClass('active');
            }
        }
    }

    function isElementInViewport(el) {
        if ($(el).length) {
            if (typeof jQuery === "function" && el instanceof jQuery) {
                el = el[0];
            }

            var rect = el.getBoundingClientRect();

            return (
                rect.top >= 0 &&
                rect.bottom <= (window.innerHeight || $(window).height())
            );
        }
    }

});