33 <div class =" scroll-container" >
44
55 <Example-start
6- v-if =" ! currentlyShowing"
6+ v-if =" currentlyShowing === 'first' "
77 title =" Scroll Markers Example"
88 description =" This is an example demonstrating the use of scrollmarkers as triggers for scroll positions."
99 ></Example-start >
1010
11- <p v-if =" currentlyShowing === 'first '" class =" scroll-section" >
12- As the scroll markers enter visibility, the trigger the text
11+ <p v-if =" currentlyShowing === 'second '" class =" scroll-section" >
12+ As the scroll markers enter visibility, they trigger the text
1313 to change.
1414 </p >
1515
16- <p v-if =" currentlyShowing === 'second '" class =" scroll-section" >
16+ <p v-if =" currentlyShowing === 'third '" class =" scroll-section" >
1717 Instead of just changing text, you could attach different actions
1818 to each scroll marker trigger point.
1919 </p >
2020
2121
22- <div v-if =" currentlyShowing === 'third '" class =" scroll-section" >
22+ <div v-if =" currentlyShowing === 'fourth '" class =" scroll-section" >
2323 <p >
2424 Notice how the scroll markers are red lines... that is because the
2525 debug prop is set to 'true'.
2626 </p >
2727 </div >
2828
2929
30- <p v-if =" currentlyShowing === 'fourth '" class =" scroll-section" >
30+ <p v-if =" currentlyShowing === 'fifth '" class =" scroll-section" >
3131 You might also notice they markers dont trigger a change
3232 of text until they're well into the viewport -- that's because
3333 of the scroll-view component's default offset of 200px (can be changed
3434 via props).
3535 </p >
3636
37- <p v-if =" currentlyShowing === 'fifth '" class =" scroll-section" >
37+ <p v-if =" currentlyShowing === 'sixth '" class =" scroll-section" >
3838 The end.
3939 </p >
4040
41+ <div class =" debug-toggle" >
42+ <input type =" checkbox" v-model =" debug" >
43+ Toggle debug mode
44+ </div >
45+
4146 </div >
4247 <div class =" markers" >
4348 <scroll-view >
4752 :key =" m"
4853 :visible =" visible[m]"
4954 :name =" m"
50- :spacing =" 1500 "
55+ :spacing =" 700 "
5156 :debug =" debug"
5257 @isVisible =" markerVisible"
5358 @isNotVisible =" markerNotVisible"
5964</template >
6065
6166<script >
67+ import { $scrollview } from ' ../../../../../src'
6268import ExampleStart from ' .././../ExampleStart'
6369
6470export default {
@@ -67,17 +73,18 @@ export default {
6773 },
6874 data () {
6975 return {
70- markers: [' first' , ' second' , ' third' , ' fourth' , ' fifth' ],
76+ markers: [' first' , ' second' , ' third' , ' fourth' , ' fifth' , ' sixth ' ],
7177 debug: true ,
72- currentlyShowing: ' ' ,
78+ currentlyShowing: ' first ' ,
7379 }
7480 },
7581 methods: {
7682 markerVisible (name ) {
7783 this .currentlyShowing = name
7884 },
7985 markerNotVisible (name ) {
80- if (name === ' first' ) this .currentlyShowing = ' '
86+ const scrollDirection = $scrollview .getScrollDirection ()
87+ if (name === ' first' && scrollDirection === ' UP' ) this .currentlyShowing = name
8188 }
8289 }
8390}
@@ -104,4 +111,11 @@ export default {
104111 width : 100% ;
105112 padding-bottom : 300px ;
106113}
114+
115+ .debug-toggle {
116+ position : absolute ;
117+ bottom : 25px ;
118+ left : 50% ;
119+ transform : translateX (-50% );
120+ }
107121 </style >
0 commit comments