-
Notifications
You must be signed in to change notification settings - Fork 0
/
App.vue
79 lines (69 loc) · 1.84 KB
/
App.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<script setup lang="ts">
import { ref } from 'vue'
import HelloWorld from './components/HelloWorld.vue'
import Sidebar from './components/Sidebar.vue'
import VueStickyToParent from '../lib/VueStickyToParent.vue'
// Define a ref for the parent element and pass it to the VueStickyToParent component
const container = ref<Maybe<HTMLElement>>(null);
</script>
<template>
<div class="page">
<aside ref="container" class="container">
<VueStickyToParent :parent="container">
<div class="sticky">
<h1>Sticky to parent</h1>
<p><strong>Scroll down to see how it works</strong></p>
<hr>
<p><strong>Note:</strong> the <code>.container</code> should have full height of the column, component sticks to it and moves <i>"inside"</i> it</p>
<hr>
<img src="./assets/vue.svg" class="logo" alt="Vue logo" />
<Sidebar/>
</div>
</VueStickyToParent>
</aside>
<section class="section">
<a href="https://vuejs.org/" target="_blank">
<img src="./assets/vue.svg" class="logo vue" alt="Vue logo" />
</a>
<HelloWorld msg="Vue + Nuxt compatible" />
</section>
</div>
</template>
<style scoped>
.page {
display: flex;
justify-content: center;
align-items: stretch;
gap: 2em;
width: 100%;
}
.logo {
height: 6em;
padding: 1.5em;
will-change: filter;
transition: filter 300ms;
}
.logo:hover {
filter: drop-shadow(0 0 2em #646cffaa);
}
.logo.vue:hover {
filter: drop-shadow(0 0 2em #42b883aa);
}
.section {
width: calc(100% - 300px);
}
/* Define styles of Sidebar container */
.container {
position: relative;
width: 300px;
height: inherit;
min-height: 100vh;
display: flex;
flex-direction: column;
align-items: flex-start;
}
/* Define styles of sticky content block */
.sticky {
width: 300px;
}
</style>