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 is required to process package imports. If you need a different preprocessor remove all packages first.

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

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 Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

HTML

              
                <link href="https://fonts.googleapis.com/css?family=Roboto+Condensed:400,700" rel="stylesheet">

<div class="load"></div>

<header class="header">
    <p>ARCHY</p>
    <div class="menu"></div>
</header>

<div class="canvasWrap">
    <canvas id="canvas"></canvas>
</div>

<div class="images">
    <img width="200" id="image1" src="https://alikinvv.github.io/square-slider/build/img/img1.jpg" alt="">
    <img width="200" id="image2" class="active" src="https://alikinvv.github.io/square-slider/build/img/img2.jpg" alt="">
    <img width="200" id="image3" src="https://alikinvv.github.io/square-slider/build/img/img3.jpg" alt="">
    <img width="200" id="image4" src="https://alikinvv.github.io/square-slider/build/img/img4.jpg" alt="">
</div>

<div class="captions">
    <div class="caption show">
        <p class="count">26</p>
        <div class="buttonWrap"><a href="#" class="button">Architecture</a></div>
        <div class="titleWrap"><p class="title">Marine Centre</p></div>
        <div class="locWrap"><p class="loc">Auckland, New Zealand</p></div>
    </div>
    <div class="caption">
        <p class="count">12</p>
        <div class="buttonWrap"><a href="#" class="button">Architecture</a></div>
        <div class="titleWrap"><p class="title">Musée du Louvre</p></div>
        <div class="locWrap"><p class="loc">Paris, France</p></div>
    </div>
    <div class="caption">
        <p class="count">06</p>
        <div class="buttonWrap"><a href="#" class="button">Architecture</a></div>
        <div class="titleWrap"><p class="title">Arc de Triomphe</p></div>
        <div class="locWrap"><p class="loc">Paris, France</p></div>
    </div>
    <div class="caption">
        <p class="count">18</p>
        <div class="buttonWrap"><a href="#" class="button">Architecture</a></div>
        <div class="titleWrap"><p class="title">Sofia</p></div>
        <div class="locWrap"><p class="loc">Bulgaria</p></div>
    </div>
</div>

<!-- github  -->
<a href="https://github.com/alikinvv/square-slider" target="_blank" class="github-corner" aria-label="View source on GitHub"><svg width="80" height="80" viewBox="0 0 250 250" style="fill:#151513; color:#fff; position: absolute; top: 0; border: 0; right: 0;" aria-hidden="true"><path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path><path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path><path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" fill="currentColor" class="octo-body"></path></svg></a><style>.github-corner:hover .octo-arm{animation:octocat-wave 560ms ease-in-out}@keyframes octocat-wave{0%,100%{transform:rotate(0)}20%,60%{transform:rotate(-25deg)}40%,80%{transform:rotate(10deg)}}@media (max-width:500px){.github-corner:hover .octo-arm{animation:none}.github-corner .octo-arm{animation:octocat-wave 560ms ease-in-out}}</style>
              
            
!

CSS

              
                body {
	overflow-x: hidden;
	font-family: 'Roboto Condensed', sans-serif;
	color: #fff;
	height: 880px;
	position: relative;
}

a {
	color: #fff;
}

.canvasWrap {
	position: relative;	
	overflow: hidden;
}

.images {
	display: none;
}

.load {
	width: 0;
	height: 8px;
	background: #fff;
	position: absolute;
	top: 0;
	left: 0;
	z-index: 20;
}

.header {
	position: absolute;
	width: 100%;
	top: 0;
	left: 0;
	z-index: 20;
	padding: 50px 5%;
	p {
		font-size: 30px;
		font-weight: bold;
	}
	.menu {
		position: absolute;
		right: 5%;
		top: 46%;
		transform: translateY(-50%);
		z-index: 20;
		width: 35px;
		height: 35px;
		&:before, &:after {
			content: '';
			position: absolute;
			left: 0;
			width: 100%;
			height: 2px;
			background: #fff;
		}
		&:before {			
			top: 12px;		
		}
		&:after {
			top: 21px;
		}
	}
}

.captions {
	position: absolute;
	bottom: 5%;
	left: 5%;
	z-index: 20;
	color: #fff;
	width: 100%;
	height: 200px;
	overflow: hidden;
	.count {
		font-size: 200px;
		font-weight: bold;
		margin: 0;
		float: left;
		margin-right: 35px;
		line-height: 1;
	}
	.title {
		font-size: 70px;
		font-weight: bold;
		letter-spacing: 5px;
		line-height: 1;
	}
	.loc {
		color: #ccc;
		letter-spacing: 2px;
		font-size: 16px;
		line-height: 1;
	}
	.buttonWrap {
		padding-top: 29px;
		overflow: hidden;
	}
	.titleWrap {
		margin-top: 14px;
		overflow: hidden;
	}
	.locWrap {
		overflow: hidden;
	}
}

.caption {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
}


.button {
	background: #fff;
	color: #333;
	display: inline-block;
	padding: 6px 29px;
	text-decoration: none;
	&:hover, &:focus {
		text-decoration: none;
		color: #333;
	}
}

.read {
	position: absolute;
	right: 5%;
	bottom: 7%;
	color: #fff;
	font-weight: bold;
	font-size: 20px;	
	z-index: 30;
	&:before {
		content: '';
		right: -25px;
		position: absolute;
		left: -25px;
		bottom: -10px;
		height: 1px;
		background: #fff;
		transition: all .4s ease-in-out;
	}
	&:hover, &:focus {
		color: #fff;
		text-decoration: none;
		&:before {
			left: -40px;
			right: -40px;
		}
	}
}
              
            
!

JS

              
                let settings = {};
settings.cols = 20;
settings.rows = 20;
let canvas =jQuery('#canvas')[0];
let context = canvas.getContext('2d');
let toggle1 = jQuery('#image1')[0];
let toggle2 = jQuery('#image2')[0];
let image11 = jQuery('#image1')[0];
let image2 = jQuery('#image2')[0];
let image3 = jQuery('#image3')[0];
let image4 = jQuery('#image4')[0];
let newcanvas = jQuery('<canvas></canvas>')[0];
let newcontext = newcanvas.getContext('2d');
let state = {pos:0};
let xw,xh,delay;
let windowW = $(window).width();
let windowH = 880;

let tl = new TimelineMax();
let tlLoad = new TimelineMax();
let tlText = new TimelineMax();
let scaleFrom = 1.2;

var autoplay = 5000;

tlText.to($('.count, .title, .loc'), 0, {y: '-100%'})
        .to($('.button'), 0, {y: '-200%'})
        .to($('.show .count'), 1, {ease: Power2.easeInOut, y: '0%'})
        .to($('.show .button'), 1, {ease: Power2.easeInOut, y: '0%'}, '-=0.9')
        .to($('.show .title, .show .loc'), 1, {ease: Power2.easeInOut, y: '0%'}, '-=0.8')
        .to($('.show .count, .show .title, .show .loc, .show .button'), 1, {ease: Power2.easeInOut, y: '170%'}, '+=3');

function clamp(min,mid,max){
  return mid < min ? min : mid < max ? mid : max
}
function setCanvasSize(canvas) {
    canvas.width = windowW;
    canvas.height = windowH;    
    $(canvas).css('width', windowW);
    $(canvas).css('height', windowH);
}

setCanvasSize(canvas);
setCanvasSize(newcanvas);

function RenderTempCanvas() {
    newcontext.clearRect(0,0,windowW,windowH);
    newcontext.drawImage(toggle2, 0,0);
    xw = windowW/settings.cols;
    xh = windowH/settings.rows;
    for (var i = 0; i<=settings.cols; i++) {
        for (var j = 0; j<=settings.rows; j++) {
            delay = (j*i)/(settings.cols*settings.rows);
            newcontext.clearRect(i*xw,j*xh,xw*clamp(state.pos -delay,0,1),xh*clamp(state.pos - delay,0,1));
        }
    }
}

function render(imageT) {
    context.clearRect(0,0,windowW,windowH);
    context.drawImage(imageT, 0,0);
    RenderTempCanvas();
    context.drawImage(newcanvas, 0,0);    
}


function draw() {
    render(toggle1);
    window.requestAnimationFrame(draw);
}

draw();
load();

setInterval(function() {
    Toggle()
    load();   
}, autoplay);

function load() {
    tlLoad.to($('.load'), autoplay / 1000, {ease: Power2.easeInOut, width: '100%'})
    .to($('.load'), 0, {width: 0});
}

function Toggle(){

    

    if($('.caption.show').is(':last-child')) {
        $('.caption.show').removeClass('show');
        $('.captions .caption:first-child').addClass('show');
    } else {
        $('.caption.show').removeClass('show').next().addClass('show');
    }
    
    tlText.to($('.count, .title, .loc'), 0, {y: '-100%'})
        .to($('.button'), 0, {y: '-200%'})
        .to($('.show .count'), 1, {ease: Power2.easeInOut, y: '0%'})
        .to($('.show .button'), 1, {ease: Power2.easeInOut, y: '0%'}, '-=0.9')
        .to($('.show .title, .show .loc'), 1, {ease: Power2.easeInOut, y: '0%'}, '-=0.8')
        .to($('.show .count, .show .title, .show .loc, .show .button'), 1, {ease: Power2.easeInOut, y: '170%'}, '+=2.8')

    if(state.pos===2) {
        tl.to(state, 2, {pos: 0, ease: Power1.easeOut});
        //tl.fromTo(canvas, 3, {scale: scaleFrom}, {scale: 1, delay: -1.7,ease: Expo.easeOut} )
        //tl.to(newcanvas, 0, {scale: 1, delay: 1});
    } else{
        tl.to(state, 2, {pos: 2, ease: Power1.easeOut});
        //tl.fromTo(canvas, 3, {scale: scaleFrom}, {scale: 1, delay: -1.7,ease: Expo.easeOut} )
        //tl.to(canvas, 0, {scale: 1, delay: 1});        
    }

    if($('#image2').hasClass('active')) {
        $('#image2').removeClass('active');
        $('#image3').addClass('active');
        toggle1 = image3;
    } else if($('#image3').hasClass('active')) {
        $('#image3').removeClass('active');
        $('#image4').addClass('active');
        toggle2 = image4;
    } else if($('#image4').hasClass('active')) {
        $('#image4').removeClass('active');
        $('#image1').addClass('active');
        toggle1 = image1;
    } else if($('#image1').hasClass('active')) {
        $('#image1').removeClass('active');
        $('#image2').addClass('active');
        toggle2 = image2;
    }
}
              
            
!
999px

Console