Compare commits
No commits in common. "9370996c0383730f669697939d8064ef5aa4bc09" and "c82fc633aafc001e500a127a356e141d5ccdb8fc" have entirely different histories.
9370996c03
...
c82fc633aa
|
@ -269,7 +269,7 @@ display:
|
|||
popupAnchor:
|
||||
x: ''
|
||||
'y': ''
|
||||
html: "<div></div>\r\n<div></div>\r\n<div></div>\r\n<div class=\"url\">[node:url]</div>\r\n<div class=\"couleur\">[node:field_couleur]</div>"
|
||||
html: "<div></div>\r\n<div></div>\r\n<div></div>\r\n<div class=\"nid\">{{ nid }}</div>\r\n<div class=\"couleur\">{{ field_couleur }}</div>"
|
||||
html_class: 'leaflet-map-divicon '
|
||||
circle_marker_options: '{"radius":100,"color":"red","fillColor":"#f03","fillOpacity":0.5}'
|
||||
leaflet_markercluster:
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { initVueContentModale } from './utils/vue-setup';
|
||||
import { processClickableElements } from './utils/process-clickable-elements';
|
||||
import { handleReactiveness, setMenuToggle, setHamburgerWhenLogged } from './utils/layout-setup';
|
||||
import { initFirstLoadRouting, handleClickableElements, handleBrowserNavigation } from './utils/handle-navigation';
|
||||
import { initFirstLoadRouting, handleClickableElements } from './utils/handle-navigation';
|
||||
import { setupMapStore } from './utils/map-setup';
|
||||
|
||||
import '../scss/main.scss'
|
||||
|
@ -39,10 +39,6 @@ import '../scss/main.scss'
|
|||
initFirstLoadRouting(store, router, baseUrl, siteName);
|
||||
|
||||
handleClickableElements(clickableElements, store, router, baseUrl, siteName, mapStore);
|
||||
|
||||
window.addEventListener("popstate", () => {
|
||||
handleBrowserNavigation(store, baseUrl, siteName, mapStore);
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
|
@ -38,13 +38,21 @@ export const useLayoutStore = defineStore('layout', {
|
|||
const menuH2 = document.querySelector('#menu > h2');
|
||||
|
||||
menuBurger.addEventListener('click', (e) => {
|
||||
this.toggleHamburgerMenu(menuBurger, menuContainer, menuTitle, menuH2);
|
||||
});
|
||||
setTimeout(() => {
|
||||
if (!this.isHamburgerMenuOpen) menuContainer.style.display = 'block';
|
||||
menuContainer.classList.toggle('open');
|
||||
menuTitle.classList.toggle('open');
|
||||
menuBurger.classList.toggle('open');
|
||||
menuH2.classList.toggle('open');
|
||||
if (this.isHamburgerMenuOpen) {
|
||||
setTimeout(() => {
|
||||
menuContainer.style.display = 'none';
|
||||
this.isHamburgerMenuOpen = !this.isHamburgerMenuOpen;
|
||||
}, 300);
|
||||
}
|
||||
}, 50);
|
||||
document.addEventListener('click', (e) => {
|
||||
if (
|
||||
(!menuContainer.contains(e.target) && !menuBurger.contains(e.target))
|
||||
|| e.target.tagName === 'A'
|
||||
) {
|
||||
if (!menuContainer.contains(e.target) && !menuBurger.contains(e.target)) {
|
||||
menuContainer.classList.remove('open');
|
||||
menuTitle.classList.remove('open');
|
||||
menuBurger.classList.remove('open');
|
||||
|
@ -53,29 +61,11 @@ export const useLayoutStore = defineStore('layout', {
|
|||
if (this.isHamburgerMenuOpen) {
|
||||
menuContainer.style.display = 'none';
|
||||
}
|
||||
}, 300);
|
||||
this.isHamburgerMenuOpen = false;
|
||||
}, 300);
|
||||
}
|
||||
});
|
||||
},
|
||||
toggleHamburgerMenu(menuBurger, menuContainer, menuTitle, menuH2) {
|
||||
setTimeout(() => {
|
||||
if (!this.isHamburgerMenuOpen) menuContainer.style.display = 'block';
|
||||
menuContainer.classList.toggle('open');
|
||||
menuTitle.classList.toggle('open');
|
||||
menuBurger.classList.toggle('open');
|
||||
menuH2.classList.toggle('open');
|
||||
// console.log('isHamburgerMenuOpen', this.isHamburgerMenuOpen);
|
||||
console.log(this.isHamburgerMenuOpen);
|
||||
if (this.isHamburgerMenuOpen) {
|
||||
setTimeout(() => {
|
||||
menuContainer.style.display = 'none';
|
||||
}, 300);
|
||||
}
|
||||
console.log('TOGGLE', this.isHamburgerMenuOpen);
|
||||
console.log('isHamburgerMenuOpen', this.isHamburgerMenuOpen);
|
||||
this.isHamburgerMenuOpen = !this.isHamburgerMenuOpen;
|
||||
}, 50);
|
||||
});
|
||||
}
|
||||
},
|
||||
})
|
|
@ -10,30 +10,23 @@ export const useMapStore = defineStore('mapState', {
|
|||
currentPlace: Object,
|
||||
maxZoom: Number,
|
||||
currentZoom: Number,
|
||||
animationsAreEnabled: true,
|
||||
animationDuration: 3,
|
||||
duration: 3,
|
||||
}),
|
||||
actions: {
|
||||
zoomToPlace(lat, long) {
|
||||
if (useLayoutStore().isDesktop) long = long - 0.03;
|
||||
this.map.flyTo(
|
||||
[lat, long],
|
||||
this.maxZoom,
|
||||
{ animate: this.animationsAreEnabled, animationDuration: this.animationDuration });
|
||||
this.map.flyTo([lat, long], this.maxZoom, { duration: this.duration });
|
||||
this.currentZoom = this.maxZoom;
|
||||
},
|
||||
resetMap() {
|
||||
this.map.flyTo(
|
||||
this.defaultMapCenter,
|
||||
useLayoutStore().isDesktop ? this.defaultZoomDesktop : this.defaultZoomMobile,
|
||||
{ animate: this.animationsAreEnabled, animationDuration: this.animationDuration });
|
||||
this.map.flyTo(this.defaultMapCenter, useLayoutStore().isDesktop ? this.defaultZoomDesktop : this.defaultZoomMobile, { duration: this.duration });
|
||||
this.currentZoom = useLayoutStore().isDesktop ? this.defaultZoomDesktop : this.defaultZoomMobile;
|
||||
},
|
||||
lockMap() {
|
||||
setTimeout(() => {
|
||||
this.map.options.minZoom = this.currentZoom;
|
||||
this.map.options.maxZoom = this.currentZoom;
|
||||
}, this.animationDuration * 1000 + 100);
|
||||
}, this.duration * 1000 + 100);
|
||||
this.map.dragging.disable();
|
||||
this.map.touchZoom.disable();
|
||||
this.map.doubleClickZoom.disable();
|
||||
|
@ -53,16 +46,5 @@ export const useMapStore = defineStore('mapState', {
|
|||
this.map.keyboard.enable();
|
||||
// map.tap.enable();
|
||||
},
|
||||
toggleAnimation() {
|
||||
this.animationsAreEnabled = !this.animationsAreEnabled;
|
||||
},
|
||||
checkReducedMotion() {
|
||||
const mediaQuery = window.matchMedia('(prefers-reduced-motion: reduce)');
|
||||
this.animationsAreEnabled = !mediaQuery.matches;
|
||||
|
||||
mediaQuery.addEventListener('change', (event) => {
|
||||
this.animationsAreEnabled = !event.matches;
|
||||
});
|
||||
},
|
||||
},
|
||||
});
|
|
@ -23,19 +23,6 @@ export function handleClickableElements(clickableElements, store, router, baseUr
|
|||
link.onclick = async function (e) {
|
||||
router.push(href);
|
||||
if (href !== window.location.pathname) {
|
||||
pageChange(href, store, siteName, mapStore, baseUrl);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
export async function handleBrowserNavigation(store, baseUrl, siteName, mapStore) {
|
||||
let href = window.location.pathname;
|
||||
if (href.startsWith(baseUrl)) href = href.replace(baseUrl, '');
|
||||
pageChange(href, store, siteName, mapStore, baseUrl)
|
||||
}
|
||||
|
||||
async function pageChange(href, store, siteName, mapStore, baseUrl) {
|
||||
if (href === '/') {
|
||||
store.resetStore(true);
|
||||
document.title = siteName;
|
||||
|
@ -48,4 +35,7 @@ async function pageChange(href, store, siteName, mapStore, baseUrl) {
|
|||
|
||||
const listeEtape = document.querySelector('#etapes-liste');
|
||||
if (!useLayoutStore().isDesktop) useLayoutStore().collapseEtapeListe(listeEtape);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -26,6 +26,14 @@ function processEtapeLinks() {
|
|||
function processStaticLinks() {
|
||||
const general_link_fields = document.querySelectorAll('#menu > ul > li > a');
|
||||
for (let i = 0; i < general_link_fields.length; i ++) {
|
||||
let general_link_path = general_link_fields[i].getAttribute('data-drupal-link-system-path');
|
||||
if (general_link_path && general_link_path !== '<front>') {
|
||||
const match = [...general_link_path.match(/^node\/(\d+)$/)];
|
||||
if (match) {
|
||||
const nid = match[1];
|
||||
general_link_fields[i].setAttribute('data-nid', parseInt(nid));
|
||||
}
|
||||
}
|
||||
general_link_fields[i].addEventListener('click', (e) => e.preventDefault());
|
||||
}
|
||||
|
||||
|
|
|
@ -2,7 +2,6 @@ import { createApp } from 'vue';
|
|||
import { createPinia } from 'pinia';
|
||||
import router from '../router/router';
|
||||
import Modale from '../vuejs/Modale.vue';
|
||||
import AnimationToggle from '../vuejs/AnimationToggle.vue';
|
||||
import VueImageZoomer from 'vue-image-zoomer';
|
||||
import 'vue-image-zoomer/dist/style.css';
|
||||
|
||||
|
@ -10,10 +9,8 @@ import { useContentStore } from '../stores/content';
|
|||
import { useMapStore } from '../stores/map';
|
||||
|
||||
export function initVueContentModale() {
|
||||
const pinia = createPinia();
|
||||
|
||||
const app = createApp(Modale)
|
||||
.use(pinia)
|
||||
.use(createPinia())
|
||||
.use(router)
|
||||
.use(VueImageZoomer);
|
||||
|
||||
|
@ -21,9 +18,5 @@ export function initVueContentModale() {
|
|||
const mapStore = useMapStore();
|
||||
app.mount('#content-modale');
|
||||
|
||||
const animationToggle = createApp(AnimationToggle)
|
||||
.use(pinia)
|
||||
.mount('#animation-toggle');
|
||||
|
||||
return { store, mapStore, router };
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
<template>
|
||||
<div @click="handleClick" class="animation-toggle-container">
|
||||
<div><p>Activer les animations</p></div>
|
||||
<label class="switch">
|
||||
<input type="checkbox" v-model="animationsAreEnabled" @click.stop @change="toggleAnimation" />
|
||||
<span class="slider round"></span>
|
||||
</label>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
|
||||
import { useMapStore } from '../stores/map';
|
||||
import { storeToRefs } from 'pinia';
|
||||
|
||||
export default {
|
||||
setup() {
|
||||
const mapStore = useMapStore();
|
||||
|
||||
const { animationsAreEnabled } = storeToRefs(mapStore);
|
||||
|
||||
const toggleAnimation = () => {
|
||||
mapStore.toggleAnimation();
|
||||
};
|
||||
|
||||
const handleClick = () => {
|
||||
toggleAnimation();
|
||||
};
|
||||
|
||||
return {
|
||||
handleClick,
|
||||
toggleAnimation,
|
||||
animationsAreEnabled,
|
||||
};
|
||||
},
|
||||
};
|
||||
</script>
|
|
@ -1,8 +1,5 @@
|
|||
<template>
|
||||
<Transition
|
||||
:enter-active-class="animationsAreEnabled ? 'v-enter-active' : 'no-transition'"
|
||||
:leave-active-class="animationsAreEnabled ? 'v-leave-active' : 'no-transition'"
|
||||
>
|
||||
<Transition>
|
||||
<div v-if="!loading && (contentType === 'etape' || contentType === 'static')">
|
||||
<div class="content-wrapper">
|
||||
<ModaleHeader
|
||||
|
@ -84,7 +81,7 @@ const {
|
|||
error,
|
||||
} = storeToRefs(store);
|
||||
|
||||
const { defaultMapCenter, animationDuration, animationsAreEnabled } = storeToRefs(mapState);
|
||||
const { map, duration } = storeToRefs(mapState);
|
||||
|
||||
let isModaleEtape, wasModaleEtape;
|
||||
|
||||
|
@ -108,56 +105,30 @@ const handleMapMovement = () => {
|
|||
if (!loading.value) {
|
||||
isModaleEtape = contentType.value === 'etape';
|
||||
|
||||
// Define helper functions in variables
|
||||
const disableModaleTransition = () => {
|
||||
document.documentElement.style.setProperty('margin-top', '0');
|
||||
document.documentElement.style.setProperty('transition', 'none');
|
||||
}
|
||||
const setModaleTransition = (enterDelay) => {
|
||||
document.documentElement.style.setProperty('--modale-enter-delay', `${enterDelay}s`);
|
||||
};
|
||||
if (!wasModaleEtape && isModaleEtape) {
|
||||
// national -> détail
|
||||
document.documentElement.style.setProperty('--modale-enter-delay', `${duration.value}s`);
|
||||
mapState.zoomToPlace(content.value.coordinates.lat, content.value.coordinates.lon);
|
||||
} else if (wasModaleEtape && isModaleEtape) {
|
||||
// détail -> détail
|
||||
document.documentElement.style.setProperty('--modale-leave-delay', 0);
|
||||
document.documentElement.style.setProperty('--modale-enter-delay', `${duration.value * 2}s`);
|
||||
mapState.resetMap(map.value);
|
||||
setTimeout(() => {
|
||||
mapState.zoomToPlace(content.value.coordinates.lat, content.value.coordinates.lon);
|
||||
}, duration.value * 1000);
|
||||
|
||||
const zoomToContentPlace = () => {
|
||||
mapState.zoomToPlace(
|
||||
content.value.coordinates.lat ? content.value.coordinates.lat : defaultMapCenter.value.lat,
|
||||
content.value.coordinates.lon ? content.value.coordinates.lon : defaultMapCenter.value.lng
|
||||
);
|
||||
};
|
||||
|
||||
if (animationsAreEnabled.value) {
|
||||
|
||||
if (isModaleEtape) {
|
||||
if (!wasModaleEtape) {
|
||||
console.log('national -> détail');
|
||||
setModaleTransition(animationDuration.value);
|
||||
zoomToContentPlace();
|
||||
} else {
|
||||
console.log('détail -> détail');
|
||||
setModaleTransition(animationDuration.value);
|
||||
//mapState.resetMap();
|
||||
zoomToContentPlace();
|
||||
//setTimeout(zoomToContentPlace, animationDuration.value * 1000);
|
||||
}
|
||||
} else {
|
||||
if (wasModaleEtape) {
|
||||
console.log('détail -> national');
|
||||
setModaleTransition(animationDuration.value);
|
||||
} else if (wasModaleEtape && !isModaleEtape) {
|
||||
// détail -> national
|
||||
document.documentElement.style.setProperty('--modale-leave-delay', 0);
|
||||
document.documentElement.style.setProperty('--modale-enter-delay', `${duration.value}s`);
|
||||
mapState.resetMap();
|
||||
} else {
|
||||
} else if (!wasModaleEtape && !isModaleEtape) {
|
||||
// national -> national
|
||||
console.log('national -> national');
|
||||
setModaleTransition(0);
|
||||
document.documentElement.style.setProperty('--modale-leave-delay', 0);
|
||||
document.documentElement.style.setProperty('--modale-enter-delay', '0.5s');
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (isModaleEtape) {
|
||||
zoomToContentPlace();
|
||||
} else {
|
||||
mapState.resetMap();
|
||||
}
|
||||
disableModaleTransition();
|
||||
}
|
||||
|
||||
scrollTo(0, 0);
|
||||
|
||||
wasModaleEtape = isModaleEtape;
|
||||
}
|
||||
|
@ -179,7 +150,7 @@ onMounted(() => {
|
|||
}
|
||||
|
||||
.v-leave-active {
|
||||
transition: margin-top 0.5s ease-in;
|
||||
transition: margin-top 0.5s ease-in var(--modale-leave-delay);
|
||||
}
|
||||
|
||||
.v-enter-from,
|
||||
|
@ -191,10 +162,4 @@ onMounted(() => {
|
|||
.v-leave-from {
|
||||
margin-top: 0vh;
|
||||
}
|
||||
|
||||
/* This class will disable transitions */
|
||||
.no-transition {
|
||||
margin-top: 0 !important;
|
||||
transition: none !important;
|
||||
}
|
||||
</style>
|
|
@ -5,7 +5,7 @@
|
|||
</div>
|
||||
|
||||
<div v-if="contentType === 'etape' && (content.previous || content.next)" class="related-etape-links">
|
||||
<div v-if="content.previous" class="card previous" @click="clickRelatedElement(content.previous.url)">
|
||||
<div v-if="content.previous" class="card previous" @click="displayRelatedElement(content.previous.url)">
|
||||
<div class="icon">
|
||||
<div :style="{ backgroundColor: content.previous.couleur }"></div>
|
||||
<div :style="{ backgroundColor: content.previous.couleur }"></div>
|
||||
|
@ -21,7 +21,7 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div v-if="content.next" class="card next" @click="clickRelatedElement(content.next.url)">
|
||||
<div v-if="content.next" class="card next" @click="displayRelatedElement(content.next.url)">
|
||||
<div class="icon">
|
||||
<div :style="{ backgroundColor: content.next.couleur }"></div>
|
||||
<div :style="{ backgroundColor: content.next.couleur }"></div>
|
||||
|
@ -63,13 +63,4 @@ async function displayRelatedElement(href) {
|
|||
await store.fetchContentData(baseUrl + href);
|
||||
document.title = store.pageTitle;
|
||||
}
|
||||
|
||||
import { setActiveNavItem } from '../../utils/set-active-nav-item.js';
|
||||
|
||||
function clickRelatedElement(href) {
|
||||
const baseUrl = window.location.protocol + "//" + window.location.host;
|
||||
if (href.startsWith(baseUrl)) href = href.replace(baseUrl, '');
|
||||
setActiveNavItem('etape', href);
|
||||
displayRelatedElement(href);
|
||||
}
|
||||
</script>
|
|
@ -597,7 +597,6 @@ body{
|
|||
margin: 30px 0;
|
||||
transform: scale(1);
|
||||
opacity: 1;
|
||||
padding-right: 0.5rem;
|
||||
transition: transform 0.3s ease-out, opacity 0.3s ease-out;
|
||||
cursor: pointer;
|
||||
> .infos-arret {
|
||||
|
@ -1179,75 +1178,6 @@ body{
|
|||
}
|
||||
}
|
||||
}
|
||||
> #animation-toggle > div {
|
||||
cursor: pointer;
|
||||
position: fixed;
|
||||
bottom: $body-margin-bottom;
|
||||
right: $body-margin-x;
|
||||
z-index: 999;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
padding: 0.4rem 1.2rem;
|
||||
border-radius: 10rem;
|
||||
background-color: white;
|
||||
transition: background-color 0.3s ease-out;
|
||||
|
||||
> div {
|
||||
margin-right: 1rem;
|
||||
> p {
|
||||
font-size: $sm-font-size-mobile;
|
||||
@media screen and (min-width: $desktop-min-width) {
|
||||
font-size: $sm-font-size-desktop;
|
||||
}
|
||||
}
|
||||
}
|
||||
> .switch {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
width: 2.2rem;
|
||||
height: 1.2rem;
|
||||
> input {
|
||||
opacity: 0;
|
||||
width: 0;
|
||||
height: 0;
|
||||
&:checked + .slider {
|
||||
background-color: $brand-color;
|
||||
}
|
||||
&:focus + .slider {
|
||||
box-shadow: 0 0 1px $brand-color;
|
||||
}
|
||||
&:checked + .slider::before {
|
||||
-webkit-transform: translateX(1rem);
|
||||
-ms-transform: translateX(1rem);
|
||||
transform: translateX(1rem);
|
||||
}
|
||||
}
|
||||
> .slider {
|
||||
position: absolute;
|
||||
cursor: pointer;
|
||||
top: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
bottom: 0;
|
||||
border-radius: 34px;
|
||||
background-color: $main-color-light;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
&::before {
|
||||
position: absolute;
|
||||
content: "";
|
||||
height: 1rem;
|
||||
width: 1rem;
|
||||
border-radius: 50%;
|
||||
left: 0.1rem;
|
||||
bottom: 0.1rem;
|
||||
background-color: $light-color;
|
||||
-webkit-transition: .4s;
|
||||
transition: .4s;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
> .user-login-form {
|
||||
height: 90vh;
|
||||
|
|
|
@ -52,6 +52,5 @@
|
|||
</div>
|
||||
{% endif %}
|
||||
<div id="content-modale"></div>
|
||||
<div id="animation-toggle"></div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
|
Loading…
Reference in New Issue