Skip to content

Commit d0a72d5

Browse files
committed
feat: class Styler;to fix: About bottom figures, vert long tablet overflow
1 parent ff19c92 commit d0a72d5

File tree

3 files changed

+35
-20
lines changed

3 files changed

+35
-20
lines changed

Classes/Styler.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
export class Styler {
22
pics = [];
33

4-
fillPicsArray(className){
5-
document.querySelectorAll(className).forEach(el => {
6-
this.pics.push(el)
7-
})
8-
};
4+
findPics(className){ //выдаёт массив из нод-узлов (элементов)
5+
return document.querySelectorAll(className);
6+
}
97

108
calcStyles(elData1,elData2,screenWidthFresh = document.documentElement.clientWidth){
119
let wider,narrower,taller,lower;
@@ -21,17 +19,17 @@ export class Styler {
2119

2220
};
2321

24-
getParam(stylesObj, param){
22+
getParam(stylesObj, param){ //получает исчисленный объект стилей и имя параметра, возвращает численное значение параметра
2523
return +stylesObj[param]
2624
.slice(0,stylesObj[param]
2725
.indexOf('px'));
2826
};
2927

30-
findNGive(id){
28+
findNGive(elem){ // иметь в виду, что компьютед-стили надо бы запрашивать после прогрузки ДОМ!
3129
let elData = {}
32-
elData.el = document.getElementById(id);
33-
elData.id = id;
34-
elData.initStyles = window.getComputedStyle(elData.el);
30+
elData.el = elem;
31+
//elData.id = id;
32+
elData.initStyles = window.getComputedStyle(elem);
3533
elData.height = this.getParam(elData.initStyles,'height');
3634
elData.width = this.getParam(elData.initStyles,'width');
3735
elData.ratio = elData.width / elData.height;

Routes/About.js

+25-7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
import {Styler} from "../Classes/Styler.js"
2+
let styler = new Styler();
3+
14
export const About = {
25
template:
36
`<div class="About-whole-container">
@@ -7,13 +10,11 @@ export const About = {
710
</p>
811
<div class="About-figures" id="medievalPics">
912
<figure>
10-
<img src="./pics/Morignoni_Desenciano.jpg" alt="portrait of young tailor Morignoni Desenciano ">
11-
<!-- <img src="https://1.bp.blogspot.com/-QSd1Uh3-HDM/WJTSc3Po-lI/AAAAAAAActg/bQGmNlSDTTUvIbb8tTae2VHKQVXrXI4XwCLcB/s1600/giovanni_battista_moroni_-_the_tailor_il_tagliapanni_-_google_art_project.jpg" alt="portrait of young tailor Morignoni Desenciano ">-->
13+
<img src="./pics/Morignoni_Desenciano.jpg" class="about-pic" alt="portrait of young tailor Morignoni Desenciano">
1214
<figcaption> Портрет Маринони Дезенцано, Лондон, 1525г.</figcaption>
1315
</figure>
1416
<figure>
15-
<img src="./pics/Henry_8.jpeg" alt="portrait of King Henry VIII">
16-
<!-- <img src="http://4.bp.blogspot.com/-rYu2nmHFoS0/VDxjMn1xzxI/AAAAAAAAAMA/QkeJqI9rJaw/s1600/henry8petworth.jpg" alt="portrait of King Henry VIII">-->
17+
<img src="./pics/Henry_8.jpeg" class="about-pic" alt="portrait of King Henry VIII">
1718
<figcaption> Портрет Короля Генриха VIII, Лондон, 1528г.</figcaption>
1819
</figure>
1920
</div>
@@ -29,11 +30,11 @@ export const About = {
2930
</p>
3031
<div class="About-figures" id="20th_pics">
3132
<figure>
32-
<img src="./pics/Chesare_Fellini_1930s.jpg" alt="portrait of tailor Chesare Fellini">
33+
<img src="./pics/Chesare_Fellini_1930s.jpg" class="about-pic" alt="portrait of tailor Chesare Fellini">
3334
<figcaption> Чезаре Феллини в мастерской, 1930-е гг, Лондон</figcaption>
3435
</figure>
3536
<figure>
36-
<img src="./pics/British_Indian_Army.png" alt="three British Indian Army officers">
37+
<img src="./pics/British_Indian_Army.png" class="about-pic" alt="three British Indian Army officers">
3738
<figcaption>Выпускники Академии, 1930-е гг, Лондон</figcaption>
3839
</figure>
3940
</div>
@@ -50,8 +51,18 @@ export const About = {
5051
</div>`,
5152
data(){
5253
return{
53-
}},
54+
//ширина экрана - будем следить за ней через Watch
55+
screenWidth:document.documentElement.clientWidth,
56+
}
57+
},
5458
mounted(){
59+
window.onload = ()=> {
60+
styler.findPics('.about-pic').forEach(el => {
61+
styler.pics.push(styler.findNGive(el))
62+
})
63+
console.log(styler.pics)
64+
65+
};
5566

5667
},
5768
created(){
@@ -63,5 +74,12 @@ export const About = {
6374
computed:{
6475

6576
},
77+
watch:{
78+
screenWidth(){ //если ресайзнули окно - делать это:
79+
//styler.pics[0].el.style = 'width:300px'
80+
console.log('resize')
81+
//styler.calcStyles(styler.pics[0], styler.pics[1])
82+
}
83+
}
6684

6785
}

styles.css

+2-3
Original file line numberDiff line numberDiff line change
@@ -638,9 +638,8 @@ footer{
638638
padding:0 10px;
639639
}
640640

641-
.About-whole-container img{ /*сама картинка*/
642-
width:100%;
643-
height:100%;
641+
.about-pic{ /*сама картинка*/
642+
644643
}
645644

646645
}

0 commit comments

Comments
 (0)