better responsivness #2416

This commit is contained in:
Bachir Soussi Chiadmi 2024-02-05 11:58:01 +01:00
parent 40dbbb2384
commit b2614bf755
3 changed files with 78 additions and 20 deletions

View File

@ -14,10 +14,10 @@ body{
font-size: 16px; font-size: 16px;
} }
#app{ // #app{
min-width: 1280px; // min-width: 1280px;
min-height: 800px; // min-height: 800px;
} // }
#app>header#header{ #app>header#header{
// background-color: $front; // background-color: $front;
@ -115,7 +115,7 @@ body{
ul{ ul{
display: flex; display: flex;
flex-flow: row; flex-flow: row;
gap: 1em; // gap: 1em;
pointer-events: none; pointer-events: none;
li{ li{
list-style: none; list-style: none;
@ -147,7 +147,7 @@ body{
} }
} }
@media screen and (max-width: 1300px) { @media screen and (max-width: 1500px) {
ul{ ul{
gap: 0.5em; gap: 0.5em;
li{ li{
@ -179,16 +179,31 @@ body{
} }
} }
$cartouch_width : 450px; $cartouch_width_full : 450px;
$cartouch_width_medium: 350px;
$cartouch_width_small: 250px;
@mixin font_questions{ @mixin font_questions{
font-size: 1em; font-size: 1em;
font-weight: 500; font-weight: 500;
line-height: 1.4; line-height: 1.4;
@media screen and (max-width: 1500px) {
font-size: 0.882em;
}
@media screen and (max-width: 880px) {
font-size: 0.756em;
}
} }
@mixin font_reponses{ @mixin font_reponses{
font-weight: 100; font-weight: 100;
font-size: 0.882em; font-size: 0.882em;
line-height: 1.4; line-height: 1.4;
@media screen and (max-width: 1500px) {
font-size: 0.756em;
}
@media screen and (max-width: 880px) {
font-size: 0.693em;
}
} }
#content{ #content{
display: flex; display: flex;
@ -196,7 +211,7 @@ body{
@mixin main-cartouche{ @mixin main-cartouche{
background-color: rgba(255, 255, 255, 1); background-color: rgba(255, 255, 255, 1);
box-sizing: border-box; box-sizing: border-box;
width:$cartouch_width; width:$cartouch_width_full;
height: 100%; height: 100%;
padding: 2rem 2rem 1rem; padding: 2rem 2rem 1rem;
overflow-y: auto; overflow-y: auto;
@ -204,6 +219,14 @@ body{
// //
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@media screen and (max-width: 1500px) {
width: $cartouch_width_medium;
padding: 1rem 1rem 0.5rem;
}
@media screen and (max-width: 880px) {
width: $cartouch_width_small;
padding: 0.5rem 0.5rem 0.5rem;
}
} }
section.static{ section.static{
@include main-cartouche(); @include main-cartouche();
@ -721,7 +744,7 @@ body{
pointer-events: none; pointer-events: none;
overflow: hidden; overflow: hidden;
top: 0; left: 0; top: 0; left: 0;
width: calc(100vw - $cartouch_width - 0.5rem); width: calc(100vw - $cartouch_width_full - 0.5rem);
height: 100vh; height: 100vh;
div{ div{
pointer-events: all; pointer-events: all;
@ -811,6 +834,12 @@ body{
border-radius: 3px; border-radius: 3px;
// border: #fff 1px solid; // border: #fff 1px solid;
} }
@media screen and (max-width: 1500px) {
width: $cartouch_width_medium
}
@media screen and (max-width: 880px) {
width: $cartouch_width_small;
}
} }
&:not(.visible){ &:not(.visible){
display: none; display: none;

View File

@ -96,6 +96,10 @@ export default {
}, },
mounted() { mounted() {
console.log('map mounted'); console.log('map mounted');
// update the cartouch width reference
this.setOriginalCartoucheWidth(this.getCartouchWidth());
this.canvasMap.canvas = this.$refs['canvas-map']; this.canvasMap.canvas = this.$refs['canvas-map'];
this.canvasMap.ctx = this.canvasMap.canvas.getContext('2d'); this.canvasMap.ctx = this.canvasMap.canvas.getContext('2d');
@ -103,8 +107,13 @@ export default {
let canvas_h = this.canvasMap.canvas.height = this.canvasMap.canvas.parentElement.clientHeight; let canvas_h = this.canvasMap.canvas.height = this.canvasMap.canvas.parentElement.clientHeight;
console.log(`canvas_w: ${canvas_w}, canvas_h: ${canvas_h}`); console.log(`canvas_w: ${canvas_w}, canvas_h: ${canvas_h}`);
// PAPER // PAPER
this.paper = paper.setup(this.canvasMap.canvas); this.paper = paper.setup(this.canvasMap.canvas);
// this.paper.view.viewSize = new paper.Size(canvas_w, canvas_h);
// this resizing is needed for display with pixel ratio more than 1 (retina)
this.canvasMap.canvas.setAttribute('width', canvas_w);
this.canvasMap.canvas.setAttribute('height', canvas_h);
// symbol defintions // symbol defintions
this.initPaperSymbols(); this.initPaperSymbols();
@ -269,7 +278,8 @@ export default {
'resetConcernementOpened']), 'resetConcernementOpened']),
...mapActions(CommonStore,['addPaperSymbolDefinition', ...mapActions(CommonStore,['addPaperSymbolDefinition',
'setHoverElmt', 'setHoverElmt',
'updateMapItemRay']), 'updateMapItemRay',
'setOriginalCartoucheWidth']),
animate () { animate () {
// if (document.hasFocus()) { // if (document.hasFocus()) {
Matter.Engine.update(this.engine, 1); Matter.Engine.update(this.engine, 1);
@ -358,6 +368,8 @@ export default {
// paper.view.viewSize.width = canvas_w; // paper.view.viewSize.width = canvas_w;
// paper.view.viewSize.height = canvas_h; // paper.view.viewSize.height = canvas_h;
this.paper.view.viewSize = new paper.Size(canvas_w, canvas_h); this.paper.view.viewSize = new paper.Size(canvas_w, canvas_h);
// this.canvasMap.canvas.setAttribute('width', canvas_w);
// this.canvasMap.canvas.setAttribute('height', canvas_h);
// apply to matter env // apply to matter env
// this.buildMatterWalls(); // this.buildMatterWalls();
@ -370,7 +382,20 @@ export default {
// rebuild all the paper symbols with new ray // rebuild all the paper symbols with new ray
this.initPaperSymbols(true) this.initPaperSymbols(true)
// update the cartouch width reference
this.setOriginalCartoucheWidth(this.getCartouchWidth());
},
getCartouchWidth(){
let ww = window.clientWidth;
if (ww > 1500) {
return 450;
} else if (ww > 880) {
return 400;
} else {
return 350;
}
}, },
initPaperSymbols(update){ initPaperSymbols(update){
this.addPaperSymbolDefinition('boussole_bg', this.setPaperBoussoleBGSymbol()); this.addPaperSymbolDefinition('boussole_bg', this.setPaperBoussoleBGSymbol());
@ -503,11 +528,11 @@ export default {
strokeColor: '#fff', strokeColor: '#fff',
})) }))
let fontsize = 4; let fontsize = 3;
let fontFamily = "public_sans"; let fontFamily = "public_sans";
children.push(new paper.PointText({ children.push(new paper.PointText({
point: [pos.x + 4.5, pos.y - ray - 5], point: [pos.x + 4.5, pos.y - ray],
content: `entités qui menacent \u2194 entités qui maintiennent`, content: `entités qui menacent \u2194 entités qui maintiennent`,
fontSize: fontsize, fontSize: fontsize,
fontFamily: fontFamily, fontFamily: fontFamily,
@ -516,7 +541,7 @@ export default {
})) }))
children.push(new paper.PointText({ children.push(new paper.PointText({
point: [pos.x - ray - 5, pos.y + 1], point: [pos.x - ray, pos.y + 1],
content: "axe d'intensité", content: "axe d'intensité",
fontSize: fontsize, fontSize: fontsize,
fontFamily: fontFamily, fontFamily: fontFamily,
@ -525,7 +550,7 @@ export default {
})) }))
children.push(new paper.PointText({ children.push(new paper.PointText({
point: [pos.x + ray + 5, pos.y - 3], point: [pos.x + ray, pos.y - 3],
content: "situation future\n\u2195\nsituation actuelle", content: "situation future\n\u2195\nsituation actuelle",
fontSize: fontsize, fontSize: fontsize,
fontFamily: fontFamily, fontFamily: fontFamily,
@ -535,7 +560,7 @@ export default {
let t1 = new paper.PointText({ let t1 = new paper.PointText({
point: [pos.x - ray/8*2.3, pos.y - ray/8*2.3], point: [pos.x - ray/8*2.54, pos.y - ray/8*2.54],
content: "avec prise", content: "avec prise",
fontSize: fontsize, fontSize: fontsize,
fontFamily: fontFamily, fontFamily: fontFamily,
@ -546,7 +571,7 @@ export default {
children.push(t1) children.push(t1)
let t2 = new paper.PointText({ let t2 = new paper.PointText({
point: [pos.x - ray/8*2.95, pos.y - ray/8*2.95], point: [pos.x - ray/8*3.1, pos.y - ray/8*3.1],
content: "sans prise", content: "sans prise",
fontSize: fontsize, fontSize: fontsize,
fontFamily: fontFamily, fontFamily: fontFamily,
@ -1465,9 +1490,9 @@ export default {
<div id="map-backgrounds"> <div id="map-backgrounds">
<MapBackground /> <MapBackground />
</div> </div>
<div id="map-matter"> <!-- <div id="map-matter">
<canvas ref="canvas-engine"></canvas> <canvas ref="canvas-engine"></canvas>
</div> </div> -->
<div id="map-concernements"> <div id="map-concernements">
<canvas ref="canvas-map"></canvas> <canvas ref="canvas-map"></canvas>
<slot></slot> <slot></slot>

View File

@ -21,6 +21,10 @@ export const CommonStore = defineStore({
// mode can be : terraindevie, proximite, superposition, puissancedagir, action, doleancer // mode can be : terraindevie, proximite, superposition, puissancedagir, action, doleancer
this.hover_elmt = elmt; this.hover_elmt = elmt;
}, },
setOriginalCartoucheWidth (w) {
console.log('CommonStore setOriginalCartoucheWidth', w);
this.original_cartouch_width = w;
},
setCartoucheWidth (delta) { setCartoucheWidth (delta) {
console.log('CommonStore setCartoucheWidth', delta); console.log('CommonStore setCartoucheWidth', delta);
this.cartouch_width = this.original_cartouch_width * delta; this.cartouch_width = this.original_cartouch_width * delta;