Skip to content

Commit 2a99e70

Browse files
committed
Correction de soucis avec le carousel et avec sal.js.
1 parent 8073f79 commit 2a99e70

File tree

3 files changed

+60
-23
lines changed

3 files changed

+60
-23
lines changed

components/Page/Carousel/Carousel.vue

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,20 @@ const slides = [
5050
</p>`
5151
}
5252
]
53+
54+
const root = ref<HTMLDivElement>()
55+
56+
onMounted(async () => {
57+
await nextTick()
58+
// @ts-ignore
59+
const bootstrap = await import('bootstrap')
60+
// eslint-disable-next-line
61+
new bootstrap.Carousel(root.value)
62+
})
5363
</script>
5464

5565
<template>
56-
<div id="page-carousel" class="carousel carousel-dark slide stripes" data-bs-ride="carousel">
66+
<div id="page-carousel" ref="root" class="carousel carousel-dark slide stripes" data-bs-ride="carousel">
5767
<div class="carousel-indicators">
5868
<button
5969
v-for="(slide, index) in slides"

components/Page/Navbar/PageNavbar.vue

Lines changed: 33 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
<script lang="ts">
2-
export const fullHeight = 130
32
export const shrinkedHeight = 70
43
</script>
54

@@ -10,34 +9,46 @@ import LessonListModal from '~/components/Page/Navbar/LessonListModal.vue'
109
import LessonListDropdown from '~/components/Page/Navbar/LessonListDropdown.vue'
1110
1211
const heightDelta = ref<number>(0)
13-
const currentTopOffset = ref<number>(0)
12+
1413
const navbar = ref<ComponentPublicInstance | null>(null)
1514
1615
onMounted(async () => {
1716
await nextTick()
1817
18+
handleResize()
19+
})
20+
21+
onBeforeMount(() => {
22+
window.addEventListener('resize', handleResize)
23+
window.addEventListener('scroll', handleScroll)
24+
})
25+
onBeforeUnmount(() => {
26+
window.removeEventListener('resize', handleResize)
27+
window.removeEventListener('scroll', handleScroll)
28+
})
29+
30+
const handleResize = () => {
31+
const windowsWidth = window.innerWidth
32+
const fullHeight = windowsWidth < 768 ? 70 : 130
33+
1934
navbar.value!.$el.setAttribute('style', `--height: ${fullHeight}px; --shrinked-height: ${shrinkedHeight}px`)
20-
navbar.value!.$el.setAttribute('data-height', fullHeight.toString())
21-
navbar.value!.$el.setAttribute('data-shrinked-height', shrinkedHeight.toString())
22-
const spacer = document.createElement('div')
23-
spacer.classList.add('bg-primary')
24-
spacer.setAttribute('id', 'page-navbar-spacer')
35+
let spacer = document.getElementById('page-navbar-spacer')
36+
if (!spacer) {
37+
spacer = document.createElement('div')
38+
spacer.classList.add('bg-primary')
39+
spacer.setAttribute('id', 'page-navbar-spacer')
40+
navbar.value!.$el.parentNode.insertBefore(spacer, navbar.value!.$el)
41+
}
2542
spacer.style.height = `${fullHeight}px`
2643
27-
navbar.value!.$el.parentNode.insertBefore(spacer, navbar.value!.$el)
28-
2944
document.documentElement.scrollTop = Math.max(document.documentElement.scrollTop - fullHeight, 0)
3045
3146
heightDelta.value = fullHeight - shrinkedHeight
32-
})
33-
34-
onBeforeMount(() => window.addEventListener('scroll', handleScroll))
35-
onBeforeUnmount(() => window.removeEventListener('scroll', handleScroll))
36-
37-
watch(currentTopOffset, value => navbar.value?.$el.classList.toggle('shrinked', value > heightDelta.value))
47+
}
3848
3949
const handleScroll = () => {
40-
currentTopOffset.value = document.documentElement.scrollTop
50+
const scrollTop = document.documentElement.scrollTop
51+
navbar.value?.$el.classList.toggle('shrinked', scrollTop > heightDelta.value)
4152
}
4253
</script>
4354

@@ -47,9 +58,9 @@ const handleScroll = () => {
4758
id="page-navbar"
4859
ref="navbar"
4960
brightness="primary"
50-
class="navbar-dark"
61+
theme="dark"
5162
>
52-
<ski-navbar-collapse id="page-navbar-collapse" class="collapse-container">
63+
<ski-navbar-collapse id="page-navbar-collapse">
5364
<ski-navbar-items class="ms-auto ms-lg-0">
5465
<ski-navbar-item class="page-navbar-item" to="/" :active="$route.path === '/'">
5566
<ski-icon icon="house-door-fill" /> Accueil
@@ -97,8 +108,8 @@ $shrinked-shadow: 0 0 20px rgba(black, 0.2);
97108
position: relative;
98109
99110
&.collapsing, &.show {
100-
margin-left: -40px;
101-
margin-right: -40px;
111+
margin-left: -20px;
112+
margin-right: -20px;
102113
// box-shadow: $shrinked-shadow;
103114
}
104115
@@ -126,9 +137,10 @@ $shrinked-shadow: 0 0 20px rgba(black, 0.2);
126137
}
127138
128139
@include media-breakpoint-down(lg) {
140+
background-color: darken($primary, 5%);
141+
129142
.page-navbar-item {
130143
padding: 10px 20px;
131-
background-color: darken($primary, 5%);
132144
133145
:deep(a) {
134146
padding: 10px;

composables/useSal.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,24 @@
11
import sal from 'sal.js'
22

33
export const useSal = () => {
4-
onMounted(() => {
4+
onMounted(async () => {
55
import('sal.js/dist/sal.css')
66
// @ts-ignore
77
sal({ threshold: window.outerWidth <= 768 ? 0.1 : 0.25 })
8+
await nextTick()
9+
const handled: HTMLElement[] = []
10+
const salElements = document.querySelectorAll('[data-sal]')
11+
for (const salElement of salElements) {
12+
const parent = salElement.parentElement
13+
if (!parent || handled.includes(parent)) {
14+
continue
15+
}
16+
const previousOverflowX = parent.style.overflowX
17+
parent.style.overflowX = 'hidden'
18+
parent.addEventListener('sal:in', () => {
19+
parent.style.overflowX = previousOverflowX
20+
})
21+
handled.push(parent)
22+
}
823
})
924
}

0 commit comments

Comments
 (0)