concernement on map hover effect, better mappopup
This commit is contained in:
parent
19da070e31
commit
453e07ec31
@ -112,13 +112,68 @@ body{
|
|||||||
|
|
||||||
#map-popup{
|
#map-popup{
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
z-index: 10;
|
||||||
|
// outline: 1px solid red;
|
||||||
// top:0;
|
// top:0;
|
||||||
// left: 0;
|
// left: 0;
|
||||||
background-color: white;
|
|
||||||
padding: 1em;
|
.popup-content-wrapper{
|
||||||
h1{
|
background-color: white;
|
||||||
font-size: 1em;
|
padding: 1em;
|
||||||
font-weight: 400;
|
border-radius: 3px;
|
||||||
|
// min-width: 10em;
|
||||||
|
// max-width: 30em;
|
||||||
|
h1{
|
||||||
|
font-size: 1em;
|
||||||
|
font-weight: 400;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&:before{
|
||||||
|
content: "";
|
||||||
|
display: block;
|
||||||
|
height: 0;
|
||||||
|
width: 2.9em;
|
||||||
|
border-top: 1px solid #01ffe2;
|
||||||
|
position: absolute;
|
||||||
|
}
|
||||||
|
|
||||||
|
&[pos="top-right"]{
|
||||||
|
padding: 0 0 2em 2em;
|
||||||
|
&:before{
|
||||||
|
bottom: 0;
|
||||||
|
left: 0;
|
||||||
|
transform-origin: 0 0;
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&[pos="bottom-right"]{
|
||||||
|
padding: 2em 0 0 2em;
|
||||||
|
&:before{
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
transform-origin: 0 0;
|
||||||
|
transform: rotate(45deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&[pos="top-left"]{
|
||||||
|
padding: 0 2em 2em 0;
|
||||||
|
&:before{
|
||||||
|
bottom: 0;
|
||||||
|
right: 0;
|
||||||
|
transform-origin: right bottom;
|
||||||
|
transform: rotate(45deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
&[pos="bottom-left"]{
|
||||||
|
padding: 2em 2em 0 0;
|
||||||
|
&:before{
|
||||||
|
top: 0;
|
||||||
|
right: 0;
|
||||||
|
transform-origin: right top;
|
||||||
|
transform: rotate(-45deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import Tween from "@tweenjs/tween.js";
|
|||||||
|
|
||||||
import { mapState, mapActions } from 'pinia'
|
import { mapState, mapActions } from 'pinia'
|
||||||
import { ConcernementsStore } from '@/stores/concernements'
|
import { ConcernementsStore } from '@/stores/concernements'
|
||||||
|
import { CommonStore } from '@/stores/common'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
inject: ['canvasMap', 'matterEngine'],
|
inject: ['canvasMap', 'matterEngine'],
|
||||||
@ -49,14 +50,16 @@ export default {
|
|||||||
tween: null,
|
tween: null,
|
||||||
body: null,
|
body: null,
|
||||||
body_parts: [],
|
body_parts: [],
|
||||||
constraint: null
|
constraint: null,
|
||||||
|
isHover: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
props: ['concernement', 'opened'],
|
props: ['concernement', 'opened'],
|
||||||
computed: {
|
computed: {
|
||||||
...mapState(ConcernementsStore,['map_mode']),
|
...mapState(ConcernementsStore,['map_mode']),
|
||||||
...mapState(ConcernementsStore,['concernementsByID']),
|
...mapState(ConcernementsStore,['concernementsByID']),
|
||||||
...mapState(ConcernementsStore,['opened_entite_id'])
|
...mapState(ConcernementsStore,['opened_entite_id']),
|
||||||
|
...mapState(CommonStore,['hover_elmt'])
|
||||||
},
|
},
|
||||||
created () {
|
created () {
|
||||||
// console.log(`ConcernementsMapItem ${this.concernement.id} created`, this.canvasMap, this.matterEngine);
|
// console.log(`ConcernementsMapItem ${this.concernement.id} created`, this.canvasMap, this.matterEngine);
|
||||||
@ -115,6 +118,17 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
deep: true
|
deep: true
|
||||||
|
},
|
||||||
|
hover_elmt: {
|
||||||
|
handler (n, o) {
|
||||||
|
console.log('watch hover_elmt', o, n);
|
||||||
|
if (n && n.type === 'concernement' && n.id === this.id) {
|
||||||
|
this.isHover = true;
|
||||||
|
} else {
|
||||||
|
this.isHover = false;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
deep: true
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -725,14 +739,18 @@ export default {
|
|||||||
drawContour(){
|
drawContour(){
|
||||||
if (this.salientPoints.length > 3) {
|
if (this.salientPoints.length > 3) {
|
||||||
var fillStyle;
|
var fillStyle;
|
||||||
|
let strokeStyle = "#000";
|
||||||
if (!this.isFocused()){
|
if (!this.isFocused()){
|
||||||
fillStyle = "rgba(255,255,255,0.3)";
|
fillStyle = "rgba(255,255,255,0.3)";
|
||||||
}else{
|
}else{
|
||||||
fillStyle = "rgba(255,255,255,0.8)"
|
fillStyle = "rgba(255,255,255,0.8)"
|
||||||
|
if (this.isHover) {
|
||||||
|
strokeStyle = "#01ffe2";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
this.ctx.beginPath();
|
this.ctx.beginPath();
|
||||||
this.ctx.lineWidth = 1;
|
this.ctx.lineWidth = 1;
|
||||||
this.ctx.strokeStyle = "#000";
|
this.ctx.strokeStyle = strokeStyle;
|
||||||
this.ctx.fillStyle = fillStyle;
|
this.ctx.fillStyle = fillStyle;
|
||||||
this.ctx.moveTo(this.pos.x+this.salientPoints[0].pos.x*this.scale*1.15, this.pos.y+this.salientPoints[0].pos.y*this.scale*1.15)
|
this.ctx.moveTo(this.pos.x+this.salientPoints[0].pos.x*this.scale*1.15, this.pos.y+this.salientPoints[0].pos.y*this.scale*1.15)
|
||||||
for (let j = 1; j < this.salientPoints.length; j++) {
|
for (let j = 1; j < this.salientPoints.length; j++) {
|
||||||
|
@ -57,8 +57,35 @@ export default {
|
|||||||
methods: {
|
methods: {
|
||||||
onMousemove(e){
|
onMousemove(e){
|
||||||
// console.log(`popup move type: ${this.infos.type}`);
|
// console.log(`popup move type: ${this.infos.type}`);
|
||||||
this.dom.style.left = `${e.clientX + 5}px`;
|
let v = "top";
|
||||||
this.dom.style.top = `${e.clientY - this.dom.clientHeight - 5}px`;
|
let h = "right";
|
||||||
|
if (e.clientX + this.dom.clientWidth > document.body.clientWidth) {
|
||||||
|
h = "left";
|
||||||
|
} else {
|
||||||
|
h = "right";
|
||||||
|
}
|
||||||
|
if (e.clientY - this.dom.clientHeight < 0) {
|
||||||
|
v = "bottom";
|
||||||
|
} else {
|
||||||
|
v = "top";
|
||||||
|
}
|
||||||
|
this.dom.setAttribute("pos", `${v}-${h}`);
|
||||||
|
switch (h) {
|
||||||
|
case "right":
|
||||||
|
this.dom.style.left = `${e.clientX}px`;
|
||||||
|
break;
|
||||||
|
case "left":
|
||||||
|
this.dom.style.left = `${e.clientX - this.dom.clientWidth}px`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
switch (v) {
|
||||||
|
case "top":
|
||||||
|
this.dom.style.top = `${e.clientY - this.dom.clientHeight}px`;
|
||||||
|
break;
|
||||||
|
case "bottom":
|
||||||
|
this.dom.style.top = `${e.clientY}px`;
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
components: {
|
components: {
|
||||||
@ -69,18 +96,21 @@ export default {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div id="map-popup" ref="map-popup">
|
<div id="map-popup" ref="map-popup">
|
||||||
<section v-if="infos.type === 'concernement'" class="concernement-map-popup">
|
|
||||||
<h1>{{ concernement.title }}</h1>
|
<div class="popup-content-wrapper">
|
||||||
</section>
|
<section v-if="infos.type === 'concernement'" class="concernement-map-popup">
|
||||||
<section v-if="infos.type === 'entite'" class="entite-map-popup">
|
<h1>{{ concernement.title }}</h1>
|
||||||
<h1>{{ entite.entite.title }}</h1>
|
</section>
|
||||||
</section>
|
<section v-if="infos.type === 'entite'" class="entite-map-popup">
|
||||||
<section v-if="infos.type === 'besoin'" class="besoin-map-popup">
|
<h1>{{ entite.entite.title }}</h1>
|
||||||
<h1>Besoin</h1>
|
</section>
|
||||||
</section>
|
<section v-if="infos.type === 'besoin'" class="besoin-map-popup">
|
||||||
<section v-if="infos.type === 'reponse'" class="reponse-map-popup">
|
<h1>Besoin</h1>
|
||||||
<h1>Réponse</h1>
|
</section>
|
||||||
</section>
|
<section v-if="infos.type === 'reponse'" class="reponse-map-popup">
|
||||||
|
<h1>Réponse</h1>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
@ -29,6 +29,7 @@ Matter.use(MatterAttractors);
|
|||||||
|
|
||||||
import { mapState, mapActions } from 'pinia'
|
import { mapState, mapActions } from 'pinia'
|
||||||
import { ConcernementsStore } from '@/stores/concernements'
|
import { ConcernementsStore } from '@/stores/concernements'
|
||||||
|
import { CommonStore } from '@/stores/common'
|
||||||
|
|
||||||
import ConcernementMapPopup from '@components/ConcernementMapPopup.vue';
|
import ConcernementMapPopup from '@components/ConcernementMapPopup.vue';
|
||||||
|
|
||||||
@ -61,7 +62,8 @@ export default {
|
|||||||
...mapState(ConcernementsStore,['map_mode']),
|
...mapState(ConcernementsStore,['map_mode']),
|
||||||
...mapState(ConcernementsStore,['concernements']),
|
...mapState(ConcernementsStore,['concernements']),
|
||||||
...mapState(ConcernementsStore,['concernementsByID']),
|
...mapState(ConcernementsStore,['concernementsByID']),
|
||||||
...mapState(ConcernementsStore,['opened'])
|
...mapState(ConcernementsStore,['opened']),
|
||||||
|
...mapState(CommonStore,['hover_elmt'])
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
// MATTER
|
// MATTER
|
||||||
@ -109,6 +111,7 @@ export default {
|
|||||||
...mapActions(ConcernementsStore,['setMapMode']),
|
...mapActions(ConcernementsStore,['setMapMode']),
|
||||||
...mapActions(ConcernementsStore,['openCloseConcernements']),
|
...mapActions(ConcernementsStore,['openCloseConcernements']),
|
||||||
...mapActions(ConcernementsStore,['resetConcernementOpened']),
|
...mapActions(ConcernementsStore,['resetConcernementOpened']),
|
||||||
|
...mapActions(CommonStore,['setHoverElmt']),
|
||||||
animate () {
|
animate () {
|
||||||
this.canvasMap.ctx.clearRect(0, 0, this.canvasMap.canvas.width, this.canvasMap.canvas.height)
|
this.canvasMap.ctx.clearRect(0, 0, this.canvasMap.canvas.width, this.canvasMap.canvas.height)
|
||||||
// this.canvasMap.canvas.dispatchEvent(this.animateEvent)
|
// this.canvasMap.canvas.dispatchEvent(this.animateEvent)
|
||||||
@ -132,7 +135,7 @@ export default {
|
|||||||
query = Matter.Query.point(this.world.bodies, this.mouse.position)
|
query = Matter.Query.point(this.world.bodies, this.mouse.position)
|
||||||
}
|
}
|
||||||
|
|
||||||
this.mapPopupData = null;
|
let hover_elmt = null;
|
||||||
if (query && query.length) {
|
if (query && query.length) {
|
||||||
// if we have a results
|
// if we have a results
|
||||||
for (let body of query) {
|
for (let body of query) {
|
||||||
@ -140,7 +143,7 @@ export default {
|
|||||||
&& body.item_type === "concernement" // if it is a concernement
|
&& body.item_type === "concernement" // if it is a concernement
|
||||||
&& typeof this.concernementsByID[body.id] !== "undefined" // if the id exists
|
&& typeof this.concernementsByID[body.id] !== "undefined" // if the id exists
|
||||||
&& !this.concernementsByID[body.id].opened) { // if the concernement is not opened
|
&& !this.concernementsByID[body.id].opened) { // if the concernement is not opened
|
||||||
this.mapPopupData = {
|
hover_elmt = {
|
||||||
type: 'concernement',
|
type: 'concernement',
|
||||||
id: body.id
|
id: body.id
|
||||||
};
|
};
|
||||||
@ -148,14 +151,14 @@ export default {
|
|||||||
if (body.item_type === "entite" // if it is an entite
|
if (body.item_type === "entite" // if it is an entite
|
||||||
&& this.opened // if a concernement is opened
|
&& this.opened // if a concernement is opened
|
||||||
&& typeof this.opened.entites_byid[body.id] !== "undefined") { // if the entity exists
|
&& typeof this.opened.entites_byid[body.id] !== "undefined") { // if the entity exists
|
||||||
this.mapPopupData = {
|
hover_elmt = {
|
||||||
type: 'entite',
|
type: 'entite',
|
||||||
id: body.id
|
id: body.id
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
if (body.item_type === "besoin" // if it is a besoin
|
if (body.item_type === "besoin" // if it is a besoin
|
||||||
&& this.opened) { // if a concernement is opened
|
&& this.opened) { // if a concernement is opened
|
||||||
this.mapPopupData = {
|
hover_elmt = {
|
||||||
type: 'besoin',
|
type: 'besoin',
|
||||||
id: body.id
|
id: body.id
|
||||||
};
|
};
|
||||||
@ -163,15 +166,16 @@ export default {
|
|||||||
|
|
||||||
if (body.item_type === "reponse" // if it is a besoin
|
if (body.item_type === "reponse" // if it is a besoin
|
||||||
&& this.opened) { // if a concernement is opened
|
&& this.opened) { // if a concernement is opened
|
||||||
this.mapPopupData = {
|
hover_elmt = {
|
||||||
type: 'reponse',
|
type: 'reponse',
|
||||||
id: body.id
|
id: body.id
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// console.log(`this.mapPopupData type: ${this.mapPopupData.type}, id: ${this.mapPopupData.id}`);
|
// console.log(`hover_elmt type: ${hover_elmt.type}, id: ${hover_elmt.id}`);
|
||||||
}
|
}
|
||||||
if (this.mapPopupData) {
|
this.setHoverElmt(hover_elmt);
|
||||||
|
if (hover_elmt) {
|
||||||
document.body.style.cursor = "pointer";
|
document.body.style.cursor = "pointer";
|
||||||
} else {
|
} else {
|
||||||
document.body.style.cursor = "auto";
|
document.body.style.cursor = "auto";
|
||||||
@ -293,8 +297,8 @@ export default {
|
|||||||
</ul>
|
</ul>
|
||||||
</nav>
|
</nav>
|
||||||
<ConcernementMapPopup
|
<ConcernementMapPopup
|
||||||
v-if="mapPopupData"
|
v-if="hover_elmt"
|
||||||
:infos="mapPopupData"
|
:infos="hover_elmt"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
|
18
src/stores/common.js
Normal file
18
src/stores/common.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
import { defineStore } from 'pinia'
|
||||||
|
|
||||||
|
export const CommonStore = defineStore({
|
||||||
|
id: 'common',
|
||||||
|
state: () => ({
|
||||||
|
hover_elmt: null
|
||||||
|
}),
|
||||||
|
getters: {
|
||||||
|
|
||||||
|
},
|
||||||
|
actions: {
|
||||||
|
setHoverElmt(elmt) {
|
||||||
|
console.log(`setHoverElmt ${elmt}`);
|
||||||
|
// mode can be : terraindevie, proximite, superposition, puissancedagir, action, doleancer
|
||||||
|
this.hover_elmt = elmt;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
Loading…
x
Reference in New Issue
Block a user