Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                
   <div id="middle-form">
   
      <h1>Play with the parameters!</h1>
      
      <p>number of slices (horizontally):</p>
         <span class="rangeValue"><span id="ix">5</span></span>
         <input type="range" name="x" min="1" max="20" value="5" onchange="setRange(this.name,this.value)" onclick="setRange(this.name,this.value)">
      
      <p>transition time of one slice (msec):</p>
         <span class="rangeValue"><span id="ispeed">750</span></span>
         <input type="range" name="speed" min="50" max="2000" value="750" step="10" onchange="setRange(this.name,this.value)" onclick="setRange(this.name,this.value)">

      <p>time between transitions (msec):</p>
         <span class="rangeValue"><span id="iseq">200</span></span>
         <input type="range" name="seq" min="0" max="1000" value="200" step="10" onchange="setRange(this.name,this.value)" onclick="setRange(this.name,this.value)">
      
      <p>effect:</p>
         <select onchange="effectChange(this);">
            <option value="1">effect 1</option>
            <option value="2">effect 2</option>
            <option value="3">effect 3</option>
            <option value="4">effect 4</option>
         </select> 

      <p>drop an image (*.png, *.jpg, *.gif) (web):</p>
         <div id="dropZone">
            <input type="text" id="dropContainer" ondrop="drop(event)" ondragover="allowDrop(event)" ondragenter="enterDrop(event)" ondragleave="leaveDrop(event)" />
            <img id="dropImage" onload="posDropImg(this)"></img>
         </div>
         
      <button onclick="startAnimation()">Start the animation!</button>

           <p>Remake of my previous pen <a class="ownlink" href="https://codepen.io/mesteradam/pen/EsLcC" target="_blank">Full screen transition animation</a>.</p>
   </div>
              
            
!

CSS

              
                @import url(https://fonts.googleapis.com/css?family=Roboto:300);

#wv-full-fill {
	position: fixed;
	width: 100%;
	height: 100%;
   z-index: 1;
}

/* site */
* {
   padding: 0;
   margin: 0;
   color: #191970;
}
#middle-form {
   font-family: 'Roboto',sans-serif;
   font-weight: 300;
}
#middle-form > h1, #middle-form > p, #middle-form > span  {
   text-align: center;
}
#middle-form > h1 {
   background-color: #3399FF;
   color: #FFFFFF;
}
#middle-form > p {
   margin: 30px 0 10px 0;
}
#middle-form > span > span {
   display: block;
   margin: 0 auto 0 auto;
   width: 80px;
   border: 1px solid #3399FF;
   transition: background-color 0.4s;
   cursor: default;
}
#middle-form > span > span:hover {
   background-color: #EEEEEE;
}
#middle-form > span:after {
   display: block;
   margin: 0 auto 5px auto;
   width: 0;
   height: 0;
   color: transparent;
   content: ".";
   border-left: 5px solid transparent;
   border-right: 5px solid transparent; 
   border-top: 5px solid #3399FF;
}
#middle-form > input[type="range"], #middle-form > label {
   display: block;
   margin: 0 auto 0 auto;
   width: 300px;
}
#middle-form > label {
   border: 1px solid #3399FF;
}

/* drag drop */
#dropZone {
   display: block;
   margin: 0 auto 0 auto;
   width: 300px;
   min-height: 168.75px;
   position: relative;
}
#dropContainer {
   border: 2px solid #3399FF;
   width: 300px;
   min-height: 168.75px;
   cursor: default;
   background-color: #FFFFFF;
   color: #FFFFFF;
   position: absolute;
   top: 0; left: 0;
}
#dropImage {
   max-width: 300px;
   max-height: 168.75px;
   position: absolute;
   top: 0; left: 0;
   border: 2px solid transparent;
}
select {
   width: 200px;
   margin: 0 auto 0 auto;
   display: block;
}

button {
   display: block;
   margin: 40px auto 0px auto;
   padding: 0 20px 0 20px;
   height: 40px;
   font-size: 1.4em;
   font-family: 'Roboto',sans-serif;
   font-weight: 300;
   color: #FFFFFF;
   background-color: #3399FF;
   position: relative;
   border: none;
   transition: all 0.1s;
   cursor: pointer;
}
button:after {
   display: block;
   content: '';
   width: 100%;
   height: 4px;
   background-color: #336699;
   position: absolute;
   bottom: -4px;
   left: 0;
   transition: background-color 0.4s, height 0.1s, bottom 0.1s;
}
button:hover:after {
   background-color: #003366;
}
button:active {
   transform: translateY(4px);
}
button:active:after {
   height: 0px;
   bottom: 0px;
}

.rangeValue {
   position: relative;
   top: 5px;
}

              
            
!

JS

              
                
var wvAnimation = {
   nX			:	0,
   nSpeed	:	1,
   nSeq		:	0,
   oNegyzet	:	new Array(),
   nSum		:	0,
   nWidth   :  0,
   oBody		:	null,
   oFullFill:	null,
   oImg     :  new Image(),
   effect   :  0
}


setImage('https://blog.codepen.io/wp-content/uploads/2012/06/Button-Black-Large.png');
setTimeout(function(){
  startAnimation();
},1500);

/*
	"class" name 
		wvAnimation
	parameters
		nX			:	szeletek száma vízszintesen
		nSpeed	:	egy négyzet áttünési sebessége (msec)
		nSeq		:	két egymást követő áttünés megkezdése közti idő (msec)
      bCreate  :  ha true akkor letrehozza a full-fill div-et, egyebkent nem
      oImg     :  megjelenítendő kép (Image object)
      effect   :  effect number
		
	default parameters
		nX			=	6		(min:0,max:50)
		nSpeed	=	500	(min:1)
		nSeq		=	50		(min:0)
*/

function SquareFadeAnimation(nX,nSpeed,nSeq,bCreate) {	
   
   wvAnimation.oNegyzet	= new Array();
   
   // speed
	if(nSpeed===undefined) {				// ha nincs megadva, vagy 0, akkor 500
		wvAnimation.nSpeed = 500;
	} else { wvAnimation.nSpeed = nSpeed; }
   
   // seq
	if(nSeq===undefined) {					// ha nincs megadva, akkor 40
		wvAnimation.nSeq = 50;
	} else { wvAnimation.nSeq = nSeq; }

   // nX
	if(nX===undefined || nX>50) {		   // negyzetek szama x tengelyen
		wvAnimation.nX = 6;
	} else { wvAnimation.nX = nX; }

   wvAnimation.oBody = document.body;
   
   // create?!
   if( bCreate===undefined || bCreate===false ) {
      wvAnimation.oFullFill = document.getElementById("wv-full-fill");
   } else {
      oWvFullFill = document.createElement("div");
      oWvFullFill.setAttribute("id","wv-full-fill");
      document.body.insertBefore(oWvFullFill,document.body.childNodes[0]);
      wvAnimation.oFullFill = document.getElementById("wv-full-fill");
   }
   
   start();
}

function start(){
	var nWidth = wvAnimation.oFullFill.offsetWidth;
	var nHeight = wvAnimation.oFullFill.offsetHeight;
	var nSzelesseg = Math.round(nWidth/wvAnimation.nX+0.5);// negyzetek szelessege
	var nY = Math.round(nHeight/nSzelesseg+0.5);		// negyzetek szama y tengelyen
	var oTemp, i, j;
	wvAnimation.nSum = wvAnimation.nX * nY;			// negyzetek szama
	wvAnimation.nWidth = nSzelesseg;                // negyzetek szelessege
   
   /* Image positioning */
   var nImgWidth = wvAnimation.oImg.width;
   var nImgHeight = wvAnimation.oImg.height;
   // szelesseghez igazitas
   if( nImgWidth > nWidth ) {
      var nArany = nWidth / nImgWidth;
      wvAnimation.oImg.width = nWidth;
      wvAnimation.oImg.height = nImgHeight * nArany;
   }
   
   nImgWidth = wvAnimation.oImg.width;
   nImgHeight = wvAnimation.oImg.height;
   // magassaghoz hasonlitas
   if( nImgHeight > nHeight ) {
      var nArany = nHeight / nImgHeight;
      wvAnimation.oImg.width = nImgWidth * nArany;
      wvAnimation.oImg.height = nHeight;
   }
   
   var nImgXPoz = (nWidth - wvAnimation.oImg.width) / 2
   var nImgYPoz = (nHeight - wvAnimation.oImg.height) / 2
   
   var nXPos = 0, nYPos = 0;
   
   
	for( i=0; i<nY; i++ ) {
		for( j=0; j<wvAnimation.nX; j++ ) {
			oTemp=document.createElement("div");
			oTemp.style.position = "fixed";
			oTemp.style.width = nSzelesseg + "px";
			oTemp.style.height = nSzelesseg + "px";
			oTemp.style.backgroundColor = "#aaaaaa";
			oTemp.style.backgroundImage = "url("+wvAnimation.oImg.src+")";
         oTemp.style.backgroundSize = wvAnimation.oImg.width + "px " + wvAnimation.oImg.height + "px";
         oTemp.style.backgroundRepeat="no-repeat";
			oTemp.style.left = j*nSzelesseg + "px";
			oTemp.style.top = i*nSzelesseg + "px";
         oTemp.style.backgroundPosition = (nImgXPoz - (j*nSzelesseg)) + "px " + (nImgYPoz - (i*nSzelesseg)) + "px";
         oTemp.style.transition = "all " + (wvAnimation.nSpeed/1000) + "s";
			wvAnimation.oNegyzet.push(oTemp);
		}
	}
	
   
	wvAnimation.oNegyzet.arrayRandomizer();
	for( i = 0; i < wvAnimation.nSum; i++ ) {
		wvAnimation.oFullFill.appendChild(wvAnimation.oNegyzet[i]);
	}
   
	wvAnimation.oFullFill.style.backgroundColor = "transparent";
   wvAnimation.oFullFill.style.backgroundImage = "";
	
   linearCSSAnimation( );
};



function linearCSSAnimation( ) {	
   switch (wvAnimation.effect) {
    case 0:
      wvAnimation.oNegyzet[--wvAnimation.nSum].style.transform = "perspective("+ wvAnimation.nWidth*2 +"px) rotateX(90deg)";
      wvAnimation.oNegyzet[wvAnimation.nSum].style.opacity = "0.5";
      break;
    case 1:
      wvAnimation.oNegyzet[--wvAnimation.nSum].style.transform = "translateX(" + wvAnimation.nWidth*2 + "px)";
      wvAnimation.oNegyzet[wvAnimation.nSum].style.opacity = "0";
      break;
    case 2:
      wvAnimation.oNegyzet[--wvAnimation.nSum].style.transform = "scale(2)";
      wvAnimation.oNegyzet[wvAnimation.nSum].style.opacity = "0";
      break;
    case 3:
      wvAnimation.oNegyzet[--wvAnimation.nSum].style.transform = "scale(0.5)";
      wvAnimation.oNegyzet[wvAnimation.nSum].style.opacity = "0";
      break;
   }
	
	if( wvAnimation.nSum !== 0 ) {
		setTimeout(function(){
			linearCSSAnimation( );
		},wvAnimation.nSeq);
   } else {
		setTimeout(function(){
			wvAnimation.oBody.removeChild(wvAnimation.oFullFill);
		},wvAnimation.nSpeed);
		return false;
	}
};



// arrarRandomizer() fuggveny array-ekhez
Array.prototype.arrayRandomizer=function() {
	var len = this.length, x, temp;
	if ( len === 0 ) return false;
	while ( --len ) {
		x = Math.floor( Math.random() * len );
		temp = this[len];
		this[len] = this[x]; 
		this[x] = temp;
	}
};



/*
   form   
*/

function startAnimation() {
   var nX = document.getElementsByName("x")[0].value;
   var nSpeed = document.getElementsByName("speed")[0].value;
   var nSeq = document.getElementsByName("seq")[0].value;
   
   SquareFadeAnimation(nX,nSpeed,nSeq,true);
}

function setRange(cName, nValue) {
   var textbox = document.getElementById("i"+cName);
   textbox.innerHTML = ""+nValue;
}

function setImage(cImg) {
   var preloader = document.getElementById("bgPreloaderDiv");
   if (preloader == null) {
      preloader = document.createElement("div");
      preloader.setAttribute("id","bgPreloaderDiv");
      document.body.insertBefore(preloader,document.body.childNodes[0]);
   }
   preloader.style.width = "0px";
   preloader.style.height = "0px";
   preloader.style.position = "fixed";
   preloader.style.opacity = "0";
   preloader.style.backgroundImage = "url(" + cImg + ")";
   wvAnimation.oImg = new Image();
   wvAnimation.oImg.src = cImg;
}


function allowDrop(ev) {
   ev.preventDefault();
   ev.target.style.border = "2px dashed #3399FF";
}

function drop(ev) {
   var url = ev.dataTransfer.getData("text");
   var kit = url.substr(url.length-3,3);
   if( kit == "jpg" || kit == "png" || kit == "gif" ) {
      ev.target.style.border = "2px solid #3399FF";
      var dropImg = document.getElementById("dropImage");
      dropImg.src = url;
      setImage(url);
   } else
      ev.target.style.border = "2px solid red";
}

function posDropImg(o) {
   o.style.left = ((300 - o.width) / 2) + "px";
}

function enterDrop(ev) {
   ev.preventDefault();
   ev.target.style.border = "2px dashed #3399FF";
}

function leaveDrop(ev) {
   ev.preventDefault();
   ev.target.style.border = "2px solid #3399FF";
}

function effectChange(o) {
   wvAnimation.effect = o.selectedIndex
}

/*
   form vege
*/
              
            
!
999px

Console