better responsivness #2416

This commit is contained in:
Bachir Soussi Chiadmi 2024-02-05 15:57:09 +01:00
parent b2614bf755
commit 609964b358
3 changed files with 52 additions and 11 deletions

View File

@ -196,6 +196,8 @@ export default {
// if map_item is open and we change the mad mode, redefined what is displayed in the "boussole"
if (this.is_open & n !== o) {
this.setPaperContents();
this.resetMapItemPosition();
this.resetMapItemScale();
}
// Clones visibility
@ -264,7 +266,7 @@ export default {
console.log(`map_item_ray updated o: ${o}, n: ${n}`);
this.ray = n;
this.updateMatterBodyRay();
this.updatePaperObjectSize(n,o);
this.updatePaperObjectSize();
},
deep: true
}
@ -644,7 +646,7 @@ export default {
this.initPaperEvents()
},
async updatePaperObjectSize(n,o){
async updatePaperObjectSize(){
await nextTick();
// INFO we redraw the points with the new ray AND sacle the backgrounds ... would it be simplier to only resize the whole mapitem ???
// window has been resized
@ -654,6 +656,7 @@ export default {
if (this.is_open) {
// move to the new position
// INFO we need to change position first for the contours to be redraw in the right place
// this.resetMapItemPosition();
this.pos = this.paper_main_object.position = {
x: (this.canvas.width - this.cartouch_width) / 2,
y: this.canvas.height / 2
@ -2295,6 +2298,29 @@ export default {
}
this.tween.easing(Tween.Easing.Quadratic.InOut).start();
},
async resetMapItemPosition(){
await nextTick();
console.log('resetMapItemPosition');
this.pos = this.paper_main_object.position = {
x: (this.canvas.width - this.cartouch_width) / 2,
y: this.canvas.height / 2
};
this.constraint.pointA = this.pos;
console.log('resetMapItemPosition', this.cartouch_width, this.pos);
Matter.Body.setPosition(this.body, this.pos);
},
async resetMapItemScale(){
await nextTick();
console.log('resetMapItemScale');
let s = this.getOpeningAvailableScale();
// revert to the original scale (by reverting the previous scale)
this.paper_main_object.scale(1 / this.scale);
// then scale again to new scale
this.paper_main_object.scale(s);
this.prev_scale = this.scale = s;
// TODO handle superposition scaling
},
// ENGINE UPDATE
onBeforeEngineUpdate (event) {

View File

@ -27,7 +27,7 @@ export const CommonStore = defineStore({
},
setCartoucheWidth (delta) {
console.log('CommonStore setCartoucheWidth', delta);
this.cartouch_width = this.original_cartouch_width * delta;
this.cartouch_width = this.original_cartouch_width * delta + 8 * (delta+1);
},
setCartoucheOpened (v) {
console.log('setCartoucheOpened', v);

View File

@ -149,6 +149,21 @@ export default {
}
},
deep: true
},
map_mode: {
handler (n, o) {
console.log('concernement watch map_mode', o, n);
if(n === "proximite" || n === "superposition"){
// as we have two content to show multiply the cartouch with by 2
// necessary for mapitem opening scale and position
this.setCartoucheWidth(2)
}else{
// as we have one content to show multiply the cartouch with by 1
// necessary for mapitem opening scale and position
this.setCartoucheWidth(1)
}
},
deep: true
}
},