1/* 2* Section parallax effect 3 */ 4(function(document,window){ 5 6 tenwebParallax = function(element,options){ 7 8 var defoultOptions = { 9 vertical_scroll:{ 10 active: false, 11 direction: 'up', 12 speed: 4, 13 }, 14 horizontal_scroll:{ 15 active: false, 16 direction: 'right', 17 speed: 4, 18 }, 19 transparency:{ 20 active: false, 21 direction: 'in', 22 speed: 5, 23 }, 24 blur:{ 25 active: false, 26 direction: 'in', 27 speed: 10, 28 }, 29 scale:{ 30 active: false, 31 direction: 'in', 32 speed: 10, 33 } 34 } 35 this.element = element; 36 var curOptions = {}; 37 mergeOptions(options); 38 this.layerDiv = createInnerDiv(); 39 this.options = curOptions; 40 function mergeOptions(userOpt){ 41 // checking if options acceptable then set user def options else set def options 42 curOptions = defoultOptions; 43 if(typeof userOpt !== 'object') 44 curOptions = defoultOptions; 45 let optionsArray = Object.entries(userOpt); 46 for(let i = 0; i < optionsArray.length;i++){ 47 if(typeof optionsArray[i] === 'object' && typeof defoultOptions[optionsArray[i][0]] === 'object'){ 48 if(typeof optionsArray[i][1] === 'object'){ 49 if(typeof optionsArray[i][1].active !== 'undefined' && ["on", "yes","On", "Yes", true].includes(optionsArray[i][1].active)) 50 curOptions[optionsArray[i][0]].active=true; 51 if(typeof optionsArray[i][1].speed !== 'undefined' && 0<=optionsArray[i][1].speed<=10) 52 curOptions[optionsArray[i][0]].speed=optionsArray[i][1].speed; 53 if(typeof optionsArray[i][1].direction !== 'undefined' && ['in','out','up','down'].includes(optionsArray[i][1].direction)) 54 curOptions[optionsArray[i][0]].direction=optionsArray[i][1].direction; 55 } 56 } 57 } 58 } 59 function createInnerDiv(){ 60 var conteinerDiv = document.createElement('div'); 61 conteinerDiv.classList.add("tenweb-elementor-scrolling-effects-container"); 62 var layerDiv = document.createElement('div'); 63 layerDiv.classList.add("tenweb-elementor-scrolling-effects-layer"); 64 65 var style = element.currentStyle || window.getComputedStyle(element, null); 66 67 layerDiv.style.backgroundImage = style.backgroundImage; 68 layerDiv.style.backgroundPosition = style.backgroundPosition; 69 layerDiv.style.backgroundRepeat = style.backgroundRepeat; 70 layerDiv.style.backgroundSize = style.backgroundSize; 71 72 conteinerDiv.appendChild(layerDiv); 73 element.prepend(conteinerDiv); 74 return layerDiv; 75 } 76 } 77 78 tenwebParallax.prototype = { 79 vertical_transform:function(){ 80 if(this.options.vertical_scroll.active){ 81 this.layerDiv.style.height = (100 + this.options.vertical_scroll.speed * 100 / 10) + "%"; 82 if(this.isElementVisible()){ 83 var center = this.element.offsetHeight * this.options.vertical_scroll.speed / 2 / 10; 84 var backgroundScrolled = - (window.scrollY + window.innerHeight - this.element.offsetTop) * this.options.vertical_scroll.speed / 4 / 10; 85 if(this.options.vertical_scroll.direction == 'down') 86 backgroundScrolled = - backgroundScrolled; 87 return "translateY(calc(-" + center + "px + " + backgroundScrolled + "px))"; 88 }else{ 89 return ''; 90 } 91 } 92 return ''; 93 }, 94 horizontal_transform:function(){ 95 if(this.options.horizontal_scroll.active){ 96 this.layerDiv.style.width = (100 + this.options.horizontal_scroll.speed * 100 / 10) + "%"; 97 if(this.isElementVisible()){ 98 var backgroundScrolled = (window.scrollY + window.innerHeight - this.element.offsetTop) * this.options.horizontal_scroll.speed/4 / 10; 99 var center = this.element.offsetWidth * this.options.horizontal_scroll.speed/ 2 / 10; 100 if(this.options.horizontal_scroll.direction == 'left') 101 backgroundScrolled = - backgroundScrolled; 102 return "translateX(calc(-" + center + "px + " + backgroundScrolled + "px))"; 103 }else{ 104 return ''; 105 } 106 } 107 return ''; 108 }, 109 transparency:function(){ 110 if(this.options.transparency.active){ 111 if(this.isElementVisible()){ 112 opacity_value = (window.scrollY + window.innerHeight - this.element.offsetTop) / (this.element.offsetHeight + window.innerHeight) 113 opacity_value = opacity_value*(this.options.transparency.speed/10); 114 if(this.options.transparency.direction == 'out') 115 opacity_value = 1 - opacity_value; 116 return opacity_value; 117 }else{ 118 return ''; 119 } 120 } 121 return ''; 122 }, 123 blur:function(){ 124 if(this.options.blur.active){ 125 if(this.isElementVisible()){ 126 blur_value = (window.scrollY + window.innerHeight - this.element.offsetTop) / (this.element.offsetHeight + window.innerHeight) 127 blur_value = blur_value * this.options.blur.speed; 128 if(this.options.blur.direction == 'out') 129 blur_value = 10 - blur_value; 130 return "blur(" + blur_value + "px)"; 131 }else{ 132 return ''; 133 } 134 } 135 return ''; 136 }, 137 scale:function(){ 138 if(this.options.scale.active){ 139 if(this.isElementVisible()){ 140 scale_value = (window.scrollY + window.innerHeight - this.element.offsetTop) / (this.element.offsetHeight + window.innerHeight) 141 scale_value = scale_value*(this.options.scale.speed)/10; 142 scale_value = scale_value+1; 143 if(this.options.scale.direction == 'out') 144 scale_value = 2 - scale_value; 145 return "scale(" + scale_value + ")"; 146 }else{ 147 return ''; 148 } 149 } 150 return ''; 151 }, 152 onScroll:function(){ 153 var transform_options = this.vertical_transform(); 154 transform_options += this.horizontal_transform(); 155 transform_options += this.scale(); 156 this.layerDiv.style.transform = transform_options; 157 this.layerDiv.style.opacity = this.transparency(); 158 this.layerDiv.style.filter = this.blur(); 159 160 }, 161 onResize:function(){ 162 var transform_options = this.vertical_transform(); 163 transform_options += this.horizontal_transform(); 164 transform_options += this.scale(); 165 this.layerDiv.style.transform = transform_options; 166 this.layerDiv.style.opacity = this.transparency(); 167 this.layerDiv.style.filter = this.blur(); 168 }, 169 changePosition:function(){ 170 171 }, 172 isElementVisible:function(){ 173 var ElementPositionInfo = this.element.getBoundingClientRect(); 174 if(ElementPositionInfo.top + ElementPositionInfo.height >= 0 && ElementPositionInfo.top <= (window.innerHeight || document.documentElement.clientHeight)) 175 return true; 176 return false;
177 }, 178 elementTopPosition:function(){ 179 return ; 180 }, 181 elementBottomPosition:function(){ 182 return ; 183 }, 184 185 addDisableBackgroundClass:function(){ 186 this.element.classList.add("tenweb-disable-background-image"); 187 }, 188 removeDisableBackgroundClass:function(){ 189 this.element.classList.remove("tenweb-disable-background-image"); 190 }, 191 start:function(){ 192 var self = this; 193 this.onScroll = this.onScroll.bind(this); 194 this.onResize = this.onResize.bind(this); 195 this.addDisableBackgroundClass(); 196 window.addEventListener('scroll',this.onScroll); 197 window.addEventListener('resize',this.onResize); 198 self.onResize(); 199 return this; 200 }, 201 destroy:function(){ 202 this.layerDiv.parentElement.remove(); 203 this.removeDisableBackgroundClass(); 204 window.removeEventListener('scroll',this.onScroll); 205 window.removeEventListener('resize',this.onResize); 206 } 207 } 208 209})(document,window);
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.