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/SBogers104/angeliekly.nl/wwwroot/js/main.js
/**
 * Created by Pascal on 30/09/15.
 */
$(function () {
    initMain();
});

function initMain() {
    resizer();

    setTimeout(function () {
        animations();
    }, 800);

    if (typeof $.throttle === "undefined") rebindThrottleDebounce();

    lastScrollTop = 0;

    $(window).resize(
        $.throttle(250, resizer)
    );

    $(window).scroll(
        $.throttle(250, scroller)
    );

    //get internal link and animate them examp: <a href='#top'>Home</a>
    $('a.internalLink').click(function () {
        animateScroll($(this));
        return false;
    });

    $('.footerForm .submit').click(function () {
        //if($('footer #footerForm input[name="email"]').val()!='') $('footer #footerForm').submit();
        $(this).closest('form').submit();
        //$('footer .footerForm').submit();
    });

}

function resizer() {

    //Detection for home blocks overview
    var overSide = ($('body').width() - $('.full-image-block .content-container').width()) / 2;
    $('.full-image-block .image').width($('.full-image-block .content-container').width() / 12 * 7 + overSide);
    if (overSide < 120) $('.scroll-button').width(overSide).height(overSide).css('right', '-' + overSide + 'px');
    if (overSide >= 120) $('.scroll-button').width(120).height(120).css('right', '-120px');
    $('.full-image-block .latest-post').height($('.full-image-block .latest-post').width() / 2);
    $('.full-image-block#home .right-content .text').height($(window).height() - $('.full-image-block .latest-post').height() - $('.full-image-block .right-content .logo.white').height());

}

function scroller() {
    if (!isElementPartInViewport($('header'))) {
        $('.sticky-header').addClass('show');
    }
    else {
        $('.sticky-header').removeClass('show');
    }
    animations();

    if ($(document).scrollTop() >= 135 && $('.mobile-navigation .bar .logo').hasClass('home')) $('.mobile-navigation .bar .logo').addClass('show');
    if ($(document).scrollTop() < 135 && $('.mobile-navigation .bar .logo.home').hasClass('show')) $('.mobile-navigation .bar .logo').removeClass('show');

}

function animations() {
    $('.animation').each(function () {
        if (isElementFullInViewport($(this))) $(this).removeClass('animation');
    });
    $('.animation-part').each(function () {
        if (isElementPartExtraInViewport($(this), 60)) $(this).removeClass('animation-part');
    });
}

function isElementFullInViewport(el) {
    //special bonus for those using jQuery
    if (el.length > 0) {
        if (typeof jQuery === "function" && el instanceof jQuery) {
            el = el[0];
        }

        var rect = el.getBoundingClientRect();

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

function isElementPartInViewport(el) {
    if (el.length > 0) {
        //special bonus for those using jQuery
        if (typeof jQuery !== 'undefined' && el instanceof jQuery) el = el[0];

        var rect = el.getBoundingClientRect();
        // DOMRect { x: 8, y: 8, width: 100, height: 100, top: 8, right: 108, bottom: 108, left: 8 }
        var windowHeight = (window.innerHeight || document.documentElement.clientHeight);
        var windowWidth = (window.innerWidth || document.documentElement.clientWidth);

        var vertInView = (rect.top <= windowHeight) && ((rect.top + rect.height) >= 0);
        var horInView = (rect.left <= windowWidth) && ((rect.left + rect.width) >= 0);

        return (vertInView && horInView);
    }
}

function isElementPartExtraInViewport(el, margin) {
    if (el.length > 0) {
        //special bonus for those using jQuery
        if (typeof jQuery !== 'undefined' && el instanceof jQuery) el = el[0];

        var rect = el.getBoundingClientRect();
        // DOMRect { x: 8, y: 8, width: 100, height: 100, top: 8, right: 108, bottom: 108, left: 8 }
        var windowHeight = (window.innerHeight || document.documentElement.clientHeight);
        var windowWidth = (window.innerWidth || document.documentElement.clientWidth);

        var vertInView = (rect.top <= (windowHeight - margin)) && ((rect.top + rect.height) >= 0);
        var horInView = (rect.left <= windowWidth) && ((rect.left + rect.width) >= 0);

        return (vertInView && horInView);
    }
}


function animateScroll(e, offset, time) {
    offset = typeof offset !== 'undefined' ? offset : 60;
    time = typeof time !== 'undefined' ? time : 800;

    var scrollTo = e.prop('href');
    scrollTo = scrollTo.substr(scrollTo.indexOf('#') + 1);

    var body = $('html,body');

    body.animate({
        scrollTop: $('#' + scrollTo).offset().top - offset
    }, time);

    body.on("scroll mousedown wheel DOMMouseScroll mousewheel keyup touchmove", function () {
        body.stop();
    });
}