1/** 2 * main.js 3 * http://www.codrops.com 4 * 5 * Licensed under the MIT license. 6 * http://www.opensource.org/licenses/mit-license.php 7 * 8 * Copyright 2016, Codrops 9 * http://www.codrops.com 10 */ 11;(function(window) { 12 13 'use strict'; 14 15 // Helper vars and functions. 16 function extend(a, b) { 17 for(var key in b) { 18 if( b.hasOwnProperty( key ) ) { 19 a[key] = b[key]; 20 } 21 } 22 return a; 23 } 24 25 function createDOMEl(type, className, content) { 26 var el = document.createElement(type); 27 el.className = className || ''; 28 el.innerHTML = content || ''; 29 return el; 30 } 31 32 /** 33 * RevealFx obj. 34 */ 35 function RevealFx(el, options) { 36 this.el = el; 37 this.options = extend({}, this.options); 38 extend(this.options, options); 39 this.content = null; 40 this.revealer = null; 41 this._init(); 42 } 43 44 /** 45 * RevealFx options. 46 */ 47 RevealFx.prototype.options = { 48 // If true, then the content will be hidden until it´s "revealed". 49 isContentHidden: true, 50 // The animation/reveal settings. This can be set initially or passed when calling the reveal method. 51 revealSettings: { 52 // Animation direction: left right (lr) || right left (rl) || top bottom (tb) || bottom top (bt). 53 direction: 'lr', 54 // Revealer´s background color. 55 bgcolor: '#f0f0f0', 56 // Animation speed. This is the speed to "cover" and also "uncover" the element (seperately, not the total time). 57 duration: 500, 58 // Animation easing. This is the easing to "cover" and also "uncover" the element. 59 easing: 'easeInOutQuint', 60 // percentage-based value representing how much of the area should be left covered. 61 coverArea: 0, 62 // Callback for when the revealer is covering the element (halfway through of the whole animation). 63 onCover: function(contentEl, revealerEl) { return false; }, 64 // Callback for when the animation starts (animation start). 65 onStart: function(contentEl, revealerEl) { return false; }, 66 // Callback for when the revealer has completed uncovering (animation end). 67 onComplete: function(contentEl, revealerEl) { return false; } 68 } 69 }; 70 71 /** 72 * Init. 73 */ 74 RevealFx.prototype._init = function() { 75 this._layout(); 76 }; 77 78 /** 79 * Build the necessary structure. 80 */ 81 RevealFx.prototype._layout = function() { 82 if (!this.el) return 83 84 var position = getComputedStyle(this.el).position; 85 if( position !== 'fixed' && position !== 'absolute' && position !== 'relative' ) { 86 this.el.style.position = 'relative'; 87 } 88 89 if (!this.el.classList.contains('block-revealer')) { 90 91 if ( this.el.classList.contains('elementor-section') ) { 92 // Content element. 93 this.content = this.el.querySelector('.elementor-container'); 94 } else if ( this.el.dataset.element_type === 'container' ) { 95 // Content element. 96 var container = this.el.querySelector('.elementor-element'); 97 if ( container.dataset.element_type === 'container' ) { 98 this.content = container; 99 } else { 100 this.content = this.el.querySelector('.elementor-widget'); 101 } 102 103 } else { 104 // Content element. 105 this.content = this.el.querySelector('.elementor-widget-container'); 106 } 107 108 if (this.content) { 109 this.content.classList.add('block-revealer__content'); 110 if( this.options.isContentHidden) { 111 this.content.style.opacity = 0; 112 113 const nodelist = this.content.querySelectorAll(".elementor-element"); 114 115 for (let i = 0; i < nodelist.length; i++) { 116 nodelist[i].style.opacity = 0; 117 } 118 } 119 // Revealer element (the one that animates) 120 this.revealer = createDOMEl('div', 'block-revealer__element'); 121 this.el.classList.add('block-revealer'); 122 this.el.appendChild(this.content); 123 this.el.appendChild(this.revealer); 124 } 125 126 } else { 127 // Content element. 128 this.content = this.el.querySelector('.block-revealer__content'); 129 if (this.content) { 130 if( this.options.isContentHidden) { 131 this.content.style.opacity = 0; 132 } 133 // Revealer element (the one that animates) 134 this.revealer = this.el.querySelector('.block-revealer__element'); 135 } else { 136 this.content = this.el.querySelector('.elementor-widget-container'); 137 138 if (this.content) { 139 this.content.classList.add('block-revealer__content'); 140 if( this.options.isContentHidden) { 141 this.content.style.opacity = 0; 142 } 143 // Revealer element (the one that animates) 144 this.revealer = createDOMEl('div', 'block-revealer__element'); 145 this.el.classList.add('block-revealer'); 146 // this.el.appendChild(this.content); 147 this.el.appendChild(this.revealer); 148 } 149 } 150 } 151 }; 152 153 /** 154 * Gets the revealer element´s transform and transform origin. 155 */ 156 RevealFx.prototype._getTransformSettings = function(direction) { 157 var val, origin, origin_2; 158 159 switch (direction) { 160 case 'lr' : 161 val = 'scale3d(1,1,1)'; 162 origin = '0 50%'; 163 origin_2 = '100% 50%'; 164 break; 165 case 'rl' : 166 val = 'scale3d(1,1,1)'; 167 origin = '100% 50%'; 168 origin_2 = '0 50%'; 169 break; 170 case 'tb' : 171 val = 'scale3d(1,1,1)'; 172 origin = '50% 0'; 173 origin_2 = '50% 100%'; 174 break; 175 case 'bt' : 176 val = 'scale3d(1,1,1)'; 177 origin = '50% 100%'; 178 origin_2 = '50% 0'; 179 break; 180 default : 181 val = 'scale3d(1,1,1)'; 182 origin = '0 50%'; 183 origin_2 = '100% 50%'; 184 break; 185 }; 186 187 return { 188 // transform value. 189 val: val, 190 // initial and halfway/final transform origin. 191 origin: {initial: origin, halfway: origin_2}, 192 }; 193 }; 194 195 /** 196 * Reveal animation. If revealSettings is passed, then it will over
196write the options.revealSettings. 197 */ 198 RevealFx.prototype.reveal = function(revealSettings) { 199 // Do nothing if currently animating. 200 if( this.isAnimating ) { 201 return false; 202 } 203 this.isAnimating = true; 204 205 // Set the revealer element´s transform and transform origin. 206 var defaults = { // In case revealSettings is incomplete, its properties deafault to: 207 duration: 500, 208 easing: 'easeInOutQuint', 209 delay: 0, 210 bgcolor: '#f0f0f0', 211 direction: 'lr', 212 coverArea: 0 213 }, 214 revealSettings = revealSettings || this.options.revealSettings, 215 direction = revealSettings.direction || defaults.direction, 216 transformSettings = this._getTransformSettings(direction); 217 218 if ( this.revealer ) { 219 this.revealer.style.WebkitTransform = this.revealer.style.transform = transformSettings.val; 220 this.revealer.style.WebkitTransformOrigin = this.revealer.style.transformOrigin = transformSettings.origin.initial; 221 222 // Set the Revealer´s background color. 223 // this.revealer.style.backgroundColor = revealSettings.bgcolor || defaults.bgcolor; 224 225 // Show it. By default the revealer element has opacity = 0 (CSS). 226 this.revealer.style.opacity = 1; 227 } 228 229 // Animate it. 230 var self = this, 231 // Second animation step. 232 animationSettings_2 = { 233 complete: function() { 234 self.isAnimating = false; 235 if( typeof revealSettings.onComplete === 'function' ) { 236 revealSettings.onComplete(self.content, self.revealer); 237 } 238 } 239 }, 240 // First animation step. 241 animationSettings = { 242 delay: revealSettings.delay || defaults.delay, 243 complete: function() { 244 if (self.revealer) { 245 self.revealer.style.WebkitTransformOrigin = self.revealer.style.transformOrigin = transformSettings.origin.halfway; 246 if( typeof revealSettings.onCover === 'function' ) { 247 revealSettings.onCover(self.content, self.revealer); 248 } 249 anime(animationSettings_2); 250 } 251 } 252 }; 253 254 animationSettings.targets = animationSettings_2.targets = this.revealer; 255 animationSettings.duration = animationSettings_2.duration = revealSettings.duration || defaults.duration; 256 animationSettings.easing = animationSettings_2.easing = revealSettings.easing || defaults.easing; 257 258 var coverArea = revealSettings.coverArea || defaults.coverArea; 259 if( direction === 'lr' || direction === 'rl' ) { 260 animationSettings.scaleX = [0,1]; 261 animationSettings_2.scaleX = [1,coverArea/100]; 262 } 263 else { 264 animationSettings.scaleY = [0,1]; 265 animationSettings_2.scaleY = [1,coverArea/100]; 266 } 267 268 if( typeof revealSettings.onStart === 'function' ) { 269 revealSettings.onStart(self.content, self.revealer); 270 } 271 anime(animationSettings); 272 }; 273 274 window.RevealFx = RevealFx; 275 276})(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.