Ловите рабочий код!!!
| JavaScript | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
| content: ElementRef;
gradient: ElementRef;
showContent: ElementRef;
numberOfClicks = 0;
isShowMoreCompanies: boolean = true;
isShowMore: boolean = true;
buttonDown: ElementRef;
arrayList: any = [
{
logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
title: "ПИК",
rc: "28 ЖК",
price: "от 3,1 млн",
apartments: "6 988 квартир",
},
{
logo: "https://data1.logaster.com/logotype/data/5413158/png/512/1/?c=421366bd831202f9ce00d973cfed6ba3",
title: "MR GROUP",
rc: "13 ЖК",
price: "от 5,9 млн",
apartments: "3 067 кварти",
},
{
logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
title: "Главстрой",
rc: "1 ЖК",
price: "от 3,8 млн",
apartments: "1 266 квартир",
},
{
logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
title: "ПИК",
rc: "28 ЖК",
price: "от 3,1 млн",
apartments: "6 988 квартир",
},
{
logo: "https://data1.logaster.com/logotype/data/5413158/png/512/1/?c=421366bd831202f9ce00d973cfed6ba3",
title: "MR GROUP",
rc: "13 ЖК",
price: "от 5,9 млн",
apartments: "3 067 кварти",
},
{
logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
title: "Главстрой",
rc: "1 ЖК",
price: "от 3,8 млн",
apartments: "1 266 квартир",
},
{
logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
title: "ПИК",
rc: "28 ЖК",
price: "от 3,1 млн",
apartments: "6 988 квартир",
},
{
logo: "https://data1.logaster.com/logotype/data/5413158/png/512/1/?c=421366bd831202f9ce00d973cfed6ba3",
title: "MR GROUP",
rc: "13 ЖК",
price: "от 5,9 млн",
apartments: "3 067 кварти",
},
{
logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
title: "Главстрой",
rc: "1 ЖК",
price: "от 3,8 млн",
apartments: "1 266 квартир",
},
{
logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
title: "ПИК",
rc: "28 ЖК",
price: "от 3,1 млн",
apartments: "6 988 квартир",
}
];
arrayListOne: any = [
{
logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
title: "ПИК",
rc: "28 ЖК",
price: "от 3,1 млн",
apartments: "6 988 квартир",
},
{
logo: "https://data1.logaster.com/logotype/data/5413158/png/512/1/?c=421366bd831202f9ce00d973cfed6ba3",
title: "MR GROUP",
rc: "13 ЖК",
price: "от 5,9 млн",
apartments: "3 067 кварти",
},
{
logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
title: "Главстрой",
rc: "1 ЖК",
price: "от 3,8 млн",
apartments: "1 266 квартир",
},
{
logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
title: "ПИК",
rc: "28 ЖК",
price: "от 3,1 млн",
apartments: "6 988 квартир",
},
]
constructor(){}
ngOnInit(): void {
if(this.arrayList.length > 4){
this.arrayListOne = this.arrayList.slice(0, 4);
console.log(this.arrayListOne);
}
}
showMore(){
if(this.isShowMoreCompanies){
this.arrayListOne = this.arrayList.slice(0, this.arrayList.length - 1);
}
else{
this.arrayListOne = this.arrayList.slice(0, 4);
}
this.isShowMoreCompanies = !this.isShowMoreCompanies;
}
showMoreCompanies(){
this.isShowMoreCompanies = !this.isShowMoreCompanies;
console.log(this.isShowMoreCompanies); |
|
Добавлено через 1 час 9 минут
вот ещё вариант. тоже работает на отлично
| JavaScript | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
| import { Component, ElementRef, OnInit } from '@angular/core';
@Component({
selector: 'developer-block-card',
templateUrl: './developer-block-card.html',
styleUrls: ['./developer-block-card.less']
})
export class DeveloperBlockCard implements OnInit{
// @ViewChild('content') Component :ElementRef;
// renderer: any;
content: ElementRef;
gradient: ElementRef;
showContent: ElementRef;
numberOfClicks = 0;
isShowMoreCompanies: boolean = false;
isShowMore: boolean = true;
button: ElementRef;
arrayList: any = [
{
logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
title: "ПИК",
rc: "28 ЖК",
price: "от 3,1 млн",
apartments: "6 988 квартир",
},
{
logo: "https://data1.logaster.com/logotype/data/5413158/png/512/1/?c=421366bd831202f9ce00d973cfed6ba3",
title: "MR GROUP",
rc: "13 ЖК",
price: "от 5,9 млн",
apartments: "3 067 кварти",
},
// {
// logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
// title: "Главстрой",
// rc: "1 ЖК",
// price: "от 3,8 млн",
// apartments: "1 266 квартир",
// },
// {
// logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
// title: "ПИК",
// rc: "28 ЖК",
// price: "от 3,1 млн",
// apartments: "6 988 квартир",
// },
// {
// logo: "https://data1.logaster.com/logotype/data/5413158/png/512/1/?c=421366bd831202f9ce00d973cfed6ba3",
// title: "MR GROUP",
// rc: "13 ЖК",
// price: "от 5,9 млн",
// apartments: "3 067 кварти",
// },
// {
// logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
// title: "Главстрой",
// rc: "1 ЖК",
// price: "от 3,8 млн",
// apartments: "1 266 квартир",
// },
// {
// logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
// title: "ПИК",
// rc: "28 ЖК",
// price: "от 3,1 млн",
// apartments: "6 988 квартир",
// },
// {
// logo: "https://data1.logaster.com/logotype/data/5413158/png/512/1/?c=421366bd831202f9ce00d973cfed6ba3",
// title: "MR GROUP",
// rc: "13 ЖК",
// price: "от 5,9 млн",
// apartments: "3 067 кварти",
// },
// {
// logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
// title: "Главстрой",
// rc: "1 ЖК",
// price: "от 3,8 млн",
// apartments: "1 266 квартир",
// },
// {
// logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
// title: "ПИК",
// rc: "28 ЖК",
// price: "от 3,1 млн",
// apartments: "6 988 квартир",
// }
];
arrayListOne: any = [
{
logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
title: "ПИК",
rc: "28 ЖК",
price: "от 3,1 млн",
apartments: "6 988 квартир",
},
{
logo: "https://data1.logaster.com/logotype/data/5413158/png/512/1/?c=421366bd831202f9ce00d973cfed6ba3",
title: "MR GROUP",
rc: "13 ЖК",
price: "от 5,9 млн",
apartments: "3 067 кварти",
},
{
logo: "https://data2.logaster.com/logotype/data/5410523/png/512/1/?c=b03e679a8687b207dbec72112b999b3e",
title: "Главстрой",
rc: "1 ЖК",
price: "от 3,8 млн",
apartments: "1 266 квартир",
},
]
countCompany: number;
constructor(){}
ngOnInit(): void {
if(this.arrayList.length > 4){
this.countCompany = 4;
}
else{
this.countCompany = this.arrayList.length;
this.button
}
}
showMore(){
if(!this.isShowMoreCompanies){
this.countCompany = this.arrayList.length;
}
else{
this.countCompany = 4;
}
this.isShowMoreCompanies = !this.isShowMoreCompanies;
}
showMoreCompanies(){
this.isShowMoreCompanies = !this.isShowMoreCompanies;
console.log(this.isShowMoreCompanies);
let content = document.getElementById('content');
let gradient = document.getElementById('gradient');
let button = document.getElementById('buttonDown');
if(this.isShowMoreCompanies){
// content.style.height = '300px';
// gradient.style.display = 'block';
// button.style.bottom = '1315px';
// this.renderer.nativeElement.addClass(content, 'active');
console.log("lalalend")
}
else{
// content.style.height = '100%';
// gradient.style.display = 'none';
// button.style.bottom = '1315px';
// this.renderer.nativeElement.removeClass(content, 'active');
console.log('nani')
}
}
} |
|
| HTML5 | 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| <div class="home-developer">
<div class='gradient'>
<div class="grid" #content>
<div class="home-info__item col--xlg-1-2 col--lg-1-2 col--md-1-2 col--sm-1-2 col--xs-1-1"
*ngFor='let item of arrayList | slice:0:countCompany'>
<div class="home-developer__logo">
<img src="{{item.logo}}" alt="#">
</div>
<div class="home-developer__title">{{item.title}}</div>
<p class="home-developer__rc">{{item.rc}}
<span class="home-developer__price">{{item.price}}</span>
</p>
<br>
<p class="home-developer__apart">{{item.apartments}}</p>
</div>
<div class="col--1-1">
<!-- <div class="home-developer__more home-developer__margin-block"> -->
<div class="home-developer__more">
<button class="home-developer__more-btn btn btn--yellow"
(click)="showMore()">
{{ isShowMoreCompanies ? 'Скрыть' : 'Показать ещё'}}
</button>
</div>
</div>
</div>
</div>
<!-- <div class="gradient" #gradient id="gradient"></div> -->
</div> |
|
0
|