sorta working #WIP

This commit is contained in:
Jeppe Ernst 2018-01-22 16:30:08 +01:00
parent 39fa3d27e1
commit 56e45454d7
7 changed files with 167 additions and 103 deletions

View file

@ -2,24 +2,26 @@
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, minimum-scale=1.0"">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, minimum-scale=1.0">
<!-- <meta name="viewport" content="width=700"> -->
<title>{% if page.title %}{{ page.title }}{% else %}{{ site.name }}{% endif %}</title>
<link rel="stylesheet" href="{{ site.baseurl }}/assets/style/main.css?{{ site.time | date: '%s' }}">
<link rel="alternate" type="application/rss+xml" title="RSS Feed for {{ site.name }}" href="{{ site.baseurl }}/feed.xml" />
{% seo %}
</head>
<body data-env="{{ jekyll.environment }}">
<body data-env="{{ jekyll.environment }}" class="no-js">
{% include security-camera-svgrepo-com.svg %}
<div {% if page.containerId %} id="{{ page.containerId }}" {% endif %} class="container">
{{ content }}
</div>
<footer>
<!-- <footer>
Last generated at {{ site.time | date_to_rfc822 }}
</footer>
</footer> -->
<script src="{{ site.baseurl }}/assets/js/vendor/ScrollMagic.min.js"></script>
<script src="{{ site.baseurl }}/assets/js/vendor/TweenMax.min.js"></script>
<script src="{{ site.baseurl }}/assets/js/vendor/animation.gsap.js"></script>
<script src="{{ site.baseurl }}/assets/js/vendor/debug.addIndicators.min.js"></script>
<script src="{{ site.baseurl }}/assets/js/vendor/mobile-detect.min.js"></script>
<script src="{{ site.baseurl }}/assets/js/main.js"></script>
</body>
</html>

View file

@ -1,12 +1,18 @@
body, html {
//min-height: 100%;
height: 100%;
height: 100vh;
}
body {
background: #2A2A2A;
color: #FFF;
height: 100%;
//height: 100%;
//overflow-y: scroll;
//-webkit-overflow-scrolling: touch;
&[data-env="development"] {
background: red;
}
}
footer {

View file

@ -10,7 +10,7 @@ h1, h2, h3, h4, h5, h6 {
h1 {
font-size: 4rem;
text-shadow: 4px 3px 0px rgb(90, 85, 81);
margin: 3rem 0;
margin: 4rem 0 1rem;
display: block;
width: 90vw;
.even & {

View file

@ -6,19 +6,21 @@
z-index: 1000;
pointer-events: none;
.redLight {
animation: redLigth 1s ease infinite;
animation: redLight 1s ease infinite;
}
.glare {
transform-origin: 80% 80%;
transform-box: fill-box;
animation: glare 4s linear infinite;
}
.outerRing {
transform-origin: 50% 50%;
transform-box: fill-box;
animation: outerRing 4s linear infinite;
}
}
@keyframes redLigth {
@keyframes redLight {
0% {
fill-opacity: 1;
}

View file

@ -1,25 +1,51 @@
body[data-scrollmagicPanes="enabled"] {
#pinContainer {
height: 100% !important;
width: 100% !important;
overflow: hidden;
}
section {
position: absolute;
top: 100%;
margin-top: 30px;
&:first-child {
margin-top: 0;
}
}
}
body.js {
h1 {
transition: all .5s linear;
}
#butwhy {
h1 {
opacity: 0;
transform: translateX(-100vw);
}
&.appear h1 {
opacity: 1;
transform: translateX(0);
}
}
}
section {
min-height: 100vh;
width: 100%;
position: absolute;
top: 100%;
position: relative;
//position: -webkit-sticky;
//position: sticky;
//overflow-y: auto;
//top: 0px;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
//position: relative;
background: $body-bg;
margin-top: 30px;
padding-bottom: 30px;
&:first-child {
//top: 0;
margin-top: 0;
padding-bottom: 0;
}
&:not(:first-child):before {
@ -28,13 +54,12 @@ section {
height: 30px;
position: absolute;
top: -30px;
background: linear-gradient(to left bottom, $alternate-bg 0%,$alternate-bg 49%,$body-bg 50%,$body-bg 100%);
right: 0;
background: linear-gradient(to left bottom, transparent 0%,transparent 49%,$body-bg 50%,$body-bg 100%);
}
&.even {
background: $alternate-bg;
&:before {
background: linear-gradient(to left bottom, $body-bg 0%,$body-bg 49%,$alternate-bg 50%,$alternate-bg 100%);
background: linear-gradient(to left bottom, transparent 0%,transparent 49%,$alternate-bg 50%,$alternate-bg 100%);
}
}

View file

@ -1,17 +1,21 @@
document.body.className = "js";
//are we running in dev mode?
var debug = document.body.getAttribute("data-env") === "development" ? true : false;
document.body.style.height = document.body.offsetHeight + "px";
var controllerPanes = new ScrollMagic.Controller({
globalSceneOptions: {
//triggerHook: 'onLeave'
}
});
var controllerAnimations = new ScrollMagic.Controller({
globalSceneOptions: {
//triggerHook: 'onLeave'
}
});
// var controllerAnimations = new ScrollMagic.Controller({
// globalSceneOptions: {
// //triggerHook: 'onLeave'
// }
// });
var md = new MobileDetect(window.navigator.userAgent);
var isDesktop = md.mobile() === null ? true : false;
function calculateOffset(){
var containerHeight = document.getElementById("pinContainer").offsetHeight;
@ -32,8 +36,10 @@ function createTween(section, duration ,index){
}
var tween = TweenMax.fromTo(section, duration, {
y: startY,
force3D: true,
}, {
y: "-100%",
force3D: true
})
return tween;
}
@ -59,12 +65,19 @@ function createTweenTimeline(){
};
}
function toggleDataAttr(attribute, toggle){
if (toggle) {
document.body.setAttribute("data-" + attribute, "enabled");
} else {
document.body.setAttribute("data-" + attribute, "disabled");
}
}
//only use the pane animations on desktop
if (isDesktop) {
toggleDataAttr("scrollmagicPanes", true);
wipeAnimation = createTweenTimeline();
// create scene for every slide
//for (var i = 0; i < sections.length - 1; i++) {
var triggerElement = document.getElementsByClassName("container")[0];
var panelScene = new ScrollMagic.Scene({
triggerElement: triggerElement,
@ -77,18 +90,31 @@ wipeAnimation = createTweenTimeline();
if (debug) {
panelScene.addIndicators()
}
wipeAnimation.tweens[0].updateTo({startAt: {y: calculateOffset()}}, false);
window.addEventListener('resize', function(){
wipeAnimation.tweens[0].updateTo({startAt: {y: calculateOffset()}}, false)
//document.body.style.height = document.body.offsetHeight + "px";
console.log("pinContainer " + document.getElementById("pinContainer").offsetHeight)
console.log("body " + document.body.offsetHeight)
console.log("resize fired!")
// if (document.body.offsetHeight - document.getElementById("pinContainer").offsetHeight > 100) {
// console.log("adjusting offset!");
// wipeAnimation.tweens[0].updateTo({startAt: {y: calculateOffset()}}, false)
// }
})
//}
} else {
toggleDataAttr("scrollmagicPanes", false);
}
// for (var i = 0; i < sections.length; i++) {
// new ScrollMagic.Scene({
// triggerElement: sections[i]
// })
// .setClassToggle(sections[i], "appear")
// .addIndicators({name: "1 - add a class"}) // add indicators (requires plugin)
// .addTo(controllerAnimations);
// }
var controllerAnimations = new ScrollMagic.Controller({});
var sections = document.querySelectorAll("section");
for (var i = 0; i < sections.length; i++) {
sectionScene = new ScrollMagic.Scene({
triggerElement: sections[i]
})
.setClassToggle(sections[i], "appear")
.addTo(controllerAnimations);
if (debug) {
sectionScene.addIndicators({name: "1 - add a class"}) // add indicators (requires plugin)
}
}

3
assets/js/vendor/mobile-detect.min.js vendored Normal file

File diff suppressed because one or more lines are too long