1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 |
- <script setup lang="ts">
- import { useCommonStore } from '@/stores/modules/common'
- const commonStore = useCommonStore()
- onMounted(() => {
- let lastScrollY = window.scrollY
- const sections = document.querySelectorAll('[data-section]')
- const observerOptions = {
- root: null,
- threshold: [0.1, 0.9],
- }
- const intersectionCallback = (entries: any) => {
- const currentScrollY = window.scrollY
- const isScrollingDown = currentScrollY > lastScrollY
- console.log('intersectionRatio-----111', currentScrollY, lastScrollY, isScrollingDown)
- lastScrollY = currentScrollY
- entries.forEach((entry: any) => {
- const intersectionRatio = entry.intersectionRatio
- if (isScrollingDown && intersectionRatio >= 0.1) {
- console.log('intersectionRatio-----down')
-
- const newColor = entry.target.dataset.sectionColor
- commonStore.setNavigateBgColor(newColor)
- }
- if (!isScrollingDown && intersectionRatio >= 0.1) {
- console.log('intersectionRatio-----up', entry.target)
-
- const newColor = entry.target.dataset.sectionColor
- commonStore.setNavigateBgColor(newColor)
- }
- })
- }
-
- const observer = new IntersectionObserver(intersectionCallback, observerOptions)
-
- sections.forEach(section => observer.observe(section))
-
-
-
-
-
-
-
- onUnmounted(() => {
- observer.disconnect()
- })
- })
- </script>
- <template>
- <div>
- <business-home-banner />
- <business-home-solutions />
- <common-block-catalogs />
- <common-block-partner />
- <common-block-exhibited />
- <common-block-blog />
- <common-block-faq />
- <AppFooter />
- </div>
- </template>
- <style lang="less" scoped></style>
|