File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change @@ -16,27 +16,34 @@ let screenHeight = 0
1616let stamp = 0
1717let height = 100
1818let offset = 0
19+ let normalized = 0
1920
2021function entered (e ) {
2122 stamp = scrollY + e .detail .boundingClientRect .top
2223 inview = true
2324}
2425
26+ function resized () {
27+ screenHeight = window .screen .height
28+ }
29+
30+ $: normalized = Math .abs (factor - 1 )
31+
2532$: if (screenHeight && offsetHeight) {
26- height = 100 + Math . abs (factor - 1 ) * (screenHeight / offsetHeight - 1 ) * 100
33+ height = 100 + normalized * (screenHeight / offsetHeight) * 100
2734}
2835
2936$: if (inview) {
30- offset = Math .floor ((scrollY - stamp) * Math . abs (factor - 1 ) )
37+ offset = Math .floor ((scrollY - stamp) * normalized )
3138}
3239
3340onMount (() => {
34- screenHeight = window . screen . height
41+ resized ()
3542 mounted = true
3643})
3744 </script >
3845
39- <svelte:window bind:scrollY />
46+ <svelte:window bind:scrollY on:resize ={ resized } />
4047
4148<div
4249 class ="wrap {classes }"
You can’t perform that action at this time.
0 commit comments