var subdir = ""; var protocol = location.protocol; var http_path = protocol+"//"+window.location.host+subdir; var window_breedte = $(window).width()*1; var document_clicked = false; $(document).on('click', function (e) { document_clicked = true; window.setTimeout(function(){ document_clicked = false; }, 300); var container = $("#cat_buttons"); if (!container.is(e.target) && container.has(e.target).length === 0){ hide_submenu(); } var container_2 = $("#user_login_box"); if (!container_2.is(e.target) && container_2.has(e.target).length === 0){ hide_login_overlay(); } }); $(document).on('click','#show_bestelling','data',function(e){ $('#show_bekijk_bestelling').slideToggle(500); }); $(document).on('click','#bestelling_plaatsen_1','data',function(e){ show_checkout_box(); }); $(document).on('click','#checkout_overlay, #checkout_wijzig_bestelling, .close_checkout_box','data',function(e){ hide_checkout_box(); }); var checkout_visible = false; function show_checkout_box(){ checkout_visible = true; var deze = $('#checkout_box'); var mapfilter = $('#checkout_overlay'); mapfilter.velocity({ 'opacity': '0', //'translateY': '50px', 'translateZ': '0', }, { visibility:'hidden',duration: 0}); mapfilter.velocity({ 'opacity': '1', //'translateY': '50px', 'translateZ': '0', }, { visibility:'visible',duration: 300}); deze.velocity({ 'opacity': '0', //'translateY': '50px', 'translateX': '-120%', 'translateZ': '0', }, { visibility:'hidden',duration: 0, complete: function(){ }}); deze.velocity({ 'opacity': '1', //'translateY': '50px', 'translateX': '0%', 'translateZ': '0', }, { visibility:'visible',duration: 300, complete: function(){ }}); } function hide_checkout_box(){ checkout_visible = false; var deze = $('#checkout_box'); var mapfilter = $('#checkout_overlay'); mapfilter.velocity({ 'opacity': '0', //'translateY': '50px', 'translateZ': '0', }, { visibility:'hidden',duration: 300}); deze.velocity({ 'opacity': '0', //'translateY': '50px', 'translateX': '-120%', 'translateZ': '0', }, { visibility:'hidden',duration: 300, complete: function(){ }}); } $(document).on('click','#locatie_bevestigen','data',function(e){ hide_google_map(); var latitude_1 = ''; var longitude_1 = ''; $('.loading').show(); console.log('locatieID',locatieID); get_companies(locatieID); }); function hide_google_map(){ var deze = $('#map_overlay'); var mapfilter = $('#map_overlay_filter'); mapfilter.velocity({ 'opacity': '0', //'translateY': '50px', 'translateZ': '0', }, { visibility:'hidden',duration: 500}); deze.velocity({ 'opacity': '0', //'translateY': '50px', 'translateY': '120%', 'translateZ': '0', }, { visibility:'hidden',duration: 500, complete: function(){ }}); } function show_google_map(){ var deze = $('#map_overlay'); var mapfilter = $('#map_overlay_filter'); mapfilter.velocity({ 'opacity': '0', //'translateY': '50px', 'translateZ': '0', }, { visibility:'hidden',duration: 0}); mapfilter.velocity({ 'opacity': '1', //'translateY': '50px', 'translateZ': '0', }, { visibility:'visible',duration: 500}); deze.velocity({ 'opacity': '0', //'translateY': '50px', 'translateY': '120%', 'translateZ': '0', }, { visibility:'hidden',duration: 0, complete: function(){ }}); deze.velocity({ 'opacity': '1', //'translateY': '50px', 'translateY': '0%', 'translateZ': '0', }, { visibility:'visible',duration: 500, complete: function(){ }}); } $(document).on('click','#show_cat_buttons','data',function(e){ show_submenu(); }); $(document).on('click','.productcat2, .close_cat_buttons','data',function(e){ hide_submenu(); }); $(document).on('click','.bestelling_plaatsen_mobile','data',function(e){ var deze = $(this); show_winkelmand(); }); $(document).on('click','#company_data_flex_filter, .close_winkelmand','data',function(e){ if (winkelmand_open){ hide_winkelmand(); } }); var login_active_clicked = false; $(document).on('click','.login_button','data',function(e){ var deze = $(this); deze.addClass('login_button_active'); show_login_overlay(deze); }); function show_login_overlay(deze){ if (login_active_clicked == false && deze.hasClass('login_button_active')){ var deze = $('#user_login_box'); var speed = 300; deze.velocity({ 'opacity': '0', //'translateY': '50px', 'translateX': '50px', 'translateZ': '0', }, { duration: 0, complete: function(){ }}); deze.find('.show_animate').css('opacity','0'); deze.velocity({ 'opacity': '1', 'translateY': '0%', 'translateX': '0%', 'translateZ': '0' }, { visibility:'visible',duration: (speed * 2), easing: 'easeOutQuart', complete: function(){ }}); window.setTimeout(function(){ login_active_clicked = true; deze.find('.show_animate').velocity("transition.slideRightIn", { stagger: 90, display: "block" }); }, (speed / 2)); }else{ hide_login_overlay(); } } function hide_login_overlay(){ if (login_active_clicked == true){ $('#open_login_button').removeClass('login_button_active'); var deze = $('#user_login_box'); var speed = 300; deze.velocity({ 'opacity': '0', //'translateY': '50px', 'translateX': '50px', 'translateZ': '0' }, { visibility:'hidden',duration: (speed * 2), easing: 'easeOutQuart', complete: function(){ }}); window.setTimeout(function(){ login_active_clicked = false; }, (speed / 2)); } } $(document).on('click','#create_account_link','data',function(e){ var idvar = 'create_account'; get_login_fields(idvar); }); $(document).on('click','#login_link','data',function(e){ var idvar = 'login'; get_login_fields(idvar); }); function get_login_fields(idvar){ $('#loading').show(); $.ajax({ url:http_path+'/user_login.php', type: 'GET', timeout : '60000', data: {task:idvar}, cache: false, success: function (html, response) { // wl_alert("alert",html); $('#user_login_box').html(''); $('#user_login_box').append(html); //window.setTimeout(function(){ if (!$('#open_login_button').hasClass('login_button_active')){ $('.login_button').trigger('click'); }else{ $('#user_login_box').find('.show_animate').velocity("transition.slideRightIn", { stagger: 90, display: "block" }); } // $('#user_login_box').css('visibility','visible'); // $('#user_login_box').css('opacity','1'); /* if(!$("#user_login_box").is(":visible")){ alert('tt'); show_login_overlay(); } */ //}, (speed / 2)); }, error: function(){ wl_alert('alert', 'Check uw Internet connectie of probeer het later opnieuw!', '', '', 'Ok', '', ''); }, complete: function(){ $('#loading').hide(); } }); } $(document).on('click','#trigger_login','data',function(e){ var idvar = 'login'; get_login_fields(idvar); }); $(document).on('click','#trigger_account_maken','data',function(e){ var idvar = 'create_account'; get_login_fields(idvar); }); var winkelmand_open = false; var winkelmand_visible = false; function show_winkelmand(){ var winkelmand_container = $('.winkelmand_container'); var speed = 300; winkelmand_container.velocity({ 'opacity': '0', 'translateX': '120%', 'translateZ': '0' }, { visibility:'hidden',duration: 0, easing: 'easeInOutQuart', complete: function(){ }}); winkelmand_container.velocity({ 'opacity': '1', 'translateX': '0', 'translateZ': '0' }, { visibility:'visible',duration: speed, easing: 'easeInOutQuart', complete: function(){ }}); $('#company_data_flex_filter').velocity({ 'opacity': '1', 'translateX': '0', 'translateZ': '0' }, { visibility:'visible',duration: speed, easing: 'easeInOutQuart'}); window.setTimeout(function(){ winkelmand_open = true; winkelmand_visible = true; }, speed); } function hide_winkelmand(){ var speed = 300; if (winkelmand_open){ winkelmand_visible = false; $('.winkelmand_container').velocity({ 'opacity': '0', 'translateX': '120%', 'translateZ': '0' }, { visibility:'hidden',duration: speed, easing: 'easeInOutQuart', complete: function(){ }}); $('#company_data_flex_filter').velocity({ 'opacity': '0', 'translateX': '0', 'translateZ': '0' }, { visibility:'hidden',duration: speed, easing: 'easeInOutQuart'}); window.setTimeout(function(){ winkelmand_open = false; }, speed); } } var submenu_open = false; function show_submenu(){ var speed = 300; $('.cat_buttons').velocity({ 'opacity': '0', 'translateX': '-120%', 'translateZ': '0' }, { visibility:'hidden',duration: 0, easing: 'easeInOutQuart', complete: function(){ }}); $('#company_data_flex_filter').velocity({ 'opacity': '1', 'translateX': '0', 'translateZ': '0' }, { visibility:'visible',duration: speed, easing: 'easeInOutQuart'}); $('.cat_buttons').velocity({ 'opacity': '1', 'translateX': '0', 'translateZ': '0' }, { visibility:'visible',display:'flex',duration: speed, easing: 'easeInOutQuart', complete: function(){ }}); window.setTimeout(function(){ submenu_open = true; }, speed); } function hide_submenu(){ var speed = 300; if (submenu_open){ $('.cat_buttons').velocity({ 'opacity': '0', 'translateX': '-120%', 'translateZ': '0' }, { visibility:'hidden',duration: speed, easing: 'easeInOutQuart', complete: function(){ }}); $('#company_data_flex_filter').velocity({ 'opacity': '0', 'translateX': '0', 'translateZ': '0' }, { visibility:'hidden',duration: speed, easing: 'easeInOutQuart'}); window.setTimeout(function(){ submenu_open = false; }, speed); } } $(document).on('click','#zoek_restaurants','data',function(e){ $('.loading').show(); var deze = $(this); /* var latitude_1 = ''; var longitude_1 = ''; $('.loading').show(); get_companies(latitude_1,longitude_1); */ show_google_map(); }); $(document).on('click','#zoek_adres','data',function(e){ $('#adres').show(); }); $(document).on('click','.productcat2','data',function(e){ var deze = $(this); var deze_id = deze.data('catid'); $('.productcat2').removeClass('productcat2_active'); deze.addClass('productcat2_active'); $('.productcat2').removeClass('productcat_active'); deze.addClass('productcat_active'); if (deze_id != 'all_products'){ $('.productsforcatid').hide(); target_container = $('#productsforcatid_'+deze_id); target_container.show(); target_container.find('.product_wrapper:lt(15)').velocity("transition.slideUpIn", { stagger: 70, display: "flex" }); }else{ $('.productsforcatid').show(); $('.productsforcatid').find('.comp_animate').velocity("transition.slideUpIn", { stagger: 70 }); } }); function get_companies(locatieID){ $.ajax({ url:http_path+'/companies_producten.php', type: 'GET', timeout : '60000', data: {task:'get_companies',locatieID:locatieID}, cache: false, success: function (html, response) { // wl_alert("alert",html); $('#company_bx').html(''); $('#company_bx').append(html); //$('.nav_item_link_pers').velocity("transition.shrinkIn", { stagger: 150, display: "inline-block" }); // $('.company_block').velocity("transition.slideUpIn", { stagger: 150, display: "inline-block" }); $('.company_block').velocity("transition.slideUpIn", { stagger: 150, display: "inline-block" }); // $(".company_box_container").velocity("scroll", { duration: 600, easing: "easeInOutQuart" }); // $("#scrolling_trigger_point").velocity("scroll", { duration: 600, easing: "easeInOutQuart" , container: $("#home_container")}); //// $("#company_bx").velocity("scroll", { duration: 600, easing: "easeInOutQuart", offset: 100, container: $("#home_container")}); /* window.setTimeout(function(){ // var myElement = document.getElementById('scrolling_trigger_point'); // var topPos = myElement.position().top; var topPos = $('.company_block').position().top; alert(topPos); document.getElementById('home_container').scrollTop = topPos; }, 1000); */ //$("#zoek_restaurants").velocity("scroll", { duration: 600, easing: "easeInOutQuart" , container: $("#home_container")}); document.getElementById("scrolling_trigger_point").scrollIntoView({ behavior: "smooth", block: "start", inline: "start" }); /* jqElement = $("#company_bx"); utils.scrollVerticallyToElement(jqElement, true); */ }, error: function(){ wl_alert('alert', 'Check uw Internet connectie of probeer het later opnieuw!', '', '', 'Ok', '', ''); }, complete: function(){ $('.loading').hide(); } }); } var utils = { clearAllSelections: function() { //clearing selected text if any if (document.selection && document.selection.empty) { document.selection.empty(); } else if (window.getSelection) { var sel = window.getSelection(); sel.removeAllRanges(); } }, getWindowClientVisibleRect: function () { var html = document.documentElement; var body = document.body; var doc = (html && html.clientWidth) ? html : body; var scrollTop = window.pageYOffset || html.scrollTop || body.scrollTop; var scrollLeft = window.pageXOffset || html.scrollLeft || body.scrollLeft; var clientTop = html.clientTop || body.clientTop || 0; var clientLeft = html.clientLeft || body.clientLeft || 0; var windowLeft = scrollLeft - clientLeft; var windowRight = doc.clientWidth + windowLeft; var windowTop = scrollTop - clientTop; var windowBottom = doc.clientHeight + windowTop; return { left: windowLeft, top: windowTop, right: windowRight, bottom: windowBottom }; }, getScrollableElementVisibleRect: function (element) { var left = element.scrollLeft - element.clientLeft; var top = element.scrollTop - element.clientTop; return { left: left, top: top, right: element.clientWidth + left, bottom: element.clientHeight + top }; }, getCoordinates: function (element) { var top = 0, left = 0; if (element.getBoundingClientRect) { var windowRect = this.getWindowClientVisibleRect(); var elementRect = element.getBoundingClientRect(); top = Math.round(elementRect.top + windowRect.top); left = Math.round(elementRect.left + windowRect.left); } else { while (element) { top = top + parseInt(element.offsetTop); left = left + parseInt(element.offsetLeft); element = element.offsetParent; } } return { top: top, left: left, right: left + element.offsetHeight, bottom: top + element.offsetHeight }; }, scrollWindowVerticallyToElement: function (element) { var elemCoord = this.getCoordinates(element); var wndRect = this.getWindowClientVisibleRect(); if (elemCoord.top < wndRect.top) { window.scrollTo(wndRect.left, elemCoord.top); } else if (elemCoord.bottom > wndRect.bottom) { window.scrollBy(0, elemCoord.bottom - wndRect.bottom); } }, scrollVerticallyToElement: function (jqElement, useAnimation) { if (!jqElement || !jqElement.parent) { return; } var scrollToElement; if (!useAnimation) { scrollToElement = function(jq, scrollValue) { jq.scrollTop(scrollValue); }; } else { scrollToElement = function (jq, scrollValue) { jq.animate({ scrollTop: scrollValue }, 'fast'); }; } jqElement.parents().each(function () { var jqThis = $(this); var top = Math.round(jqElement.position().top); var bottom = top + jqElement.innerHeight(); var parentTop = Math.round(jqThis.position().top); var parentBottom = parentTop + jqThis.innerHeight(); if (top < parentTop && jqThis.scrollTop() > 0) { scrollToElement(jqThis, jqThis.scrollTop() - parentTop + top); } else if (bottom > parentBottom) { scrollToElement(jqThis, jqThis.scrollTop() - parentBottom + bottom); } }); this.scrollWindowVerticallyToElement(jqElement.get(0)); } }; $(document).on('click','.close_company','data',function(e){ hide_products_overlay(); }); $(document).on('click','.company_block','data',function(e){ var deze = $(this); var company_id = deze.data('company_id'); var longitude_1 = ''; $('.loading').show(); get_products(company_id); }); function get_products(company_id){ $.ajax({ url:http_path+'/companies_producten.php', type: 'GET', timeout : '60000', data: {task:'get_products',company:company_id}, cache: false, success: function (html, response) { // wl_alert("alert",html); $('#producten_bx_inner').html(''); $('#producten_bx_inner').append(html); get_items_from_local_storage(); show_products_overlay(); //$('.company_block').velocity("transition.slideUpIn", { stagger: 150, display: "inline-block" }); }, error: function(){ wl_alert('alert', 'Check uw Internet connectie of probeer het later opnieuw!', '', '', 'Ok', '', ''); }, complete: function(){ $('.loading').hide(); } }); } $(document).on('change','#aantal','data',function(e){ var deze = $(this); var deze_aantal = deze.val(); if (deze_aantal < 1){ deze_aantal = 1; deze.val(deze_aantal); } var verkoop_prijs = $('#voeg_toe_winkelmand').data('verkoop_prijs') * 1; verkoop_prijs = get_prijs_from_wishes(verkoop_prijs); var new_display_prijs = deze_aantal * verkoop_prijs; $('#product_product_totaal').html(new_display_prijs.toMoney(2)); }); $(document).on('input','#aantal','data',function(e){ var deze = $(this); var deze_aantal = deze.val(); var verkoop_prijs = $('#voeg_toe_winkelmand').data('verkoop_prijs') * 1; var new_display_prijs = deze_aantal * verkoop_prijs; $('#product_product_totaal').html(new_display_prijs.toMoney(2)); }); $(document).on('click','.plusus','data',function(e){ var deze = $(this); var prev = deze.prev(); var cur_val = prev.val() * 1; var new_val = cur_val + 1; if (new_val > 0){ prev.val(new_val); if (deze.hasClass('in_winkelmand')){ prev.trigger('input'); var speed = 20; pulse_widget(speed); }else{ var verkoop_prijs = $('#voeg_toe_winkelmand').data('verkoop_prijs') * 1; verkoop_prijs = get_prijs_from_wishes(verkoop_prijs); var new_display_prijs = new_val * verkoop_prijs; $('#product_product_totaal').html(new_display_prijs.toMoney(2)); } } }); $(document).on('click','.minus','data',function(e){ var deze = $(this); var next = deze.next(); var cur_val = next.val() * 1; var new_val = cur_val - 1; if (new_val > 0){ next.val(new_val); if (deze.hasClass('in_winkelmand')){ next.trigger('input'); var speed = 20; pulse_widget(speed); }else{ var verkoop_prijs = $('#voeg_toe_winkelmand').data('verkoop_prijs') * 1; verkoop_prijs = get_prijs_from_wishes(verkoop_prijs); var new_display_prijs = new_val * verkoop_prijs; $('#product_product_totaal').html(new_display_prijs.toMoney(2)); } } }); function get_prijs_from_wishes(verkoop_prijs){ $('.product_wrapper_wish_active').each(function() { var dit = $(this); var dit_prijs = dit.data('verkoop_prijs') * 1; verkoop_prijs = verkoop_prijs + dit_prijs; }); return verkoop_prijs; } $(document).on('click','.product_wrapper_wish','data',function(e){ var deze = $(this); var deze_container = deze.closest('.wishdata'); if (!deze.hasClass('product_wrapper_wish_active')){ if (!deze_container.hasClass('select_multiple')){ deze_container.find('.product_wrapper_wish').removeClass('product_wrapper_wish_active'); } deze.addClass('product_wrapper_wish_active'); }else{ if (!deze_container.hasClass('select_multiple')){ deze_container.find('.product_wrapper_wish').removeClass('product_wrapper_wish_active'); } deze.removeClass('product_wrapper_wish_active'); } $('#aantal').trigger('change'); }); $(document).on('click','.product_wrapper','data',function(e){ var deze = $(this); var product_id = deze.data('product-id'); $('.loading').show(); get_product_by_id(product_id); }); $(document).on('click','#product_overlay_closer, #terug_product, .close_product_detail, #voeg_toe_winkelmand','data',function(e){ hide_single_product_overlay(); }); function get_product_by_id(product_id){ $.ajax({ url:http_path+'/companies_producten.php', type: 'GET', timeout : '60000', data: {task:'get_individual_product',prod_id:product_id}, cache: false, success: function (html, response) { // wl_alert("alert",html); $('#product_overlay_inner').html(''); $('#product_overlay_inner').append(html); show_single_product_overlay(); //$('.company_block').velocity("transition.slideUpIn", { stagger: 150, display: "inline-block" }); }, error: function(){ wl_alert('alert', 'Check uw Internet connectie of probeer het later opnieuw!', '', '', 'Ok', '', ''); }, complete: function(){ $('.loading').hide(); } }); } var single_product_visible = false; function show_single_product_overlay(){ single_product_visible = true; $('#product_overlay_filter').velocity({ 'opacity': '0', 'translateZ': '0' }, { duration: 0, easing: 'easeInOutQuart', complete: function(){ }}); $('#product_overlay_filter').velocity({ 'opacity': '1', 'translateZ': '0' }, { visibility: "visible" ,duration: 500, easing: 'easeInOutQuart', complete: function(){ }}); $('#product_overlay').velocity({ 'translateY': '100%', 'opacity': '0', 'translateZ': '0' //'translateX': weg_animeren }, { duration: 0, easing: 'easeInOutQuart', complete: function(){ }}); $('.comp_animate2').css('opacity','0'); $('#product_overlay').velocity({ 'translateY': '0%', 'opacity': '1', 'translateZ': '0' //'translateX': weg_animeren }, { visibility: "visible" ,duration: 500, easing: 'easeInOutQuart', complete: function(){ }}); window.setTimeout(function(){ $('.comp_animate2').velocity("transition.slideUpIn", { stagger: 100 }); }, 500); } function hide_single_product_overlay(){ var timing = 300; single_product_visible = false; $('#product_overlay_filter').velocity({ 'opacity': '0', 'translateZ': '0' }, { visibility: "hidden", duration: timing, easing: 'easeInOutQuart', complete: function(){ }}); $('#product_overlay').velocity({ 'translateY': '100%', 'opacity': '0', 'translateZ': '0' //'translateX': weg_animeren }, { visibility: "hidden" ,duration: timing, easing: 'easeInOutQuart'}); window.setTimeout(function(){ $("#product_overlay_inner").scrollTop(0); }, timing); } var products_visible = false; function show_products_overlay(){ products_visible = true; $('#producten_bx').velocity({ 'translateY': '100%', 'opacity': '0', 'translateZ': '0' //'translateX': weg_animeren }, { duration: 0, easing: 'easeInOutQuart', complete: function(){ }}); $('.comp_animate').css('opacity','0'); $('#producten_bx').velocity({ 'translateY': '0%', 'opacity': '1', 'translateZ': '0' //'translateX': weg_animeren }, { visibility: "visible" ,duration: 500, easing: 'easeInOutQuart', complete: function(){ }}); window.setTimeout(function(){ $('.comp_animate').velocity("transition.slideUpIn", { stagger: 100 }); }, 500); } function hide_products_overlay(){ products_visible = false; $('#producten_bx').velocity({ 'translateY': '100%', 'opacity': '0', 'translateZ': '0' //'translateX': weg_animeren }, { visibility: "hidden" ,duration: 500, easing: 'easeInOutQuart', complete: function(){ }}); } $(window).on('resize', function() { window_breedte = $(window).width()*1; }); function parallaxScroll(){ var scrolledY = $(window).scrollTop(); //$('.slides_budget_container_parallex').css('transform','translateY('+((scrolledY*0.5))+'px)'); if (window_breedte > 800){ $('#mb_wrapper').css('transform','translate3d( 0px,'+(((scrolledY)*0.2))+'px,0px)'); } } $(document).on('scroll', function() { parallaxScroll(); }); /* $(document).on('click','.round_close, .close_company, .close_product_detail','data',function(e){ window.history.back(); }); */ $(window).on('hashchange', function(e){ /* if (history.pushState) { var window_url = window.location.href; // alert(url); history.pushState(null, null, window_url); } */ console.log( 'hash changed' ); // e.preventDefault(); var current_hash = location.hash; if(current_hash!=''){ if (document_clicked == false){ navigate(current_hash); }else{ console.log('document geklikt, haschange bounce'); } }else{ hide_products_overlay(); } }); function navigate(current_hash){ if (!$('#company_data_flex_filter').length){ return false; } // var element_company = document.querySelector('#producten_bx_inner'); // var element_product = document.querySelector('#product_overlay'); // var element_winkelmand = document.querySelector('.winkelmand_container'); // var element_checkout = document.querySelector('#checkout_box'); console.log('current hash: '+current_hash); var hash_vars = current_hash.split('&'); /// var page = hash_vars[0]; /// alert(page.substring(1)); console.log(hash_vars); if ($.inArray('#company', hash_vars) > -1){ //if (!isInViewport(element_company)){ if (products_visible == false){ show_products_overlay(); } } if ($.inArray('product', hash_vars) > -1){ //if (!isInViewport(element_product)){ if (single_product_visible == false){ show_single_product_overlay(); } }else{ hide_single_product_overlay(); } if ($.inArray('winkelmand', hash_vars) > -1){ //if (!isInViewport(element_winkelmand)){ if (winkelmand_visible == false){ show_winkelmand(); } }else{ hide_winkelmand(); } if ($.inArray('checkout', hash_vars) > -1){ //if (!isInViewport(element_checkout)){ if (checkout_visible == false){ show_checkout_box(); } }else{ hide_checkout_box(); } /* if (isInViewport(element_company)){ alert('visible 2'); }else{ alert('not visble 2'); } */ } function isInViewport(element) { const rect = element.getBoundingClientRect(); return ( rect.top >= 0 && rect.left >= 0 && rect.bottom <= (window.innerHeight || document.documentElement.clientHeight) && rect.right <= (window.innerWidth || document.documentElement.clientWidth) ); } $(document).ready(function () { $('#home_container').on('scroll', function(){ //$(document).on('scroll','.home_container', function(){ var deze = $(this); var scrolledY = deze.scrollTop(); //var target_par = deze.find('.diensten_inner_image'); //target_par.css('transform','translate3d( 0px,'+(((scrolledY)*0.5))+'px,0px)'); if (window_breedte > 800){ $('#mb_wrapper').css('transform','translate3d( 0px,'+(((scrolledY)*0.2))+'px,0px)'); } //console.log('scrolledY: '+scrolledY); //console.log("scrolled!"); }); });