Compare commits
10 Commits
2bd1f6eaff
...
03117344a5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
03117344a5 | ||
|
|
87efc8d355 | ||
|
|
9aa449c61c | ||
|
|
564580db40 | ||
|
|
51afd353df | ||
|
|
3ea1bc2762 | ||
|
|
615342a55b | ||
|
|
6c1ea34570 | ||
|
|
e86f1afb2f | ||
|
|
d82aeb744b |
160
css/style.css
160
css/style.css
@@ -1,10 +1,17 @@
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
|
||||
html, body {
|
||||
height: 100%;
|
||||
min-height: 100%;
|
||||
overflow: hidden;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
body {
|
||||
background-color: #0e0e0e;
|
||||
height: 100vh;
|
||||
margin: 0;
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
@@ -12,40 +19,47 @@ body {
|
||||
}
|
||||
|
||||
.background {
|
||||
background-color: #0e0e0e;
|
||||
background-image: repeating-linear-gradient(135deg, #000, #19191a 1%, transparent 1.5%, transparent 50% );
|
||||
background-color: #0e0e0e;
|
||||
background-image: repeating-linear-gradient(
|
||||
135deg,
|
||||
#000,
|
||||
#19191a 1%,
|
||||
transparent 1.5%,
|
||||
transparent 50%
|
||||
);
|
||||
background-size: 100px 100px;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
animation: fade-in 2500ms ease-out forwards 1s;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
animation: fade-in 2750ms ease-out forwards;
|
||||
opacity: 0;
|
||||
}
|
||||
|
||||
.card {
|
||||
display: block;
|
||||
position: relative;
|
||||
width: 420px;
|
||||
display: block;
|
||||
position: relative;
|
||||
max-width: 420px;
|
||||
width: 80%;
|
||||
height: 260px;
|
||||
color: #fff;
|
||||
flex: none;
|
||||
perspective: 1000px;
|
||||
color: #fff;
|
||||
flex: none;
|
||||
perspective: 1000px;
|
||||
}
|
||||
|
||||
.card__figure {
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
position: relative;
|
||||
background: #111;
|
||||
border-radius: 2px;
|
||||
margin: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
position: relative;
|
||||
background: #111;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.card__figure::before {
|
||||
content: '';
|
||||
content: "";
|
||||
position: absolute;
|
||||
width: calc(100% - 14px);
|
||||
height: calc(100% - 14px);
|
||||
@@ -58,26 +72,32 @@ body {
|
||||
}
|
||||
|
||||
.card__deco {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
overflow: hidden;
|
||||
pointer-events: none;
|
||||
border-radius: 3px;
|
||||
}
|
||||
|
||||
.card__deco--shine div {
|
||||
position: absolute;
|
||||
width: 200%;
|
||||
height: 200%;
|
||||
top: -50%;
|
||||
left: -50%;
|
||||
background-image: linear-gradient(45deg, rgba(0, 0, 0, 0.9) 0%, rgba(200, 200, 200, 0.05) 50%, transparent 100%);
|
||||
position: absolute;
|
||||
width: 200%;
|
||||
height: 200%;
|
||||
top: -50%;
|
||||
left: -50%;
|
||||
background-image: linear-gradient(
|
||||
45deg,
|
||||
rgba(0, 0, 0, 0.9) 0%,
|
||||
rgba(200, 200, 200, 0.05) 50%,
|
||||
transparent 100%
|
||||
);
|
||||
}
|
||||
|
||||
figcaption {
|
||||
height: 100%;
|
||||
height: 100%;
|
||||
padding: 25px;
|
||||
color: #eee;
|
||||
font-family: Avenir;
|
||||
@@ -93,18 +113,66 @@ h1 {
|
||||
font-weight: 900;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
font-weight: 900;
|
||||
.links {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
font-weight: 900;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
a {
|
||||
color: #ddd;
|
||||
transition: color 100ms ease;
|
||||
height: 20px;
|
||||
}
|
||||
|
||||
a:hover {
|
||||
color: #eee;
|
||||
}
|
||||
|
||||
p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
svg {
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
border-radius: 3px;
|
||||
fill: currentColor;
|
||||
}
|
||||
|
||||
@keyframes fade-in {
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
0% {
|
||||
opacity: 0;
|
||||
}
|
||||
100% {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 430px) {
|
||||
.card {
|
||||
height: 450px;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 380px) {
|
||||
h1 {
|
||||
font-size: 2.8rem;
|
||||
line-height: 2.8rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 330px) {
|
||||
h1 {
|
||||
font-size: 2rem;
|
||||
line-height: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media screen and (max-width: 250px) {
|
||||
h1 {
|
||||
font-size: 1.3rem;
|
||||
line-height: 1.3rem;
|
||||
}
|
||||
}
|
||||
|
||||
68
index.html
68
index.html
@@ -2,40 +2,58 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
||||
<title>Travis Heinström</title>
|
||||
<meta name="description" content="" />
|
||||
<!-- Needs Favicon -->
|
||||
<meta name="description" content="The website of Travis Heinström" />
|
||||
|
||||
<link rel="stylesheet" type="text/css" href="./css/style.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div class="background"></div>
|
||||
|
||||
<main>
|
||||
<section class="content">
|
||||
<div class="card">
|
||||
<figure class="card__figure">
|
||||
<div class="card__deco card__deco--shine"><div></div></div>
|
||||
<figcaption>
|
||||
<h1>Travis <br/> Heinström</h1>
|
||||
<p>Things Here<br/>Things Here - Things here</p>
|
||||
</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<div class="card">
|
||||
<figure class="card__figure">
|
||||
<div class="card__deco card__deco--shine"><div></div></div>
|
||||
<figcaption>
|
||||
<h1>
|
||||
Travis <br />
|
||||
Heinström
|
||||
</h1>
|
||||
<div class="links">
|
||||
<span>travis@heinstrom.com</span>
|
||||
<a href="https://www.linkedin.com/in/heinstrom" target="_blank" title="Travis on LinkedIn">
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:xlink="http://www.w3.org/1999/xlink"
|
||||
version="1.1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
viewBox="0 0 455 455"
|
||||
xml:space="preserve"
|
||||
>
|
||||
<path
|
||||
style="fill-rule: evenodd; clip-rule: evenodd"
|
||||
d="M246.4,204.35v-0.665c-0.136,0.223-0.324,0.446-0.442,0.665H246.4z"
|
||||
></path>
|
||||
<path
|
||||
style="fill-rule: evenodd; clip-rule: evenodd"
|
||||
d="M0,0v455h455V0H0z M141.522,378.002H74.016V174.906h67.506V378.002z M107.769,147.186h-0.446C84.678,147.186,70,131.585,70,112.085c0-19.928,15.107-35.087,38.211-35.087 c23.109,0,37.31,15.159,37.752,35.087C145.963,131.585,131.32,147.186,107.769,147.186z M385,378.002h-67.524V269.345 c0-27.291-9.756-45.92-34.195-45.92c-18.664,0-29.755,12.543-34.641,24.693c-1.776,4.34-2.24,10.373-2.24,16.459v113.426h-67.537 c0,0,0.905-184.043,0-203.096H246.4v28.779c8.973-13.807,24.986-33.547,60.856-33.547c44.437,0,77.744,29.02,77.744,91.398V378.002 z"
|
||||
></path>
|
||||
</svg>
|
||||
</a>
|
||||
</div>
|
||||
</figcaption>
|
||||
</figure>
|
||||
</div>
|
||||
|
||||
<script src="./js/anime.min.js"></script>
|
||||
<script src="./js/main.js"></script>
|
||||
<script>
|
||||
(function() {
|
||||
new TiltFx(document.querySelector('.card', {}))
|
||||
})()
|
||||
(function () {
|
||||
new TiltFx(document.querySelector(".card", {}));
|
||||
})();
|
||||
</script>
|
||||
<script defer data-domain="heinstrom.com" src="https://plausible.nyc.h.rip/js/script.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
</html>
|
||||
|
||||
214
js/main.js
214
js/main.js
@@ -1,12 +1,10 @@
|
||||
|
||||
;(function(window) {
|
||||
|
||||
'use strict';
|
||||
(function (window) {
|
||||
"use strict";
|
||||
|
||||
// Helper vars and functions.
|
||||
function extend( a, b ) {
|
||||
for( var key in b ) {
|
||||
if( b.hasOwnProperty( key ) ) {
|
||||
function extend(a, b) {
|
||||
for (var key in b) {
|
||||
if (b.hasOwnProperty(key)) {
|
||||
a[key] = b[key];
|
||||
}
|
||||
}
|
||||
@@ -14,17 +12,23 @@
|
||||
}
|
||||
|
||||
function getMousePos(e) {
|
||||
var posx = 0, posy = 0;
|
||||
var posx = 0,
|
||||
posy = 0;
|
||||
if (!e) var e = window.event;
|
||||
if (e.pageX || e.pageY) {
|
||||
if (e.pageX || e.pageY) {
|
||||
posx = e.pageX;
|
||||
posy = e.pageY;
|
||||
} else if (e.clientX || e.clientY) {
|
||||
posx =
|
||||
e.clientX +
|
||||
document.body.scrollLeft +
|
||||
document.documentElement.scrollLeft;
|
||||
posy =
|
||||
e.clientY +
|
||||
document.body.scrollTop +
|
||||
document.documentElement.scrollTop;
|
||||
}
|
||||
else if (e.clientX || e.clientY) {
|
||||
posx = e.clientX + document.body.scrollLeft + document.documentElement.scrollLeft;
|
||||
posy = e.clientY + document.body.scrollTop + document.documentElement.scrollTop;
|
||||
}
|
||||
return { x : posx, y : posy }
|
||||
return { x: posx, y: posy };
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -40,61 +44,76 @@
|
||||
|
||||
TiltFx.prototype.options = {
|
||||
movement: {
|
||||
imgWrapper : {
|
||||
translation : {x: 0, y: 0, z: 0},
|
||||
rotation : {x: -5, y: 5, z: 0},
|
||||
reverseAnimation : {
|
||||
duration : 1200,
|
||||
easing : 'easeOutElastic',
|
||||
elasticity : 600
|
||||
}
|
||||
wrapper: {
|
||||
translation: { x: 0, y: 0, z: 0 },
|
||||
rotation: { x: -5, y: 5, z: 0 },
|
||||
reverseAnimation: {
|
||||
duration: 1200,
|
||||
easing: "easeOutElastic",
|
||||
elasticity: 600,
|
||||
},
|
||||
},
|
||||
shine : {
|
||||
translation : {x: 50, y: 50, z: 0},
|
||||
reverseAnimation : {
|
||||
duration : 1200,
|
||||
easing : 'easeOutElastic',
|
||||
elasticity: 600
|
||||
}
|
||||
}
|
||||
}
|
||||
shine: {
|
||||
translation: { x: 50, y: 50, z: 0 },
|
||||
reverseAnimation: {
|
||||
duration: 1200,
|
||||
easing: "easeOutElastic",
|
||||
elasticity: 600,
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* Init.
|
||||
*/
|
||||
TiltFx.prototype._init = function() {
|
||||
TiltFx.prototype._init = function () {
|
||||
this.DOM.animatable = {};
|
||||
this.DOM.animatable.imgWrapper = this.DOM.el.querySelector('.card__figure');
|
||||
this.DOM.animatable.shine = this.DOM.el.querySelector('.card__deco--shine > div');
|
||||
this.DOM.animatable.wrapper = this.DOM.el.querySelector(".card__figure");
|
||||
this.DOM.animatable.shine = this.DOM.el.querySelector(
|
||||
".card__deco--shine > div"
|
||||
);
|
||||
this._initEvents();
|
||||
};
|
||||
|
||||
/**
|
||||
* Init/Bind events.
|
||||
*/
|
||||
TiltFx.prototype._initEvents = function() {
|
||||
TiltFx.prototype._initEvents = function () {
|
||||
var self = this;
|
||||
|
||||
this.mouseenterFn = function() {
|
||||
for(var key in self.DOM.animatable) {
|
||||
|
||||
this.mouseenterFn = function () {
|
||||
for (var key in self.DOM.animatable) {
|
||||
anime.remove(self.DOM.animatable[key]);
|
||||
}
|
||||
};
|
||||
|
||||
this.mousemoveFn = function(ev) {
|
||||
requestAnimationFrame(function() { self._layout(ev); });
|
||||
|
||||
this.mousemoveFn = function (ev) {
|
||||
requestAnimationFrame(function () {
|
||||
self._layout(ev);
|
||||
});
|
||||
};
|
||||
|
||||
this.mouseleaveFn = function(ev) {
|
||||
requestAnimationFrame(function() {
|
||||
for(var key in self.DOM.animatable) {
|
||||
if( self.options.movement[key] == undefined ) {continue;}
|
||||
|
||||
this.mouseleaveFn = function (ev) {
|
||||
requestAnimationFrame(function () {
|
||||
for (var key in self.DOM.animatable) {
|
||||
if (self.options.movement[key] == undefined) {
|
||||
continue;
|
||||
}
|
||||
anime({
|
||||
targets: self.DOM.animatable[key],
|
||||
duration: self.options.movement[key].reverseAnimation != undefined ? self.options.movement[key].reverseAnimation.duration || 0 : 1,
|
||||
easing: self.options.movement[key].reverseAnimation != undefined ? self.options.movement[key].reverseAnimation.easing || 'linear' : 'linear',
|
||||
elasticity: self.options.movement[key].reverseAnimation != undefined ? self.options.movement[key].reverseAnimation.elasticity || null : null,
|
||||
duration:
|
||||
self.options.movement[key].reverseAnimation != undefined
|
||||
? self.options.movement[key].reverseAnimation.duration || 0
|
||||
: 1,
|
||||
easing:
|
||||
self.options.movement[key].reverseAnimation != undefined
|
||||
? self.options.movement[key].reverseAnimation.easing || "linear"
|
||||
: "linear",
|
||||
elasticity:
|
||||
self.options.movement[key].reverseAnimation != undefined
|
||||
? self.options.movement[key].reverseAnimation.elasticity || null
|
||||
: null,
|
||||
scaleX: 1,
|
||||
scaleY: 1,
|
||||
scaleZ: 1,
|
||||
@@ -103,64 +122,101 @@
|
||||
translateZ: 0,
|
||||
rotateX: 0,
|
||||
rotateY: 0,
|
||||
rotateZ: 0
|
||||
rotateZ: 0,
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
this.DOM.el.addEventListener('mousemove', this.mousemoveFn);
|
||||
this.DOM.el.addEventListener('mouseleave', this.mouseleaveFn);
|
||||
this.DOM.el.addEventListener('mouseenter', this.mouseenterFn);
|
||||
this.debounceLeaveFn = function (e) {
|
||||
e.stopPropagation();
|
||||
clearTimeout(self.timeout);
|
||||
self.timeout = setTimeout(() => {
|
||||
self.mouseleaveFn();
|
||||
}, 25);
|
||||
};
|
||||
|
||||
this.DOM.el.addEventListener("mousemove", this.mousemoveFn);
|
||||
this.DOM.el.addEventListener("mouseleave", this.mouseleaveFn);
|
||||
this.DOM.el.addEventListener("mouseenter", this.mouseenterFn);
|
||||
this.DOM.el.addEventListener("touchend", this.debounceLeaveFn);
|
||||
};
|
||||
|
||||
TiltFx.prototype._layout = function(ev) {
|
||||
TiltFx.prototype._layout = function (ev) {
|
||||
// Mouse position relative to the document.
|
||||
var mousepos = getMousePos(ev),
|
||||
// Document scrolls.
|
||||
docScrolls = {left : document.body.scrollLeft + document.documentElement.scrollLeft, top : document.body.scrollTop + document.documentElement.scrollTop},
|
||||
docScrolls = {
|
||||
left: document.body.scrollLeft + document.documentElement.scrollLeft,
|
||||
top: document.body.scrollTop + document.documentElement.scrollTop,
|
||||
},
|
||||
bounds = this.DOM.el.getBoundingClientRect(),
|
||||
// Mouse position relative to the main element (this.DOM.el).
|
||||
relmousepos = { x : mousepos.x - bounds.left - docScrolls.left, y : mousepos.y - bounds.top - docScrolls.top };
|
||||
relmousepos = {
|
||||
x: mousepos.x - bounds.left - docScrolls.left,
|
||||
y: mousepos.y - bounds.top - docScrolls.top,
|
||||
};
|
||||
|
||||
// Movement settings for the animatable elements.
|
||||
for(var key in this.DOM.animatable) {
|
||||
if( this.DOM.animatable[key] == undefined || this.options.movement[key] == undefined ) {
|
||||
for (var key in this.DOM.animatable) {
|
||||
if (
|
||||
this.DOM.animatable[key] == undefined ||
|
||||
this.options.movement[key] == undefined
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
var t = this.options.movement[key] != undefined ? this.options.movement[key].translation || {x:0,y:0,z:0} : {x:0,y:0,z:0},
|
||||
r = this.options.movement[key] != undefined ? this.options.movement[key].rotation || {x:0,y:0,z:0} : {x:0,y:0,z:0},
|
||||
var t =
|
||||
this.options.movement[key] != undefined
|
||||
? this.options.movement[key].translation || { x: 0, y: 0, z: 0 }
|
||||
: { x: 0, y: 0, z: 0 },
|
||||
r =
|
||||
this.options.movement[key] != undefined
|
||||
? this.options.movement[key].rotation || { x: 0, y: 0, z: 0 }
|
||||
: { x: 0, y: 0, z: 0 },
|
||||
setRange = function (obj) {
|
||||
for(var k in obj) {
|
||||
if( obj[k] == undefined ) {
|
||||
obj[k] = [0,0];
|
||||
}
|
||||
else if( typeof obj[k] === 'number' ) {
|
||||
obj[k] = [-1*obj[k],obj[k]];
|
||||
for (var k in obj) {
|
||||
if (obj[k] == undefined) {
|
||||
obj[k] = [0, 0];
|
||||
} else if (typeof obj[k] === "number") {
|
||||
obj[k] = [-1 * obj[k], obj[k]];
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
setRange(t);
|
||||
setRange(r);
|
||||
|
||||
|
||||
var transforms = {
|
||||
translation : {
|
||||
x: (t.x[1]-t.x[0])/bounds.width*relmousepos.x + t.x[0],
|
||||
y: (t.y[1]-t.y[0])/bounds.height*relmousepos.y + t.y[0],
|
||||
z: (t.z[1]-t.z[0])/bounds.height*relmousepos.y + t.z[0],
|
||||
translation: {
|
||||
x: ((t.x[1] - t.x[0]) / bounds.width) * relmousepos.x + t.x[0],
|
||||
y: ((t.y[1] - t.y[0]) / bounds.height) * relmousepos.y + t.y[0],
|
||||
z: ((t.z[1] - t.z[0]) / bounds.height) * relmousepos.y + t.z[0],
|
||||
},
|
||||
rotation: {
|
||||
x: ((r.x[1] - r.x[0]) / bounds.height) * relmousepos.y + r.x[0],
|
||||
y: ((r.y[1] - r.y[0]) / bounds.width) * relmousepos.x + r.y[0],
|
||||
z: ((r.z[1] - r.z[0]) / bounds.width) * relmousepos.x + r.z[0],
|
||||
},
|
||||
rotation : {
|
||||
x: (r.x[1]-r.x[0])/bounds.height*relmousepos.y + r.x[0],
|
||||
y: (r.y[1]-r.y[0])/bounds.width*relmousepos.x + r.y[0],
|
||||
z: (r.z[1]-r.z[0])/bounds.width*relmousepos.x + r.z[0]
|
||||
}
|
||||
};
|
||||
|
||||
this.DOM.animatable[key].style.WebkitTransform = this.DOM.animatable[key].style.transform = 'translateX(' + transforms.translation.x + 'px) translateY(' + transforms.translation.y + 'px) translateZ(' + transforms.translation.z + 'px) rotateX(' + transforms.rotation.x + 'deg) rotateY(' + transforms.rotation.y + 'deg) rotateZ(' + transforms.rotation.z + 'deg)';
|
||||
this.DOM.animatable[key].style.WebkitTransform = this.DOM.animatable[
|
||||
key
|
||||
].style.transform =
|
||||
"translateX(" +
|
||||
transforms.translation.x +
|
||||
"px) translateY(" +
|
||||
transforms.translation.y +
|
||||
"px) translateZ(" +
|
||||
transforms.translation.z +
|
||||
"px) rotateX(" +
|
||||
transforms.rotation.x +
|
||||
"deg) rotateY(" +
|
||||
transforms.rotation.y +
|
||||
"deg) rotateZ(" +
|
||||
transforms.rotation.z +
|
||||
"deg)";
|
||||
}
|
||||
};
|
||||
|
||||
window.TiltFx = TiltFx;
|
||||
|
||||
})(window);
|
||||
})(window);
|
||||
|
||||
Reference in New Issue
Block a user