How to reproduce the effect on this website :
https://shop.stripe.com/
I mean waiting for the DOM to fully load before showing anything, and then having the background image zooming out for 1s. Pretty cool.
How to reproduce the effect on this website :
https://shop.stripe.com/
I mean waiting for the DOM to fully load before showing anything, and then having the background image zooming out for 1s. Pretty cool.
It's done using different transition and transforms together. Demo: http://jsfiddle.net/lotusgodkk/eHAuh/2/
Key is to add/remove classes in document.ready
HTML:
<div id="DIV_1" class="scaled"></div>
JS:
$(document).ready(function () {
$('#DIV_1').attr('class', 'animatable');
setTimeout(function () {
$('#DIV_1').removeClass('animatable');
}, 1000)
});
CSS:
#DIV_1 {
background-position: 50% 50%;
bottom: 0px;
height: 472px;
left: 0px;
position: absolute;
right: 0px;
top: 0px;
width: 600px;
z-index: 1;
background: rgba(0, 0, 0, 0) url(https://shop.stripe.com/assets/images/showcase/thairu-kat.jpg) no-repeat scroll 50% 50% / cover padding-box border-box;
font: normal normal normal 16px/normal Helvetica, Arial, sans-serif;
zoom:1.1;
background-size:cover;
}
/*#DIV_1*/
.animatable {
-webkit-transition:all 750ms ease-out;
transition:all 750ms ease-out;
}
.scaled {
-webkit-transform:scale(1.02);
transform:scale(1.02);
}
You can also do it easily with pure javascript:
css:
#blackdiv { background: black; color: white; position: fixed; width: 100%; height: 100%; }
html:
<div id="blackdiv"></div>
<div>page content</div>
js:
window.onload = function(){
var blackdiv = document.getElementById('blackdiv');
blackdiv.style.opacity = 1;
doIt();
};
var doIt = function(){
if( blackdiv.style.opacity > 0 ){
console.log(blackdiv.style.opacity);
blackdiv.style.opacity -= .1;
setTimeout("doIt()", 100);
}
}
Check jsFiddle