Skip to content

Commit 8c94aaf

Browse files
committed
🚧 WIP general improvements
Yeah, I'm getting lazy with these commit messages
1 parent 1dc3278 commit 8c94aaf

28 files changed

+4553
-2573
lines changed

‎.prettierrc

Lines changed: 36 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,41 @@
11
{
2+
"$schema": "http://json.schemastore.org/prettierrc",
3+
"tabWidth": 4,
24
"useTabs": true,
5+
"semi": false,
36
"singleQuote": true,
4-
"trailingComma": "none",
7+
"arrowParens": "avoid",
58
"printWidth": 100,
6-
"plugins": ["prettier-plugin-svelte"],
7-
"overrides": [{ "files": "*.svelte", "options": { "parser": "svelte" } }],
8-
"semi": false
9+
"trailingComma": "es5",
10+
"bracketSameLine": false,
11+
"endOfLine": "auto",
12+
"overrides": [
13+
{
14+
"files": ["**/*.yml", "**/*.yaml"],
15+
"options": {
16+
"parser": "yaml",
17+
"tabWidth": 2,
18+
"useTabs": false
19+
}
20+
},
21+
{
22+
"files": "**/*.ts",
23+
"options": {
24+
"parser": "typescript"
25+
}
26+
},
27+
{
28+
"files": "**/*.svelte",
29+
"options": {
30+
"parser": "svelte",
31+
"plugins": ["prettier-plugin-svelte"]
32+
}
33+
},
34+
{
35+
"files": "**/*.svg",
36+
"options": {
37+
"parser": "html"
38+
}
39+
}
40+
]
941
}

‎.yarn/install-state.gz

352 KB
Binary file not shown.

‎.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

‎package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,5 +48,5 @@
4848
"dependencies": {
4949
"svelte-youtube-embed": "^0.3.0"
5050
},
51-
"packageManager": "yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
51+
"packageManager": "yarn@4.7.0+sha512.5a0afa1d4c1d844b3447ee3319633797bcd6385d9a44be07993ae52ff4facabccafb4af5dcd1c2f9a94ac113e5e9ff56f6130431905884414229e284e37bb7c9"
5252
}

‎src/app.html

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,6 @@
55
<link rel="icon" href="%sveltekit.assets%/favicon.png" />
66
<meta name="viewport" content="width=device-width, initial-scale=1" />
77

8-
<!-- <meta property="og:type" content="website" />
9-
<meta content="Animated Java" property="og:title" />
10-
<meta
11-
content="A Blockbench plugin that makes complex animation a breeze in Minecraft: Java Edition."
12-
property="og:description"
13-
/>
14-
<meta content="https://animated-java.github.io" property="og:url" />
15-
<meta
16-
content="https://animated-java.github.io/img/animated_java_animated_icon.png"
17-
property="og:image"
18-
/>
19-
<meta content="#00ACED" data-react-helmet="true" name="theme-color" /> -->
20-
218
<script>
229
const key = 'svelteness::color-scheme'
2310
const scheme = localStorage[key]

‎src/components/VideoCarousel.svelte

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script lang="ts" context="module">
2+
import { inView, scrollAnimator } from '$lib'
23
import { Button } from '@svelteness/kit-docs'
34
</script>
45

@@ -24,7 +25,7 @@
2425
'-6pLFvW5_Dk', // Camera Animation Test
2526
'sC3FqzpDrpQ', // Diamond Golem
2627
'fs0NUGmsa10', // Butter Dog
27-
'4VlwyI0EHo4' // Funny Mobile Game
28+
'4VlwyI0EHo4', // Funny Mobile Game
2829
]
2930
3031
async function getYoutubeVideoTitle(id: string) {
@@ -50,10 +51,8 @@
5051
{:catch error}
5152
<!-- -->
5253
{/await}
53-
<!-- {#key $index}
54-
{/key} -->
5554
<div class="grid">
56-
{#each VIDEOS as id}
55+
{#each VIDEOS as id, index}
5756
<!-- svelte-ignore a11y-click-events-have-key-events -->
5857
<!-- svelte-ignore a11y-no-static-element-interactions -->
5958
<div
@@ -67,6 +66,21 @@
6766
class="thumbnail-image"
6867
style={`background-image: url(https://img.youtube.com/vi/${id}/0.jpg);`}
6968
></div>
69+
<div
70+
use:inView={{ top: 100 }}
71+
on:enter={e => {
72+
if (
73+
e.target.parentElement?.parentElement?.parentElement?.classList.contains(
74+
'transition-in'
75+
)
76+
)
77+
return
78+
e.target.parentElement.parentElement.parentElement.classList.add(
79+
'transition-in'
80+
)
81+
}}
82+
></div>
83+
7084
{#await getYoutubeVideoTitle(id)}
7185
<p class="loading">Loading Title...</p>
7286
{:then title}
@@ -102,6 +116,15 @@
102116
display: flex;
103117
flex-direction: column;
104118
align-items: center;
119+
transition:
120+
transform 0.2s ease 0s,
121+
opacity 0.2s ease 0s;
122+
transform: translateY(16px) scale(0.9);
123+
opacity: 0;
124+
}
125+
.thumbnail-container:global(.transition-in) {
126+
transform: translateY(0) scale(1);
127+
opacity: 1;
105128
}
106129
.thumbnail-container :global(button span) {
107130
display: flex;

‎src/kit-docs/WigglyText.svelte

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,10 @@
2727
animation: wave 1.5s infinite;
2828
animation-timing-function: ease-in-out;
2929
}
30+
31+
@media (prefers-reduced-motion: reduce) {
32+
.wiggly-text {
33+
animation: none;
34+
}
35+
}
3036
</style>

‎src/kit-docs/kofi-logo.svelte

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" height="1.2em" width="1.2em">
2+
<title>Ko-fi</title>
3+
<path
4+
fill="currentColor"
5+
d="M23.881 8.948c-0.773 -4.085 -4.859 -4.593 -4.859 -4.593H0.723c-0.604 0 -0.679 0.798 -0.679 0.798s-0.082 7.324 -0.022 11.822c0.164 2.424 2.586 2.672 2.586 2.672s8.267 -0.023 11.966 -0.049c2.438 -0.426 2.683 -2.566 2.658 -3.734 4.352 0.24 7.422 -2.831 6.649 -6.916zm-11.062 3.511c-1.246 1.453 -4.011 3.976 -4.011 3.976s-0.121 0.119 -0.31 0.023c-0.076 -0.057 -0.108 -0.09 -0.108 -0.09 -0.443 -0.441 -3.368 -3.049 -4.034 -3.954 -0.709 -0.965 -1.041 -2.7 -0.091 -3.71 0.951 -1.01 3.005 -1.086 4.363 0.407 0 0 1.565 -1.782 3.468 -0.963 1.904 0.82 1.832 3.011 0.723 4.311zm6.173 0.478c-0.928 0.116 -1.682 0.028 -1.682 0.028V7.284h1.77s1.971 0.551 1.971 2.638c0 1.913 -0.985 2.667 -2.059 3.015z"
6+
stroke-width="1"
7+
></path>
8+
</svg>

‎src/lib/inView.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ interface ISetObserverOptions {
44
bottom?: number
55
}
66

7-
export default function inView(node: HTMLElement, options: ISetObserverOptions = {}) {
7+
export function inView(node: HTMLElement, options: ISetObserverOptions = {}) {
88
let observer: IntersectionObserver
99

10-
const handleIntersect: IntersectionObserverCallback = (e) => {
10+
const handleIntersect: IntersectionObserverCallback = e => {
1111
const v = e[0].isIntersecting ? 'enter' : 'exit'
1212
node.dispatchEvent(new CustomEvent(v))
1313
}
@@ -31,6 +31,6 @@ export default function inView(node: HTMLElement, options: ISetObserverOptions =
3131

3232
destroy() {
3333
if (observer) observer.disconnect()
34-
}
34+
},
3535
}
3636
}

‎src/lib/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
// place files you want to import through the `$lib` alias in this folder.
2-
export { default as inView } from './inView'
2+
export * from './scrollAnim'
3+
export * from './inView'

‎src/lib/scrollAnim.ts

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { quartOut } from 'svelte/easing'
2+
3+
interface IScrollAnimatorOptions {
4+
x?: number
5+
yOffset?: number
6+
opacity?: number
7+
scale?: number
8+
rate?: number
9+
easing?: (t: number) => number
10+
}
11+
12+
export function scrollAnimator(element: HTMLElement, options: IScrollAnimatorOptions = {}) {
13+
const rect = element.getBoundingClientRect()
14+
const docRect = document.body.getBoundingClientRect()
15+
element.style.opacity = '0'
16+
element.style.transition = 'opacity 0.1s ease, transform 0.1s ease'
17+
18+
const rate = options.rate || 1
19+
20+
let top = rect.top - docRect.top - window.innerHeight / 2
21+
if (options.yOffset) top += options.yOffset
22+
else top += -rect.height / 2
23+
24+
const moveX = options.x || 0
25+
const scale = options.scale
26+
27+
const updateTransform = (t: number) => {
28+
t = (options.easing ?? quartOut)(t)
29+
const x = -moveX + moveX * t
30+
let s = 1
31+
if (scale) {
32+
s = scale + (1 - scale) * t
33+
}
34+
element.style.transform = `translateX(${x}px) scale(${s})`
35+
}
36+
37+
const updateOpacity = (t: number) => {
38+
element.style.opacity = `${Math.min(t * 1.25, 1)}`
39+
}
40+
41+
const observer = () => {
42+
const scroll = window.scrollY
43+
44+
const localScroll = Math.min(Math.max(scroll - top, 0), rect.height)
45+
const percent = Math.min(Math.max(localScroll / (rect.height * rate), 0), 1)
46+
updateTransform(percent)
47+
updateOpacity(percent)
48+
}
49+
50+
let intervalID: number | undefined
51+
const setObserver = ({}: IScrollAnimatorOptions) => {
52+
if (intervalID) clearInterval(intervalID)
53+
// if (observer) removeEventListener('scroll', observer)
54+
intervalID = setInterval(observer, 16)
55+
// addEventListener('scroll', observer, { passive: true })
56+
observer()
57+
}
58+
59+
setObserver(options)
60+
61+
return {
62+
update(args: IScrollAnimatorOptions) {
63+
setObserver(args)
64+
},
65+
66+
destroy() {
67+
if (observer) removeEventListener('scroll', observer)
68+
},
69+
}
70+
}

‎src/lib/strings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const SLOGAN = 'Effortlessly craft complex animations for Minecraft: Java Edition'

‎src/lib/styles/kit-docs.css

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@
88
--kd-color-inverse: 5 11 23;
99
--kd-color-border: 209 213 219;
1010

11-
--kd-color-subtle: rgb(181 186 199);
11+
--kd-color-subtle: rgb(103 111 124);
1212

1313
--kd-code-fence-bg: rgb(212 217 251);
1414
--kd-code-fence-fg: rgb(26, 29, 36);
1515
}
1616

1717
:root {
1818
font-size: 16px;
19-
scroll-padding-top: 6rem;
19+
scroll-padding-top: 8rem;
2020

2121
--kd-font-family-sans: Inter VF, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont,
2222
'Segoe UI', Roboto, 'Helvetica Neue', Arial, 'Noto Sans', sans-serif, 'Apple Color Emoji',
@@ -77,7 +77,7 @@
7777
--kd-color-body: 31 33 40;
7878
--kd-color-focus: 129 140 248;
7979

80-
--kd-color-subtle: rgb(106, 116, 132);
80+
--kd-color-subtle: rgb(144 156 176);
8181

8282
--kd-code-fence-bg: rgb(22 23 27);
8383
--kd-code-fence-fg: rgb(186 190 216);
@@ -111,3 +111,7 @@ code:not(pre code) {
111111
td {
112112
text-wrap: balance !important;
113113
}
114+
115+
.on-this-page {
116+
display: none !important;
117+
}

0 commit comments

Comments
 (0)