started paperjs events instead of matterjs (query) events
This commit is contained in:
@@ -107,8 +107,8 @@ export default {
|
||||
// add mouse control
|
||||
// https://github.com/liabru/matter-js/issues/491#issuecomment-331329404
|
||||
this.mouse = Matter.Mouse.create(this.canvasMap.canvas);
|
||||
this.canvasMap.canvas.addEventListener('mousemove', this.onMouseMove)
|
||||
this.canvasMap.canvas.addEventListener('click', this.onClick)
|
||||
// this.canvasMap.canvas.addEventListener('mousemove', this.onMouseMove)
|
||||
// this.canvasMap.canvas.addEventListener('click', this.onClick)
|
||||
|
||||
this.animate()
|
||||
},
|
||||
@@ -125,7 +125,7 @@ export default {
|
||||
window.requestAnimationFrame(this.animate);
|
||||
},
|
||||
onMouseMove (e) {
|
||||
this.checkMouseHover();
|
||||
// this.checkMouseHover();
|
||||
},
|
||||
checkMouseHover(){
|
||||
// check item mouse over
|
||||
@@ -149,23 +149,23 @@ export default {
|
||||
// if we have a results
|
||||
for (let body of query) {
|
||||
console.log('mouse hover body.item_type', body.item_type);
|
||||
if (!this.opened // if no concernement is opened
|
||||
&& body.item_type === "concernement" // if it is a concernement
|
||||
&& typeof this.concernementsByID[body.id] !== "undefined" // if the id exists
|
||||
&& !this.concernementsByID[body.id].opened) { // if the concernement is not opened
|
||||
hover_elmt = {
|
||||
type: 'concernement',
|
||||
id: body.id
|
||||
};
|
||||
}
|
||||
if (body.item_type === "entite" // if it is an entite
|
||||
&& this.opened // if a concernement is opened
|
||||
&& typeof this.opened.entites_byid[body.id] !== "undefined") { // if the entity exists
|
||||
hover_elmt = {
|
||||
type: 'entite',
|
||||
id: body.id
|
||||
};
|
||||
}
|
||||
// if (!this.opened // if no concernement is opened
|
||||
// && body.item_type === "concernement" // if it is a concernement
|
||||
// && typeof this.concernementsByID[body.id] !== "undefined" // if the id exists
|
||||
// && !this.concernementsByID[body.id].opened) { // if the concernement is not opened
|
||||
// hover_elmt = {
|
||||
// type: 'concernement',
|
||||
// id: body.id
|
||||
// };
|
||||
// }
|
||||
// if (body.item_type === "entite" // if it is an entite
|
||||
// && this.opened // if a concernement is opened
|
||||
// && typeof this.opened.entites_byid[body.id] !== "undefined") { // if the entity exists
|
||||
// hover_elmt = {
|
||||
// type: 'entite',
|
||||
// id: body.id
|
||||
// };
|
||||
// }
|
||||
if (body.item_type === "besoin" // if it is a besoin
|
||||
&& this.opened) { // if a concernement is opened
|
||||
hover_elmt = {
|
||||
@@ -218,42 +218,42 @@ export default {
|
||||
// no concernement is yet opened, we deal concernements
|
||||
if (!this.opened) {
|
||||
if (query.length) {
|
||||
// open/close all concernements
|
||||
this.openCloseConcernements(query[0].id)
|
||||
// push route (keep the hash for map_mode)
|
||||
this.$router.push({
|
||||
name: 'concernement',
|
||||
hash: `#${this.map_mode}`,
|
||||
params: {id: query[0].id}
|
||||
});
|
||||
// // open/close all concernements
|
||||
// this.openCloseConcernements(query[0].id)
|
||||
// // push route (keep the hash for map_mode)
|
||||
// this.$router.push({
|
||||
// name: 'concernement',
|
||||
// hash: `#${this.map_mode}`,
|
||||
// params: {id: query[0].id}
|
||||
// });
|
||||
}
|
||||
}
|
||||
|
||||
// concernement is already opened, we deal with entités
|
||||
if (this.opened) {
|
||||
if (query.length) {
|
||||
let clickedEntityBodies = [];
|
||||
query.forEach(body => {
|
||||
// console.log('body id:', body.id);
|
||||
if (body.item_type === "entite") {
|
||||
clickedEntityBodies.push(body);
|
||||
}
|
||||
});
|
||||
if (clickedEntityBodies.length) {
|
||||
// we have clicked on an entite
|
||||
this.$router.push({
|
||||
name: 'concernement',
|
||||
hash: `#${this.map_mode}`,
|
||||
params: {id: this.opened.id, eid: clickedEntityBodies[0].id}
|
||||
});
|
||||
} else {
|
||||
// otherwise we close the entite and come back to the concernement
|
||||
this.$router.push({
|
||||
name: 'concernement',
|
||||
hash: `#${this.map_mode}`,
|
||||
params: {id: this.opened.id}
|
||||
});
|
||||
}
|
||||
// let clickedEntityBodies = [];
|
||||
// query.forEach(body => {
|
||||
// // console.log('body id:', body.id);
|
||||
// if (body.item_type === "entite") {
|
||||
// clickedEntityBodies.push(body);
|
||||
// }
|
||||
// });
|
||||
// if (clickedEntityBodies.length) {
|
||||
// // we have clicked on an entite
|
||||
// this.$router.push({
|
||||
// name: 'concernement',
|
||||
// hash: `#${this.map_mode}`,
|
||||
// params: {id: this.opened.id, eid: clickedEntityBodies[0].id}
|
||||
// });
|
||||
// } else {
|
||||
// // otherwise we close the entite and come back to the concernement
|
||||
// this.$router.push({
|
||||
// name: 'concernement',
|
||||
// hash: `#${this.map_mode}`,
|
||||
// params: {id: this.opened.id}
|
||||
// });
|
||||
// }
|
||||
} else {
|
||||
// if no concernement opened retrun to home (closing concernement contents opened)
|
||||
// and reset the opened state in concernement store
|
||||
|
||||
Reference in New Issue
Block a user