scrollAnimataion({ className: "fadeIn", triggerPoint: 100 }); $(document).ready(function () { var windowWdth = $(window).width(); parallax( windowWdth ); $(window).on('resize', function(){ windowWdth = $(window).width(); parallax( windowWdth ); }); function parallax( windowWdth ) { if( windowWdth > 640 ) { $(".rellax--1").each(function () { var tmb = $(this); var scroll = $(window).scrollTop(); var windowHeight = $(window).height(); var position = tmb.offset().top; var parallaxValue = -1 * ((scroll + windowHeight - position) / 18 - windowHeight / 15); tmb.css({ transform: "translateY(" + parallaxValue + "px)" }); $(document).on("scroll", function () { scroll = $(window).scrollTop(); windowHeight = $(window).height(); position = tmb.offset().top; parallaxValue = -1 * ((scroll + windowHeight - position) / 18 - windowHeight / 15); tmb.css({ transform: "translateY(" + parallaxValue + "px)" }); }); }); $(".rellax--2").each(function () { var tmb = $(this); var scroll = $(window).scrollTop(); var windowHeight = $(window).height(); var position = tmb.offset().top; var parallaxValue = -1 * ((scroll + windowHeight - position) / 12 - windowHeight / 10); tmb.css({ transform: "translateY(" + parallaxValue + "px)" }); $(document).on("scroll", function () { scroll = $(window).scrollTop(); windowHeight = $(window).height(); position = tmb.offset().top; parallaxValue = -1 * ((scroll + windowHeight - position) / 12 - windowHeight / 10); tmb.css({ transform: "translateY(" + parallaxValue + "px)" }); }); }); $(".rellax--3").each(function () { var tmb = $(this); var scroll = $(window).scrollTop(); var windowHeight = $(window).height(); var position = tmb.offset().top; var parallaxValue =-1 * ((scroll + windowHeight - position) / 6 - windowHeight / 5); tmb.css({ transform: "translateY(" + parallaxValue + "px)" }); $(document).on("scroll", function () { scroll = $(window).scrollTop(); windowHeight = $(window).height(); position = tmb.offset().top; parallaxValue =-1 * ((scroll + windowHeight - position) / 6 - windowHeight / 5); tmb.css({ transform: "translateY(" + parallaxValue + "px)" }); }); }); } else { $(".rellax--1").each(function () { var tmb = $(this); var scroll = $(window).scrollTop(); var windowHeight = $(window).height(); var position = tmb.offset().top; var parallaxValue = -1 * ((scroll + windowHeight - position) / 36 - windowHeight / 30); tmb.css({ transform: "translateY(" + parallaxValue + "px)" }); $(document).on("scroll", function () { scroll = $(window).scrollTop(); windowHeight = $(window).height(); position = tmb.offset().top; parallaxValue = -1 * ((scroll + windowHeight - position) / 36 - windowHeight / 30); tmb.css({ transform: "translateY(" + parallaxValue + "px)" }); }); }); $(".rellax--2").each(function () { var tmb = $(this); var scroll = $(window).scrollTop(); var windowHeight = $(window).height(); var position = tmb.offset().top; var parallaxValue = -1 * ((scroll + windowHeight - position) / 24 - windowHeight / 20); tmb.css({ transform: "translateY(" + parallaxValue + "px)" }); $(document).on("scroll", function () { scroll = $(window).scrollTop(); windowHeight = $(window).height(); position = tmb.offset().top; parallaxValue = -1 * ((scroll + windowHeight - position) / 24 - windowHeight / 20); tmb.css({ transform: "translateY(" + parallaxValue + "px)" }); }); }); $(".rellax--3").each(function () { var tmb = $(this); var scroll = $(window).scrollTop(); var windowHeight = $(window).height(); var position = tmb.offset().top; var parallaxValue =-1 * ((scroll + windowHeight - position) / 12 - windowHeight / 10); tmb.css({ transform: "translateY(" + parallaxValue + "px)" }); $(document).on("scroll", function () { scroll = $(window).scrollTop(); windowHeight = $(window).height(); position = tmb.offset().top; parallaxValue =-1 * ((scroll + windowHeight - position) / 12 - windowHeight / 10); tmb.css({ transform: "translateY(" + parallaxValue + "px)" }); }); }); } } });