Added text parallax when scrolling down
This commit is contained in:
parent
6dea4a80df
commit
5c06776c01
|
@ -22,3 +22,5 @@ dist-ssr
|
||||||
*.njsproj
|
*.njsproj
|
||||||
*.sln
|
*.sln
|
||||||
*.sw?
|
*.sw?
|
||||||
|
|
||||||
|
temp
|
|
@ -1,2 +1,6 @@
|
||||||
<!-- Short hand for spacing between components-->
|
<!-- Short hand for spacing between components-->
|
||||||
<div style="flex-grow: 1;"/>
|
<div style="flex-grow: 1; {style}"/>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
export let style = "";
|
||||||
|
</script>
|
|
@ -5,16 +5,25 @@
|
||||||
let startExit = 4700;
|
let startExit = 4700;
|
||||||
let exitLength = 2000;
|
let exitLength = 2000;
|
||||||
let exitScreenLength = 700;
|
let exitScreenLength = 700;
|
||||||
|
let textMaxRotation = 30;
|
||||||
|
let parallaxOffset = 1.0125;
|
||||||
|
|
||||||
// Define, don't touch
|
// Define, don't touch
|
||||||
let scrollPos: number = 0;
|
let scrollPos: number = 0;
|
||||||
let extraPosY = 0;
|
let extraPosY = 0;
|
||||||
let rotation = 0;
|
let rotation = 0;
|
||||||
|
|
||||||
|
// Define: Parallax text
|
||||||
|
let extraPosY2 = 0;
|
||||||
|
let rotation2 = 0;
|
||||||
|
|
||||||
$:{
|
$:{
|
||||||
let time = (scrollPos - startExit) / exitLength;
|
let time = (scrollPos - startExit) / exitLength;
|
||||||
extraPosY = lerp(0, -exitScreenLength, time, true);
|
extraPosY = lerp(0, -exitScreenLength, time, true);
|
||||||
rotation = lerp(0, 50, time, true);
|
rotation = lerp(0, textMaxRotation, time, true);
|
||||||
|
|
||||||
|
extraPosY2 = lerp(0, -exitScreenLength, time * parallaxOffset, true);
|
||||||
|
rotation2 = lerp(0, textMaxRotation, time, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
function lerp(from: number, to: number, time: number, clamped: boolean = false) : number {
|
function lerp(from: number, to: number, time: number, clamped: boolean = false) : number {
|
||||||
|
@ -35,15 +44,17 @@
|
||||||
<svelte:window bind:scrollY={scrollPos} />
|
<svelte:window bind:scrollY={scrollPos} />
|
||||||
|
|
||||||
<div class="horizontal">
|
<div class="horizontal">
|
||||||
<div id="WeAreHolder" style="margin-right: 45vw;">
|
<div id="WeAreHolder" class="align-center" style="margin-right: 35vw; position: relative;">
|
||||||
<div style="transform: translate(0, {extraPosY}px) rotateX({rotation}deg);">
|
<div class="no-wrap no-interact big-text align-center WeAreText"
|
||||||
<div class="no-wrap no-interact big-text align-center"
|
style="color: #c9c9c9; transform: translate(0, {extraPosY}px) rotateX({rotation}deg); position: absolute;">
|
||||||
style="padding: -10px 10px 0px 10px;">
|
We are
|
||||||
|
</div>
|
||||||
|
<div class="no-wrap no-interact big-text align-center WeAreText"
|
||||||
|
style="color: #ffffff; transform: translate(0, {extraPosY2}px) rotateX({rotation2}deg); position: absolute;">
|
||||||
We are
|
We are
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
<ZSpacer style="width: 10vw;"/>
|
||||||
<ZSpacer/>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -55,11 +66,7 @@
|
||||||
-moz-perspective: 1000px;
|
-moz-perspective: 1000px;
|
||||||
}
|
}
|
||||||
|
|
||||||
#WeAreHolder div>div {
|
.WeAreText {
|
||||||
padding: 0px 30px -5px 30px;
|
padding: -10px 10px 0px 10px;
|
||||||
/* border-radius: 40px; */
|
|
||||||
/* background: rgba(57, 57, 57, 0.201); */
|
|
||||||
/* border-bottom: 5px solid rgb(189, 189, 189); */
|
|
||||||
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
Loading…
Reference in New Issue