-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathproduct.js
148 lines (122 loc) · 4.33 KB
/
product.js
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
$(document).ready(function () {
$("header").load('header.html')
$(".preloadExterior :nth-child(3) > img").css({
borderTopRightRadius: '5px'
})
$(".preloadInterior :nth-child(5) > img").css({
borderBottomRightRadius: '5px'
})
$(".carPhotos img").on('click', function () {
let imagesrc = $(this).attr('src')
$('#mask').addClass('fade-in')
$('.mask').css({
display: 'block'
})
})
$("img").attr('loading', 'lazy')
$(document).on('keyup', function (e) {
if (e.key === 'Escape') {
$('.mask').css({
display: 'none'
})
}
})
//hide draggable album when display > 768
//start flickity
//hide second column of photos
const thirdChildRightAbove = $(".preloadExterior :nth-child(3)")
const fifthChildRightAbove = $(".preloadExterior :nth-child(5)")
const fifthChildRightBottom = $(".preloadInterior :nth-child(5)")
const thirdChildRightBottom = $(".preloadInterior :nth-child(3)")
function hideSecondColumn() {
if (window.innerWidth < 1330) {
thirdChildRightAbove.hide()
thirdChildRightBottom.hide()
fifthChildRightAbove.hide()
fifthChildRightBottom.hide()
$(".preloadExterior :nth-child(2) > img").css({
borderTopRightRadius: '5px'
})
$(".preloadInterior :nth-child(4) > img").css({
borderBottomRightRadius: '5px'
})
$(".preloadExterior :nth-child(2), .preloadExterior :nth-child(3)").css({
marginBottom: '0'
})
$(".preloadInterior :nth-child(2), .preloadInterior :nth-child(3)").css({
marginBottom: '0'
})
}
if (window.innerWidth > 768) {
$('.carPhotos768').flickity({
freeScroll: true,
contain: true,
// disable previous & next buttons and dots
prevNextButtons: false,
pageDots: false
})
$('.carPhotos768').hide()
}
if (window.innerWidth < 768) {
$('.carPhotos').hide()
$('.carPhotos768').show()
$('.carPhotos768').flickity({
freeScroll: true,
contain: true,
// disable previous & next buttons and dots
prevNextButtons: false,
pageDots: false
})
}
}
hideSecondColumn();
//add as much margin + 4px to the left of the exterior images as the width of the main image
let heroSize = $('#heroCarousel img').width()
let interiorWrapSize = $('.preloadExterior768').width()
let leftForInterior768 = heroSize + interiorWrapSize
$('.preloadExterior768').css({
left: `${heroSize}` + 'px'
})
$('.preloadInterior768').css({
left: `${leftForInterior768+3}` + 'px'
})
$(window).on('resize', function () {
var heroSize = $('#heroCarousel img').width()
var interiorWrapSize = $('.preloadExterior768').width()
var leftForInterior768 = heroSize + interiorWrapSize
//this one prevents flickity from changing it when resizing
$('.preloadExterior768').css({
left: `${heroSize}` + 'px'
})
$('.preloadInterior768').css({
left: `${leftForInterior768+3}` + 'px'
})
if (window.innerWidth > 1330) {
thirdChildRightAbove.show();
thirdChildRightBottom.show();
fifthChildRightAbove.show();
fifthChildRightBottom.show();
}
if (window.innerWidth < 1330) {
thirdChildRightAbove.hide();
thirdChildRightBottom.hide();
fifthChildRightAbove.hide();
fifthChildRightBottom.hide();
}
if (window.innerWidth > 768) {
$('.carPhotos').show()
$('.carPhotos768').hide()
}
if (window.innerWidth < 768) {
$('.carPhotos').hide()
$('.carPhotos768').show()
$('.carPhotos768').flickity({
freeScroll: true,
contain: true,
// disable previous & next buttons and dots
prevNextButtons: false,
pageDots: false
})
}
})
})