2
2
3
3
<template >
4
4
<div class =" fullpage-container" @wheel =" handleScroll" >
5
- <div
6
- class =" section"
7
- v-for = " (section, index) in sections "
8
- :key = " section.id "
9
- :ref = " `section-${ index}` "
10
- :class = " `section-${index}` "
11
- >
5
+ <div class = " section " v-for = " (section, index) in sections " :key = " section.id " :ref = " `section-${index}` "
6
+ : class =" ` section-${index}` " >
7
+ < div class = " sidescroll-container " >
8
+ < transition name = " fade " @before-leave = " beforeLeave " >
9
+ < SideScrolling v-if = " index === 0 && activeSection === 0 " />
10
+ </ transition >
11
+ </ div >
12
12
<h2 class =" content" >{{ section.title }}</h2 >
13
13
<p class =" content" >{{ section.content }}</p >
14
14
</div >
15
15
<div class =" scroll-indicator" v-if =" showIndicator" >
16
- <button v-for =" (section, index) in sections" :key =" index" @click =" scrollToSection(index)" >
16
+ <div class =" button-container" v-for =" (section, index) in sections" :key =" index" @click =" scrollToSection(index)" >
17
+ <div class =" box" ></div >
17
18
{{ section.title }}
18
- </button >
19
+ </div >
19
20
</div >
20
21
</div >
21
22
</template >
22
23
23
24
<script >
24
- import AshEffect from ' ./AshEffect .vue' ;
25
+ import SideScrolling from ' ./SideScrolling .vue' ;
25
26
26
27
export default {
27
28
components: {
29
+ SideScrolling,
28
30
},
29
31
props: {
30
32
sections: {
@@ -40,6 +42,7 @@ export default {
40
42
return {
41
43
activeSection: 0 ,
42
44
isScrolling: false ,
45
+ isLeaving: false
43
46
};
44
47
},
45
48
methods: {
@@ -58,7 +61,7 @@ export default {
58
61
if (this .isScrolling ) return ;
59
62
60
63
this .isScrolling = true ;
61
-
64
+
62
65
const direction = event .deltaY > 0 ? 1 : - 1 ;
63
66
this .activeSection += direction;
64
67
@@ -68,7 +71,7 @@ export default {
68
71
this .activeSection = this .sections .length - 1 ;
69
72
}
70
73
setTimeout (() => {
71
- this .scrollToSection (this .activeSection );
74
+ this .scrollToSection (this .activeSection );
72
75
}, 100 );
73
76
74
77
},
@@ -84,6 +87,13 @@ export default {
84
87
section .style .backgroundImage = this .computeGradient (index, this .sections .length );
85
88
}
86
89
});
90
+ },
91
+ beforeLeave (el ) {
92
+ // Add a delay before the component is removed
93
+ setTimeout (() => {
94
+ // This will trigger the actual removal
95
+ el .style .opacity = 0 ;
96
+ }, 500 ); // Delay in milliseconds (500ms in this example)
87
97
}
88
98
},
89
99
mounted () {
@@ -96,6 +106,19 @@ export default {
96
106
</script >
97
107
98
108
<style scoped>
109
+ .box {
110
+ border : solid black 5px ;
111
+ padding : 5px ;
112
+ background-color :white ;
113
+ }
114
+
115
+ .fade-enter-active , .fade-leave-active {
116
+ transition : opacity 0.5s ease ;
117
+ }
118
+ .fade-enter , .fade-leave-to {
119
+ opacity : 0 ;
120
+ }
121
+
99
122
.fullpage-container {
100
123
overflow : hidden ;
101
124
height : 100vh ;
@@ -107,6 +130,8 @@ export default {
107
130
display : flex ;
108
131
align-items : center ;
109
132
justify-content : center ;
133
+ flex-wrap : wrap ;
134
+ flex-direction :column ;
110
135
}
111
136
112
137
.section :nth-child (1 ) .content {
@@ -122,11 +147,28 @@ export default {
122
147
right : 10px ;
123
148
top : 50% ;
124
149
transform : translateY (-50% );
125
- display : flex ;
150
+ display :inline-block ;
126
151
flex-direction : column ;
152
+ margin : 0px ;
127
153
}
128
154
129
155
.scroll-indicator button {
130
156
margin-bottom : 10px ;
131
157
}
158
+
159
+ .button-container {
160
+ display : flex ;
161
+ flex-direction :row ;
162
+ background :red ;
163
+ }
164
+
165
+ .sidescroll-container {
166
+ background-color :green ;
167
+ color :white ;
168
+ align-items : center ;
169
+ justify-content : center ;
170
+ display :flex ;
171
+ flex-wrap : nowrap ;
172
+ width : 80% ;
173
+ }
132
174
</style >
0 commit comments