;(function(window) { 'use strict'; // Helper vars and functions. function extend(a, b) { for(var key in b) { if( b.hasOwnProperty( key ) ) { a[key] = b[key]; } } return a; } function createDOMEl(type, className,content) { var el = document.createElement(type); el.className = className || ''; el.innerHTML = content || ''; return el; } function createStyleForDOMEL(el,position,top,left,width,height,color,background,opacity,pointerEvents,zIndex) { //this is a helper function for creating the styles for a given element el.style.position = position || 'absolute'; el.style.top = top || '0'; el.style.left = left || '0'; el.style.color = color || '#fff'; el.style.width = width || '100%'; el.style.height = height || '100%'; el.style.backgroundColor = background || '#f0f0f0'; el.style.opacity = opacity || '0'; el.style.pointerEvents = pointerEvents || 'none'; el.style.zIndex = zIndex || 0; } /** * RevealFx obj. */ function RevealFx(el, options) { this.el = el; this.revealLayers = []; this.options = extend({}, this.options); extend(this.options, options); this._init(); } /** * RevealFx options. */ RevealFx.prototype.options = { // If true, then the content will be hidden until it´s "revealed". isContentHidden: true, //number of layers to be displayed layers:1, // The animation/reveal settings. This can be set initially or passed when calling the reveal method. revealSettings: { // Animation direction: left right (lr) || right left (rl) || top bottom (tb) || bottom top (bt). direction: 'lr', // Revealers´s background color Array. bgColors: ['#111'], // Animation speed. This is the speed to "cover" and also "uncover" the element (seperately, not the total time). duration: 500, // Animation easing. This is the easing to "cover" and also "uncover" the element. easing: 'easeInOutQuint', // percentage-based value representing how much of the area should be left covered. coverArea: 0, //milliseconds of delay between layers animation thatis used in stagger animation delay:100, // Callback for when the revealer is covering the element (halfway through of the whole animation) onHalfway: function(contentEl, revealerEl) { return false; }, // Callback for when the animation starts (animation start). onStart: function(contentEl, revealerEl) { return false; }, // Callback for when the revealer has completed uncovering (animation end). onComplete: function(contentEl, revealerEl) { return false; }, } }; /** * Init. */ RevealFx.prototype._init = function() { this._layout(); }; /** * Build the necessary structure. */ RevealFx.prototype._layout = function() { //instead of going with the %s go with the pxs for the better view //create an array of the selected elements and store it as global var position = getComputedStyle(this.el).position; if( position !== 'fixed' && position !== 'absolute' && position !== 'relative' ) { this.el.style.position = 'relative'; } var heightOfEl = 100; var widthOfEl = 100; // Content element. this.content = createDOMEl('div', 'block-revealer__content',this.el.innerHTML); if( this.options.isContentHidden) { this.content.style.opacity = 0; } this.el.innerHTML = ''; this.el.appendChild(this.content); var topOfRevealerElement=0; var leftOfRevalerElement=0; const numberOfLayers = this.options.layers; var colorOfBlockLayer ='#111'; for(var i=0;i