/home/arranoyd/magicraft/wp-content/themes/massive-dynamic/assets/js/section_scroll.min.js
var $row_element=$(".vc_row:not(.vc_inner)"),row_count=$row_element.length,current_row_index=0,last_row_index=0,do_scroll=true,footer_show=false,window_height=$(window).height(),brightness;function pixflow_init_one_page_scroll(){if(isMobile()&&$("body").hasClass("disable_section_scroll_mobile")){$("body").removeClass("one_page_scroll");return false}if($("body").hasClass("compose-mode")&&$("body").hasClass("one_page_scroll")){pixflow_one_page_for_customizer();return false}if($("body").hasClass("one_page_scroll")){var a=$("footer").height();$("footer").css("bottom","-"+parseInt(a)+"px");pixflow_prepare_pages(row_count);if(pixflow_isTouchDevice()){pixflow_set_event_touch_on_document()}pixflow_set_event_on_window(row_count);pixflow_check_url();pixflow_bind_event_on_link()}return false}function pixflow_set_event_touch_on_document(){var a=0;$(document).bind("touchstart",function(b){a=b.originalEvent.touches[0].clientY});$(document).bind("touchend",function(c){if(do_scroll==false){return true}var b=c.originalEvent.changedTouches[0].clientY;if(a>b+5){if($(".row-active").find(" > .wrap").hasClass("mobile-row-over-height")){pixflow_row_scroll(row_count,"down")}else{pixflow_scroll_page("down",row_count)}}else{if($(".row-active").find(" > .wrap").hasClass("mobile-row-over-height")){pixflow_row_scroll(row_count,"up")}else{pixflow_scroll_page("up",row_count)}}});return true}function pixflow_set_event_on_window(a){$(window).off("wheel").on("wheel",function(b){if(b.originalEvent.deltaY>0){pixflow_scroll_page("down",a);$(window).off()}else{pixflow_scroll_page("up",a);$(window).off()}});return false}function pixflow_row_scroll(b,a){if(pixflow_isMobile()){if(current_row_index===($(".vc_row").last().index()+1)&&true===footer_show&&"up"==a){pixflow_scroll_page("up",b);return false}pixflow_row_scroll_mobile(a)}else{pixflow_row_scroll_desktop(b,a)}}var should_scroll_up=false,should_scroll_down=false;function pixflow_row_scroll_mobile(b){var a=$(".row-active").find(" > .wrap");if(a.scrollTop()+a.innerHeight()>=a[0].scrollHeight&&b=="down"){if(should_scroll_down==true){pixflow_scroll_page("down",row_count);should_scroll_down=false}else{should_scroll_down=true}}if(a.scrollTop()==0&&b=="up"){if(should_scroll_up==true){pixflow_scroll_page("up",row_count);should_scroll_up=false}else{should_scroll_up=true}}return false}function pixflow_row_scroll_desktop(c,b){var a=$(".row-active").find(".nicescroll-cursors").last();if(((a.offset().top+a.height())+4)>=a.parent().height()&&b=="down"){pixflow_scroll_page("down",c);return true}if(parseInt(a.css("top"))==0&&b=="up"){pixflow_scroll_page("up",c);return true}}var first_time_check=false;function pixflow_check_url(a){var b,c;b=(null!=a)?a:window.location.hash;b=b.replace("#","");c=parseInt($("#"+b).closest(".vc_row:not(.vc-inner)").attr("data-index"));if($(window).width()<=1280&&pixflow_isTouchDevice()){if(first_time_check==true){if($(".navigation-mobile").css("display")!="none"){$(".navigation-button").click()}}first_time_check=true}setTimeout(function(){$("#pix-nav").find("li").eq(c).find("span").click()},700)}function pixflow_bind_event_on_link(){$("a:not(.navigation-button)").on("click",function(h){var b=$(this).attr("href");if(b.search("#")!=-1){var a=window.location.origin;var g=b.split("/");var i=g[0];var f=g[2];var d=i+"//"+f;if(a==d||i==b){h.preventDefault();var c=b.substring(b.indexOf("#")+1);pixflow_check_url(c)}}})}function pixflow_one_page_for_customizer(){$row_obj=$(".vc_row:not(.vc_inner)");var a=parseInt($(window).height());$row_obj.each(function(){$(this).css({minHeight:a+"px"})})}function pixflow_prepare_pages(a){pixflow_set_height_for_rows();pixflow_create_bullet(a);$(window).load(function(){pixflow_set_color(0)});return false}function pixflow_set_height_for_rows(){pixflow_set_style_for_onepage();var c=$(window).height(),b=$(".vc_row:not(.vc_inner)"),a=0;$(".layout").css("min-height",c);b.each(function(){pixflow_detect_color(a);$(this).attr("data-index",a);$(this).addClass("full-page").css({height:c+"px",top:c+"px",zIndex:8});pixflow_check_for_nicescoll(a);a++});b.first().addClass("row-active").css({top:"0px",zIndex:10});return true}function pixflow_set_style_for_onepage(){var a=navigator.userAgent;if(/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini|Mobile|mobile|CriOS/i.test(a)){$("body , html").css({overflow:"hidden",height:"100%",position:"static"})}else{$("body").css({overflow:"hidden",height:"100%"})}var b=document.createElement("style");b.type="text/css";if(b.styleSheet){b.styleSheet.cssText="::-webkit-scrollbar {display: none;} html { overflow: -moz-scrollbars-none; } body{overflow: hidden;} .gather-overlay{position:fixed !important}"}else{b.appendChild(document.createTextNode("::-webkit-scrollbar {display: none;} html { overflow: -moz-scrollbars-none; } .gather-overlay{position:fixed !important}"))}document.getElementsByTagName("head")[0].appendChild(b);var c=parseInt($("header:not(.header-clone)").css("top"));if($("body").hasClass("admin-bar")){c+=32}$("body.one_page_scroll:not(.compose-mode) header:not(.header-clone)").css({top:c});return false}function pixflow_set_over_height_for_mobile(b){var a=$(".vc_row:not(.vc_inner)").eq(b);if(a.hasClass("row-over-height")){return}a.find(">.wrap").addClass("mobile-row-over-height")}function pixflow_check_for_nicescoll(b){if(pixflow_isMobile()){pixflow_set_over_height_for_mobile(b);pixflow_mobile_row_over_height();return false}var a=$(".vc_row:not(.vc_inner)").eq(b);if(a.hasClass("row-over-height")){return}if(a.find(">.wrap").height()>$(window).height()){a.addClass("row-over-height").find(">.wrap").niceScroll({horizrailenabled:false,cursorcolor:"rgba(204, 204, 204, 0.2)",cursorborder:"1px solid rgba(204, 204, 204, 0.2)",cursorwidth:"2px",touchbehavior:true,preventmultitouchscrolling:false,enablescrollonselection:false})}return false}function pixflow_create_bullet(c){var a='<div id="pix-nav" class="background--light"><ul>';a+='<li class="bullet-active" ><span data-index="0"></span></li>';for(var b=1;b<c;b++){a+='<li><span data-index="'+b+'"></span></li>'}a+="</ul></div>";$("body").append(a);$("#pix-nav").css("top",($(window).height()/2)+"px");pixflow_add_event_for_bullet(c)}function pixflow_add_event_for_bullet(a){$("body").on("click","#pix-nav span",function(){var c=parseInt($(".bullet-active").find("span").attr("data-index"));var b=parseInt($(this).attr("data-index"));if(b>c){last_row_index=current_row_index;if(current_row_index==b){return}current_row_index=b;pixflow_scroll_page("down",a,type="click")}else{if(footer_show==true){pixflow_footer_scroll_up_visible();footer_show=false}last_row_index=current_row_index;if(current_row_index==b){return}current_row_index=b;pixflow_scroll_page("up",a,type="click")}})}function pixflow_scroll_page(c,b,a){if(do_scroll==false){return}switch(c){case"up":pixflow_scroll_up(b,a);break;case"down":pixflow_scroll_down(b,a);break;default:return false;break}return false}function pixflow_scroll_down(b,a){do_scroll=false;if(current_row_index>=b-1&&a!="click"){pixflow_footer_visibilty(b);setTimeout(function(){pixflow_set_event_on_window(b)},10);return}pixflow_check_for_nicescoll();$(".bullet-active").removeClass("bullet-active");if(a=="click"){$("#pix-nav").find("li").eq(current_row_index).addClass("bullet-active");pixflow_check_for_nicescoll(current_row_index)}else{$("#pix-nav").find("li").eq(current_row_index+1).addClass("bullet-active");pixflow_check_for_nicescoll(current_row_index+1)}pixflow_scroll_down_animate(a)}function pixflow_scroll_down_animate(a){setTimeout(function(){pixflow_set_color(current_row_index)},500);if(a=="click"){if(last_row_index==current_row_index){last_row_index=current_row_index-1}$this_row=$(".vc_row:not(.vc_inner)").eq(last_row_index);$next_row=$(".vc_row:not(.vc_inner)").eq(current_row_index)}else{$this_row=$(".vc_row:not(.vc_inner)").eq(current_row_index);$next_row=$this_row.next()}$this_row.css({zIndex:9});setTimeout(function(){pixflow_shortcodeAnimationScroll();pixflow_onepage_scroll_svg_animate()},800);pixflow_call_tweenMax_for_scroll_down($this_row,$next_row);if(a!="click"){current_row_index++}pixflow_back_shortcode_to_position();$(".row-active").removeClass("row-active");$(".vc_row:not(.vc_inner)").eq(current_row_index).addClass("row-active")}function pixflow_scroll_up(b,a){do_scroll=false;if(footer_show==true){pixflow_footer_scroll_up_visible();return}if(current_row_index<=0&&a!="click"){current_row_index=0;do_scroll=true;setTimeout(function(){pixflow_set_event_on_window(b)},1);return}$(".bullet-active").removeClass("bullet-active");if(a!="click"){$("#pix-nav").find("li").eq(current_row_index-1).addClass("bullet-active")}else{$("#pix-nav").find("li").eq(current_row_index).addClass("bullet-active")}if(a!="click"){pixflow_set_color(current_row_index-1);pixflow_check_for_nicescoll(current_row_index-1)}else{pixflow_set_color(current_row_index);pixflow_check_for_nicescoll(current_row_index)}pixflow_scroll_up_animate(a)}function pixflow_scroll_up_animate(a){var c,b;if(a!="click"){c=$(".vc_row:not(.vc_inner)").eq(current_row_index);b=c.prev()}else{c=$(".vc_row:not(.vc_inner)").eq(last_row_index);b=$(".vc_row:not(.vc_inner)").eq(current_row_index)}pixflow_call_tweenMax_for_scroll_up(c,b,a);if(a!="click"){current_row_index--}pixflow_back_shortcode_to_position();$(".row-active").removeClass("row-active");$(".vc_row:not(.vc_inner)").eq(current_row_index).addClass("row-active");return}function pixflow_call_tweenMax_for_scroll_up(c,b,a){c.css({zIndex:9});TweenMax.to(c,1,{scale:0.75,opacity:0,ease:Power4.easeOut,onComplete:function(){if(a!="click"){TweenMax.to(c,0,{top:window_height,scale:1,opacity:1,zIndex:8,ease:Power4.easeOut})}else{var d=0;$(".vc_row:not(.vc_inner)").each(function(){if(d>parseInt(b.attr("data-index"))){TweenMax.to($(this),0,{top:window_height,scale:1,opacity:1,zIndex:8,ease:Power4.easeOut})}d++})}}});setTimeout(function(){pixflow_shortcodeAnimationScroll();pixflow_onepage_scroll_svg_animate()},800);b.css({zIndex:"10"});TweenMax.to(b,1,{top:"0px",ease:Power4.easeOut,delay:0.1,onComplete:function(){do_scroll=true;pixflow_set_event_on_window(row_count)}})}function pixflow_call_tweenMax_for_scroll_down(c,b,a){TweenMax.to(c,1,{scale:0.75,opacity:0,ease:Power4.easeOut,onComplete:function(){if(a!="click"){TweenMax.to(c,0,{top:"-"+window_height,scale:1,opacity:1,zIndex:8,ease:Power4.easeOut})}else{var d=0;$(".vc_row:not(.vc_inner)").each(function(){if(d==parseInt(b.attr("data-index"))){return}TweenMax.to($(this),0,{top:"-"+window_height,scale:1,opacity:1,zIndex:8,ease:Power4.easeOut});d++})}do_scroll=true}});b.css({zIndex:10});TweenMax.to(b,1,{top:"0px",ease:Power4.easeOut,delay:0.1,onComplete:function(){pixflow_set_event_on_window(row_count)}})}function pixflow_back_shortcode_to_position(){$(".row-active").find(".has-animation").each(function(){var g=$(this),f=Number(g.attr("data-animation-speed"))*0.001,d=Number(g.attr("data-animation-delay")),c=g.attr("data-animation-position"),b=g.attr("data-animation-easing"),a=50;$(this).removeClass("show-animation");var e=[c,g,f,d,b,a];pixflow_get_shortcode_back_to_position(e)})}function pixflow_footer_visibilty(b){if($("footer").attr("data-footer-status")=="off"){do_scroll=true;return false}footer_show=true;current_row_index=b-1;var a=$("footer").height();this_row=$(".vc_row:not(.vc_inner)").last();TweenMax.to(this_row,1,{top:"-"+a+"px",ease:Power4.easeOut});TweenMax.to($("footer"),1,{bottom:"0px",opacity:1,ease:Power4.easeOut,onComplete:function(){do_scroll=true;pixflow_set_event_on_window(b)}});return false}function pixflow_footer_scroll_up_visible(){if($("footer").attr("data-footer-status")=="off"){do_scroll=true;return}var a=$("footer").height(),b=$(".vc_row:not(.vc_inner)").last();TweenMax.to(b,1,{top:"0px",repeatDelay:0.5,ease:Power4.easeOut});TweenMax.to($("footer"),1,{bottom:"-"+a+"px",opacity:0,repeatDelay:0.5,ease:Power4.easeOut,onComplete:function(){do_scroll=true;footer_show=false;pixflow_set_event_on_window(row_count)}});return false}function pixflow_set_color(a){pixflow_change_color($(".vc_row:not(.vc_inner)").eq(a).attr("data-detect-color"))}function pixflow_detect_color(c){var b=document.createElement("canvas"),d=b.getContext("2d");if($(".vc_row:not(.vc_inner)").eq(c).find("> .row-image").last().length){var e=$(".vc_row:not(.vc_inner)").eq(c).find("> .row-image").last().css("backgroundImage").replace(/.*\s?url\([\'\"]?/,"").replace(/[\'\"]?\).*/,"");if(e!="none"){var a=new Image();a.onload=function(){d.drawImage(a,0,0);pixflow_get_image_brightness(b.toDataURL(),function(f){$(".vc_row:not(.vc_inner)").eq(c).attr("data-detect-color",f);return})};a.src=e}}else{b.setAttribute("width","20px");b.setAttribute("height","20px");d.beginPath();d.rect(0,0,20,20);d.fillStyle=$(".vc_row:not(.vc_inner)").eq(c).attr("data-bgcolor");d.fill();pixflow_get_image_brightness(b.toDataURL(),function(f){$(".vc_row:not(.vc_inner)").eq(c).attr("data-detect-color",f);return})}}function pixflow_change_color(a){if(a>160){$("#pix-nav").removeClass("background--dark").addClass("background--light");if($("header").hasClass("top-gather")){$("header .logo").find("img").attr("src",$("header .logo-img").attr("data-dark-url"));$(".gather-menu-icon").css("color","black");if($(".navigation-button").length){$(".navigation-button").find("span").css("color","black")}if($(".shopcart-item").length){$(".shopcart-item").find(".icon").css("color","black")}if($(".notification-item").length){$(".notification-item").find(".icon").css("color","black")}if($(".search-item").length){$(".search-item").find(".icon").css("color","black")}if($(".mobile-shopcart").length){$(".mobile-shopcart").find("span").css("color","black")}}}else{$("#pix-nav").addClass("background--dark").removeClass("background--light");if($("header").hasClass("top-gather")){$("header .logo-img").attr("src",$("header .logo-img").attr("data-light-url"));$(".gather-menu-icon").css("color","#ffffff");if($(".shopcart-item").length){$(".shopcart-item").find(".icon").css("color","#ffffff")}if($(".navigation-button").length){$(".navigation-button").find("span").css("color","#ffffff")}if($(".notification-item").length){$(".notification-item").find(".icon").css("color","#ffffff")}if($(".search-item").length){$(".search-item").find(".icon").css("color","#ffffff")}if($(".mobile-shopcart").length){$(".mobile-shopcart").find("span").css("color","#ffffff")}}}}function pixflow_get_image_brightness(b,e){var a=document.createElement("img");var d=0;a.src=b;a.classList.add("pixflow-bright-img");a.style.display="none";document.body.appendChild(a);var c=0;a.onload=function(){var i=document.createElement("canvas");i.width=this.width;i.height=this.height;var p=i.getContext("2d");p.drawImage(this,0,0);var f=p.getImageData(0,0,i.width,i.height);var j=f.data;var h,k,n,m;for(var o=0,l=j.length;o<l;o+=4){h=j[o];k=j[o+1];n=j[o+2];m=Math.floor((h+k+n)/3);c+=m}d=Math.floor(c/(this.width*this.height));e(d);$(".pixflow-bright-img").remove()}}function pixflow_mobile_row_over_height(){$(".mobile-row-over-height").last().on("scroll",function(){if(true==footer_show){pixflow_footer_scroll_up_visible();footer_show=false}})};