$(window).scroll(function () {
    $('.imgAnimation').each(function () {
        if (!$(this).hasClass("bounceIn")){
            var imagePos = $(this).offset().top;
            var imageHeight = $(this).height();
            var topOfWindow = $(window).scrollTop();
            var windowHeightLessImg = $(window).height() - imageHeight;

            if (imagePos < topOfWindow + windowHeightLessImg && imagePos + windowHeightLessImg > topOfWindow) {
                $(this).addClass("bounceIn");
            }
        }
    });

    $('.textAnimationRight').each(function () {
        if (!$(this).hasClass("fadeInLeft")){
            var textPos = $(this).offset().top;
            var textHeight = $(this).height();
            var topOfWindow = $(window).scrollTop();
            var windowHeightLessText = $(window).height() - textHeight;
            if (textPos < parseFloat(parseFloat(topOfWindow) + parseFloat(windowHeightLessText +100)) && parseFloat(parseFloat(textPos) + parseFloat(windowHeightLessText)) > topOfWindow) {
                $(this).addClass("fadeInLeft");
            }
        }
    });

    $('.textAnimationLeft').each(function () {
        if (!$(this).hasClass("fadeInRight")){
            var textPos = $(this).offset().top;
            var textHeight = $(this).height();
            var topOfWindow = $(window).scrollTop();
            var windowHeightLessText = $(window).height() - textHeight;

            if (textPos < (topOfWindow + windowHeightLessText) && (textPos + windowHeightLessText) > topOfWindow) {
                $(this).addClass("fadeInRight");
            }
        }
    });


});