mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
accourse stickyNav: insert a component, replace deprecated anchor name by id
This commit is contained in:
parent
ee3776288b
commit
f93c13234a
@ -80,7 +80,7 @@ export default {
|
|||||||
left: -22px;
|
left: -22px;
|
||||||
top: 4px;
|
top: 4px;
|
||||||
}
|
}
|
||||||
a[name^="section"] {
|
a[id^="section"] {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: -2.5em; // reference for stickNav
|
top: -2.5em; // reference for stickNav
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
<h2><a name="section-80"></a>{{ $t('comment.title') }}</h2>
|
<h2><a id="section-90"></a>{{ $t('comment.title') }}</h2>
|
||||||
|
|
||||||
<!--div class="error flash_message" v-if="errors.length > 0">
|
<!--div class="error flash_message" v-if="errors.length > 0">
|
||||||
{{ errors[0] }}
|
{{ errors[0] }}
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
<h2><a name="section-90"></a>
|
<h2><a id="section-100"></a>
|
||||||
{{ $t('confirm.title') }}
|
{{ $t('confirm.title') }}
|
||||||
</h2>
|
</h2>
|
||||||
<div>
|
<div>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
<h2><a name="section-20"></a>
|
<h2><a id="section-20"></a>
|
||||||
{{ $t('courselocation.title') }}
|
{{ $t('courselocation.title') }}
|
||||||
</h2>
|
</h2>
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
<h2><a name="section-30"></a>{{ $t('origin.title') }}</h2>
|
<h2><a id="section-30"></a>{{ $t('origin.title') }}</h2>
|
||||||
|
|
||||||
<div class="mb-4">
|
<div class="mb-4">
|
||||||
<label for="selectOrigin">
|
<label for="selectOrigin">
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
<h2><a name="section-10"></a>{{ $t('persons_associated.title')}}</h2>
|
<h2><a id="section-10"></a>{{ $t('persons_associated.title')}}</h2>
|
||||||
|
|
||||||
<div v-if="currentParticipations.length > 0">
|
<div v-if="currentParticipations.length > 0">
|
||||||
<label class="col-form-label">{{ $tc('persons_associated.counter', counter) }}</label>
|
<label class="col-form-label">{{ $tc('persons_associated.counter', counter) }}</label>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
<h2><a name="section-60"></a>{{ $t('referrer.title') }}</h2>
|
<h2><a id="section-70"></a>{{ $t('referrer.title') }}</h2>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<label class="col-form-label" for="selectReferrer">
|
<label class="col-form-label" for="selectReferrer">
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
|
|
||||||
<h2><a name="section-40"></a>{{ $t('requestor.title') }}</h2>
|
<h2><a id="section-40"></a>{{ $t('requestor.title') }}</h2>
|
||||||
|
|
||||||
<div v-if="accompanyingCourse.requestor" class="flex-table">
|
<div v-if="accompanyingCourse.requestor" class="flex-table">
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
|
|
||||||
<h2><a name="section-70"></a>{{ $t('resources.title')}}</h2>
|
<h2><a id="section-80"></a>{{ $t('resources.title')}}</h2>
|
||||||
|
|
||||||
<div v-if="resources.length > 0">
|
<div v-if="resources.length > 0">
|
||||||
<label class="col-form-label">{{ $tc('resources.counter', counter) }}</label>
|
<label class="col-form-label">{{ $tc('resources.counter', counter) }}</label>
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
<h2><a name="section-65"></a>{{ $t('scopes.title') }}</h2>
|
<h2><a id="section-60"></a>{{ $t('scopes.title') }}</h2>
|
||||||
|
|
||||||
<ul>
|
<ul>
|
||||||
<li v-for="s in scopes">
|
<li v-for="s in scopes">
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="vue-component">
|
<div class="vue-component">
|
||||||
<h2><a name="section-50"></a>{{ $t('social_issue.title') }}</h2>
|
<h2><a id="section-50"></a>{{ $t('social_issue.title') }}</h2>
|
||||||
|
|
||||||
<div class="my-4">
|
<div class="my-4">
|
||||||
<!--label for="field">{{ $t('social_issue.label') }}</label
|
<!--label for="field">{{ $t('social_issue.label') }}</label
|
||||||
|
@ -62,42 +62,42 @@ export default {
|
|||||||
// load datas DOM when mounted ready
|
// load datas DOM when mounted ready
|
||||||
this.container = document.querySelector("#content");
|
this.container = document.querySelector("#content");
|
||||||
this.stickyNav = document.querySelector('#navmap');
|
this.stickyNav = document.querySelector('#navmap');
|
||||||
this.anchors = document.querySelectorAll("h2 a[name^='section']");
|
this.anchors = document.querySelectorAll("h2 a[id^='section']");
|
||||||
this.initItemsMap();
|
this.initItemsMap();
|
||||||
|
|
||||||
// TODO resizeObserver not supports IE !
|
// TODO resizeObserver not supports IE !
|
||||||
// Listen when elements change size, then recalculate heightSum and initItemsMap
|
// Listen when elements change size, then recalculate heightSum and initItemsMap
|
||||||
const resizeObserver = new ResizeObserver(entries => {
|
const resizeObserver = new ResizeObserver(entries => {
|
||||||
this.refreshPos();
|
this.refreshPos();
|
||||||
});
|
});
|
||||||
|
|
||||||
resizeObserver.observe(this.header);
|
resizeObserver.observe(this.header);
|
||||||
resizeObserver.observe(this.bannerName);
|
resizeObserver.observe(this.bannerName);
|
||||||
resizeObserver.observe(this.bannerDetails);
|
resizeObserver.observe(this.bannerDetails);
|
||||||
resizeObserver.observe(this.container);
|
resizeObserver.observe(this.container);
|
||||||
},
|
},
|
||||||
initItemsMap() {
|
initItemsMap() {
|
||||||
|
|
||||||
this.anchors.forEach(anchor => {
|
this.anchors.forEach(anchor => {
|
||||||
this.items.push({
|
this.items.push({
|
||||||
pos: null,
|
pos: null,
|
||||||
active: false,
|
active: false,
|
||||||
key: parseInt(anchor.name.slice(8).slice(0, -1)),
|
key: parseInt(anchor.id.slice(8).slice(0, -1)),
|
||||||
name: '#' + anchor.name
|
id: '#' + anchor.id
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
refreshPos() {
|
refreshPos() {
|
||||||
|
|
||||||
//console.log('refreshPos');
|
//console.log('refreshPos');
|
||||||
this.heightSum = this.header.offsetHeight + this.bannerName.offsetHeight + this.bannerDetails.offsetHeight;
|
this.heightSum = this.header.offsetHeight + this.bannerName.offsetHeight + this.bannerDetails.offsetHeight;
|
||||||
|
|
||||||
this.anchors.forEach((anchor, i) => {
|
this.anchors.forEach((anchor, i) => {
|
||||||
this.items[i].pos = this.findPos(anchor)['y'];
|
this.items[i].pos = this.findPos(anchor)['y'];
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
findPos(element) {
|
findPos(element) {
|
||||||
|
|
||||||
let posX = 0, posY = 0;
|
let posX = 0, posY = 0;
|
||||||
do {
|
do {
|
||||||
posX += element.offsetLeft;
|
posX += element.offsetLeft;
|
||||||
@ -105,38 +105,38 @@ export default {
|
|||||||
element = element.offsetParent;
|
element = element.offsetParent;
|
||||||
}
|
}
|
||||||
while( element != null );
|
while( element != null );
|
||||||
|
|
||||||
let pos = [];
|
let pos = [];
|
||||||
pos['x'] = posX;
|
pos['x'] = posX;
|
||||||
pos['y'] = posY;
|
pos['y'] = posY;
|
||||||
|
|
||||||
return pos;
|
return pos;
|
||||||
},
|
},
|
||||||
handleScroll(event) {
|
handleScroll(event) {
|
||||||
|
|
||||||
let pos = this.findPos(this.stickyNav);
|
let pos = this.findPos(this.stickyNav);
|
||||||
let top = this.heightSum + this.top - window.scrollY;
|
let top = this.heightSum + this.top - window.scrollY;
|
||||||
//console.log(window.scrollY);
|
//console.log(window.scrollY);
|
||||||
|
|
||||||
if (top > this.limit) {
|
if (top > this.limit) {
|
||||||
this.stickyNav.style.position = 'absolute';
|
this.stickyNav.style.position = 'absolute';
|
||||||
this.stickyNav.style.left = '10px';
|
this.stickyNav.style.left = '10px';
|
||||||
} else {
|
} else {
|
||||||
this.stickyNav.style.position = 'fixed';
|
this.stickyNav.style.position = 'fixed';
|
||||||
this.stickyNav.style.left = pos['x'] + 'px';
|
this.stickyNav.style.left = pos['x'] + 'px';
|
||||||
}
|
}
|
||||||
|
|
||||||
this.switchActive();
|
this.switchActive();
|
||||||
},
|
},
|
||||||
switchActive() {
|
switchActive() {
|
||||||
|
|
||||||
this.items.forEach((item, i) => {
|
this.items.forEach((item, i) => {
|
||||||
let next = (this.items[i+1]) ? this.items[i+1].pos : '100000';
|
let next = (this.items[i+1]) ? this.items[i+1].pos : '100000';
|
||||||
item.active =
|
item.active =
|
||||||
(window.scrollY >= item.pos & window.scrollY < next) ? true : false;
|
(window.scrollY >= item.pos & window.scrollY < next) ? true : false;
|
||||||
}, this);
|
}, this);
|
||||||
|
|
||||||
// last item never switch active because scroll reach bottom of page
|
// last item never switch active because scroll reach bottom of page
|
||||||
if (document.body.scrollHeight == window.scrollY + window.innerHeight) {
|
if (document.body.scrollHeight == window.scrollY + window.innerHeight) {
|
||||||
this.items[this.items.length-1].active = true;
|
this.items[this.items.length-1].active = true;
|
||||||
this.items[this.items.length-2].active = false;
|
this.items[this.items.length-2].active = false;
|
||||||
@ -151,7 +151,7 @@ export default {
|
|||||||
<style lang="scss">
|
<style lang="scss">
|
||||||
div#content {
|
div#content {
|
||||||
position: relative;
|
position: relative;
|
||||||
|
|
||||||
div#navmap {
|
div#navmap {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 30px;
|
top: 30px;
|
||||||
@ -170,7 +170,7 @@ div#content {
|
|||||||
span {
|
span {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
&:hover,
|
&:hover,
|
||||||
&.active {
|
&.active {
|
||||||
span {
|
span {
|
||||||
display: inline;
|
display: inline;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
<template>
|
<template>
|
||||||
<a
|
<a
|
||||||
v-if="item.key <= 7"
|
v-if="item.key <= 8"
|
||||||
:href="item.name"
|
:href="item.id"
|
||||||
:class="{ 'active': isActive }"
|
:class="{ 'active': isActive }"
|
||||||
>
|
>
|
||||||
<i class="fa fa-fw fa-square"></i>
|
<i class="fa fa-fw fa-square"></i>
|
||||||
@ -9,7 +9,7 @@
|
|||||||
</a>
|
</a>
|
||||||
<a
|
<a
|
||||||
v-else-if="step === 'DRAFT'"
|
v-else-if="step === 'DRAFT'"
|
||||||
:href="item.name"
|
:href="item.id"
|
||||||
:class="{ 'active': isActive }"
|
:class="{ 'active': isActive }"
|
||||||
>
|
>
|
||||||
<i class="fa fa-fw fa-square"></i>
|
<i class="fa fa-fw fa-square"></i>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user