HeyItsFinn
HeyItsFinn
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
Solution: "backdrop-filter: blur()" is not compatible with "transform: translateZ()" for some reason. If any element had the blur property, the entire thing would flatten.
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
this is in a svelte file so some of the syntax might be weird if you have never seen it
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
<style lang="scss">
.web-container {
transform-style: preserve-3d;
perspective: 5000px;
transform: rotateX(var(--rotateY)) rotateY(var(--rotateX)) translateZ(0px);

* {
transform-style: preserve-3d;
transform: translateZ(50px)
}
}
</style>
<style lang="scss">
.web-container {
transform-style: preserve-3d;
perspective: 5000px;
transform: rotateX(var(--rotateY)) rotateY(var(--rotateX)) translateZ(0px);

* {
transform-style: preserve-3d;
transform: translateZ(50px)
}
}
</style>
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
<img src="/background.jpg" alt="background" class="background">

<div class="frontground">
<div class="web-container glass track-mouse"> //The parent that tracks mouse
<div class="side-bar glass"> //The children that aren't transforming properly
<div class="profile glass">
<div class="main">
<div class="avatar glass"/>
<div class="username glass">
<h4>@Finn Milner</h4>
</div>
</div>
<div class="about glass">
<h3>Thanks for visiting my portfolio!</h3>
</div>
</div>
<div class="sections">
{#each Array(6) as _}
<div class="section glass"/>
{/each}
</div>
</div>
<div class="container">
{#each Array(9) as _}
<div class="glass"/>
{/each}
</div>
</div>
</div>
<img src="/background.jpg" alt="background" class="background">

<div class="frontground">
<div class="web-container glass track-mouse"> //The parent that tracks mouse
<div class="side-bar glass"> //The children that aren't transforming properly
<div class="profile glass">
<div class="main">
<div class="avatar glass"/>
<div class="username glass">
<h4>@Finn Milner</h4>
</div>
</div>
<div class="about glass">
<h3>Thanks for visiting my portfolio!</h3>
</div>
</div>
<div class="sections">
{#each Array(6) as _}
<div class="section glass"/>
{/each}
</div>
</div>
<div class="container">
{#each Array(9) as _}
<div class="glass"/>
{/each}
</div>
</div>
</div>
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
<script>
import { onMount } from "svelte"

onMount(() => {
const mouseTracking = Array.from(document.getElementsByClassName("track-mouse"))

console.log(mouseTracking)

document.addEventListener("mousemove", (event) => {
mouseTracking.forEach((element) => {
rotateElement(element, event)
})
})

const rotateElement = (element, event) => {
const x = event.clientX
const y = event.clientY

const middleX = window.innerWidth / 2
const middleY = window.innerHeight / 2

const offsetX = (x - middleX) / middleX
const offsetY = (y - middleY) / middleY

const maxX = 30
const maxY = 30

const rotationX = offsetX * maxX
const rotationY = offsetY * maxY

element.style.setProperty("--rotateX", rotationX + "deg")
element.style.setProperty("--rotateY", -1 * rotationY + "deg")
}
})
</script>
<script>
import { onMount } from "svelte"

onMount(() => {
const mouseTracking = Array.from(document.getElementsByClassName("track-mouse"))

console.log(mouseTracking)

document.addEventListener("mousemove", (event) => {
mouseTracking.forEach((element) => {
rotateElement(element, event)
})
})

const rotateElement = (element, event) => {
const x = event.clientX
const y = event.clientY

const middleX = window.innerWidth / 2
const middleY = window.innerHeight / 2

const offsetX = (x - middleX) / middleX
const offsetY = (y - middleY) / middleY

const maxX = 30
const maxY = 30

const rotationX = offsetX * maxX
const rotationY = offsetY * maxY

element.style.setProperty("--rotateX", rotationX + "deg")
element.style.setProperty("--rotateY", -1 * rotationY + "deg")
}
})
</script>
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
tried it tho
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
yeah ok, pretty certain z indexes aren't relevant in this context
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
no change, whats that supposed to do?
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
alr 1 sec
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
which one?
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
no, should that be on the container or the children?
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
even if it was positioned absolute, the children would always be on top
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
its not
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
as you can see, something is happening but rather than the children moving along the z axis, it just looks like they are spilling over the edges of the container
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
and this is it set to 500px
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
27 replies
KPCKevin Powell - Community
Created by HeyItsFinn on 8/2/2023 in #front-end
"transform: translateZ" not working as intended even when "transform-style: preserve-3d" is set
this is what I see when translateZ is set to 50px
27 replies