// code for fade in one by one
console.log("game begins");
allSVGs = $("g");
fadeIn(0);
setTimeout(function () {
$("#cubeTop").attr({
transform:'translate(0,-140)'
})
}, 3000);
function fadeIn(svgIndex) {
console.log(svgIndex);
allSVGs.eq(svgIndex).css({
"display": "block",
"opacity": "0"
});
allSVGs.eq(svgIndex).animate({
"opacity": "1"
}, {
complete: function () {
svgIndex++;
if (svgIndex < allSVGs.length) //Making sure we don't exceed the maximum available SVG elements
fadeIn(svgIndex); //Recursively calling the next elements animation (hide) from the completed one.
},
duration: 400
});
}
svg {
position: absolute;
left: 0;
top: 0;
}
#cube {
fill: none;
stroke: black;
cursor: pointer;
display: none;
}
#cubeTop {
fill: none;
stroke: black;
cursor: pointer;
display: none;
}
#cubeTopRight {
fill: none;
stroke: red;
cursor: pointer;
display: none;
}
#cubeTopRightDown {
fill: none;
stroke: black;
cursor: pointer;
display: none;
}
#cubeDown {
fill: none;
stroke: red;
cursor: pointer;
display: none;
}
#cubeLeftDown {
fill: none;
stroke: black;
cursor: pointer;
display: none;
}
#cubeLeft {
fill: none;
stroke: red;
cursor: pointer;
display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script>
<svg height="100%" version="1.1" width="100%" xmlns="http://www.w3.org/2000/svg">
<g id="cube">
<path id="f1" d="M190,200L260,160L330,200L260,240L190,200"></path>
<path id="f2" d="M260,240L330,200L330,280L260,320L260,240"></path>
<path id="f3" d="M260,240L260,320L190,280L190,200L260,240"></path>
</g>
<g id="cubeTop" transform="translate(0, -80)">
<path id="t1" d="M190,200L260,160L330,200L260,240L190,200"></path>
<path id="t2" d="M260,240L330,200L330,280L260,320L260,240"></path>
<path id="t3" d="M260,240L260,320L190,280L190,200L260,240"></path>
</g>
<g id="cubeTopRight" transform="translate(70, -40)">
<path id="r1" d="M190,200L260,160L330,200L260,240L190,200"></path>
<path id="r2" d="M260,240L330,200L330,280L260,320L260,240"></path>
<path id="r3" d="M260,240L260,320L190,280L190,200L260,240"></path>
</g>
<g id="cubeTopRightDown" transform="translate(70, 40)">
<path id="rd1" d="M190,200L260,160L330,200L260,240L190,200"></path>
<path id="rd2" d="M260,240L330,200L330,280L260,320L260,240"></path>
<path id="rd3" d="M260,240L260,320L190,280L190,200L260,240"></path>
</g>
<g id="cubeDown" transform="translate(0, 80)">
<path id="cd1" d="M190,200L260,160L330,200L260,240L190,200"></path>
<path id="cd2" d="M260,240L330,200L330,280L260,320L260,240"></path>
<path id="cd3" d="M260,240L260,320L190,280L190,200L260,240"></path>
</g>
<g id="cubeLeftDown" transform="translate(-70, 40)">
<path id="ld1" d="M190,200L260,160L330,200L260,240L190,200"></path>
<path id="ld2" d="M260,240L330,200L330,280L260,320L260,240"></path>
<path id="ld3" d="M260,240L260,320L190,280L190,200L260,240"></path>
</g>
<g id="cubeLeft" transform="translate(-70, -40)">
<path id="l1" d="M190,200L260,160L330,200L260,240L190,200"></path>
<path id="l2" d="M260,240L330,200L330,280L260,320L260,240"></path>
<path id="l3" d="M260,240L260,320L190,280L190,200L260,240"></path>
</g>
</svg>