|
@@ -20,30 +20,52 @@ $(window).resize(function () {
|
|
|
}, 500)
|
|
|
});
|
|
|
|
|
|
-$('.slide_single_img').each(function () { // jquery.each() 循環讀取所有圖片
|
|
|
- var height = $(this).height();
|
|
|
- var width = $(this).width();
|
|
|
- console.log(height)
|
|
|
- console.log(width)
|
|
|
- let x = (height / width)
|
|
|
- console.log(x)
|
|
|
+let imgCount = $(".slide_single_img").length;
|
|
|
+let heightImg = [];
|
|
|
+
|
|
|
+$('.slide_single_img').each(function (i) { // jquery.each() 循環讀取所有圖片
|
|
|
+ let height = $(this).height();
|
|
|
+ let width = $(this).width();
|
|
|
+ let x = (height / width);
|
|
|
if (x > 1) {
|
|
|
+ heightImg.push($(this));
|
|
|
+ // 預設高度為 0
|
|
|
$(this).css({
|
|
|
- 'height': 500 + 'px',
|
|
|
+ 'height': 0 + 'px',
|
|
|
"margin": 'auto',
|
|
|
-
|
|
|
});
|
|
|
- } else {
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+let heightImgIndex = [];
|
|
|
+
|
|
|
+function getAllIndex(arr) {
|
|
|
+ // 篩選符合條件 Index
|
|
|
+ for (i = 0; i < arr.length; i++) {
|
|
|
+ if (arr[i].height === 0)
|
|
|
+ heightImgIndex.push(i);
|
|
|
+ }
|
|
|
+ return heightImgIndex;
|
|
|
+}
|
|
|
+let allSlideImg = document.querySelectorAll('.slide_single_img');
|
|
|
+getAllIndex(allSlideImg);
|
|
|
+
|
|
|
+// 取得 slick 當前的 Index
|
|
|
+$('.style_house_sec02 .slider').on('beforeChange', function (event, slick, currentSlide, nextSlide) {
|
|
|
+ for (i = 0; i < heightImgIndex.length; i++) {
|
|
|
+ console.log(heightImgIndex[i]);
|
|
|
+ if (nextSlide == heightImgIndex[i]) {
|
|
|
+ allSlideImg[nextSlide].style.height = '500px';
|
|
|
+ } else {
|
|
|
+ allSlideImg[heightImgIndex[i]].style.height = '0px';
|
|
|
+ }
|
|
|
}
|
|
|
});
|
|
|
|
|
|
$('.slide_img').each(function () { // jquery.each() 循環讀取所有圖片
|
|
|
var height = $(this).height();
|
|
|
var width = $(this).width();
|
|
|
- console.log(height)
|
|
|
- console.log(width)
|
|
|
- let x = (height / width)
|
|
|
- console.log(x)
|
|
|
+ let x = (height / width);
|
|
|
if (x > 1) {
|
|
|
$(this).css({
|
|
|
'width': 100 + 'px',
|
|
@@ -57,6 +79,7 @@ $('.slide_img').each(function () { // jquery.each() 循環讀取所有圖片
|
|
|
});
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
$('.style_house_sec02 .slider-for').slick({
|
|
|
slidesToShow: 1,
|
|
|
slidesToScroll: 1,
|
|
@@ -69,8 +92,12 @@ $('.style_house_sec02 .slider-nav').slick({
|
|
|
slidesToScroll: 3,
|
|
|
asNavFor: '.slider-for',
|
|
|
dots: false,
|
|
|
+<<<<<<< Updated upstream
|
|
|
arrows: false,
|
|
|
// centerMode: true,
|
|
|
+=======
|
|
|
+ centerMode: true,
|
|
|
+>>>>>>> Stashed changes
|
|
|
focusOnSelect: true
|
|
|
});
|
|
|
|