PK ̜'U split-image-in-tiles/README.mdUT 1c# Split image in tiles
A Pen created on CodePen.io. Original URL: [https://codepen.io/supah/pen/ayOjop](https://codepen.io/supah/pen/ayOjop).
PKpY PK ̜'U split-image-in-tiles/LICENSE.txtUT 1cThe MIT License (MIT)
Copyright (c) 2022 by Fabio Ottaviani (https://codepen.io/supah/pen/ayOjop)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.PKJb b PK ̜'U # split-image-in-tiles/src/index.htmlUT 1c
PKPBS PK ̜'U # split-image-in-tiles/src/style.scssUT 1c*, *:before, *:after {
box-sizing: border-box;
}
html, body {
height: 100%;
overflow: hidden;
background: #000;
}
.split {
width: 750px;
height: 468px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
perspective: 400px;
cursor: pointer;
&:before {
content: 'CLICK';
color: #777;
letter-spacing: 1px;
font-size: 10px;
position: absolute;
bottom: -30px;
left: 50%;
transform: translate(-50%);
}
img {
height: auto;
width: 100%;
opacity: 0;
}
div {
position: absolute;
z-index: 1;
background-repeat: no-repeat;
transform: rotateY(-50deg) scale(0.5);
opacity: 0;
transform-origin: bottom;
transition: all .6s cubic-bezier(.71, .05, .09, .91);
}
&.active {
div {
opacity: 1;
transform: rotate(0deg) translateY(0);
}
}
}
PKVop p PK ̜'U " split-image-in-tiles/src/script.jsUT 1cvar Split = function() {
this.$t = $(".split");
this.gridX = 6;
this.gridY = 4;
this.w = this.$t.width();
this.h = this.$t.height();
this.img = $("img", this.$t).attr("src");
this.delay = 0.05;
this.create = function() {
$("div", this.$t).remove();
for (x = 0; x < this.gridX; x++) {
for (y = 0; y < this.gridY; y++) {
var width = this.w / this.gridX * 101 / this.w + "%",
height = this.h / this.gridY * 101 / this.h + "%",
top = this.h / this.gridY * y * 100 / this.h + "%",
left = this.w / this.gridX * x * 100 / this.w + "%",
bgPosX = -(this.w / this.gridX * x) + "px",
bgPosY = -(this.h / this.gridY * y) + "px";
$("
")
.css({
top: top,
left: left,
width: width,
height: height,
backgroundImage: "url(" + this.img + ")",
backgroundPosition: bgPosX + " " + bgPosY,
backgroundSize: this.w + "px",
transitionDelay: x * this.delay + y * this.delay + "s"
})
.appendTo(this.$t);
}
}
};
this.create();
this.$t
.on("click", function() {
$(this).toggleClass("active");
})
.click();
};
window.onload = function() {
var split = new Split();
var gui = (function datgui() {
var gui = new dat.GUI();
gui.add(split, "gridX", 1, 20).step(1).onChange(function(newValue) {
split.create();
});
gui.add(split, "gridY", 1, 20).step(1).onChange(function(newValue) {
split.create();
});
gui.add(split, "delay", 0, 0.3).step(0.01).onChange(function(newValue) {
split.create();
});
return gui;
})();
};
PKxF PK ̜'U $ split-image-in-tiles/dist/index.htmlUT 1c
CodePen - Split image in tiles
PKܹr7 7 PK ̜'U # split-image-in-tiles/dist/style.cssUT 1c*, *:before, *:after {
box-sizing: border-box;
}
html, body {
height: 100%;
overflow: hidden;
background: #000;
}
.split {
width: 750px;
height: 468px;
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
perspective: 400px;
cursor: pointer;
}
.split:before {
content: "CLICK";
color: #777;
letter-spacing: 1px;
font-size: 10px;
position: absolute;
bottom: -30px;
left: 50%;
transform: translate(-50%);
}
.split img {
height: auto;
width: 100%;
opacity: 0;
}
.split div {
position: absolute;
z-index: 1;
background-repeat: no-repeat;
transform: rotateY(-50deg) scale(0.5);
opacity: 0;
transform-origin: bottom;
transition: all 0.6s cubic-bezier(0.71, 0.05, 0.09, 0.91);
}
.split.active div {
opacity: 1;
transform: rotate(0deg) translateY(0);
}PK0@ @ PK ̜'U # split-image-in-tiles/dist/script.jsUT 1cvar Split = function() {
this.$t = $(".split");
this.gridX = 6;
this.gridY = 4;
this.w = this.$t.width();
this.h = this.$t.height();
this.img = $("img", this.$t).attr("src");
this.delay = 0.05;
this.create = function() {
$("div", this.$t).remove();
for (x = 0; x < this.gridX; x++) {
for (y = 0; y < this.gridY; y++) {
var width = this.w / this.gridX * 101 / this.w + "%",
height = this.h / this.gridY * 101 / this.h + "%",
top = this.h / this.gridY * y * 100 / this.h + "%",
left = this.w / this.gridX * x * 100 / this.w + "%",
bgPosX = -(this.w / this.gridX * x) + "px",
bgPosY = -(this.h / this.gridY * y) + "px";
$("
")
.css({
top: top,
left: left,
width: width,
height: height,
backgroundImage: "url(" + this.img + ")",
backgroundPosition: bgPosX + " " + bgPosY,
backgroundSize: this.w + "px",
transitionDelay: x * this.delay + y * this.delay + "s"
})
.appendTo(this.$t);
}
}
};
this.create();
this.$t
.on("click", function() {
$(this).toggleClass("active");
})
.click();
};
window.onload = function() {
var split = new Split();
var gui = (function datgui() {
var gui = new dat.GUI();
gui.add(split, "gridX", 1, 20).step(1).onChange(function(newValue) {
split.create();
});
gui.add(split, "gridY", 1, 20).step(1).onChange(function(newValue) {
split.create();
});
gui.add(split, "delay", 0, 0.3).step(0.01).onChange(function(newValue) {
split.create();
});
return gui;
})();
};PKqq PK ̜'UpY split-image-in-tiles/README.mdUT 1cPK ̜'UJb b = split-image-in-tiles/LICENSE.txtUT 1cPK ̜'UPBS # split-image-in-tiles/src/index.htmlUT 1cPK ̜'UVop p # M split-image-in-tiles/src/style.scssUT 1cPK ̜'UxF " split-image-in-tiles/src/script.jsUT 1cPK ̜'Uܹr7 7 $ split-image-in-tiles/dist/index.htmlUT 1cPK ̜'U0@ @ # split-image-in-tiles/dist/style.cssUT 1cPK ̜'Uqq # : split-image-in-tiles/dist/script.jsUT 1cPK 1