$(function () {
$(window).scroll(function () {
let scrollPos = $(window).scrollTop()
$('.anchorpoint').each(function (i) {
let thisPos = $(this).offset().top - 300
if (scrollPos >= thisPos) {
setTimeout(function () {
$('.anchorpoint').eq(i).removeClass('video-lazyload')
$('.video_player2').trigger('click')
}, 1200)
}
})
})
setTimeout(function () {
let sliderBullet = $('.ias-tpl-hm-section03-01 .swiper-pagination-bullet').eq(0).innerWidth()
$('.ias-tpl-hm-section03-01 .ias-tpl-hm-tool .ias-tpl-pagination-bg').width(sliderBullet)
}, 50)
var mySwiper = new Swiper('.as-tpl-hm-banner01', {
loop: false,
pagination: {
el: '.swiper-pagination01',
clickable: true,
renderBullet: function (index, className) {
switch (index) {
case 0:
text = '全维转向稳定控制 X-ASC'
break
case 1:
text = '全维协同稳定控制 X-ESC'
break
case 2:
text = ''
break
case 3:
text = ''
break
case 4:
text = ''
break
}
return (
'' +
text +
''
)
},
},
navigation: {
nextEl: '.swiper-button-next01',
prevEl: '.swiper-button-prev01',
},
slidesPerView: 1,
speed: 500,
loop: false,
autoplay: false,
spaceBetween: 4,
keyboard: true,
observer: true,
observeParents: true,
on: {
transitionStart: function (mySwiper) {
let sliderWidth = $('.ias-tpl-hm-section03-01 .swiper-pagination-bullet').eq(this.activeIndex).innerWidth()
let sliderActiveWidth = $('.ias-tpl-hm-section03-01 .swiper-pagination-bullet').eq(this.activeIndex).position().left
$('.ias-tpl-hm-section03-01 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css({ 'left': sliderActiveWidth, 'width': sliderWidth })
$('.as-tpl-hm-banner01').find('img').trigger('appear')
},
slideChangeTransitionEnd: function () {
gatabswiper(this)
},
},
})
setTimeout(function () {
let sliderBullet = $('.ias-tpl-hm-section03-02 .swiper-pagination-bullet').eq(0).innerWidth()
$('.ias-tpl-hm-section03-02 .ias-tpl-hm-tool .ias-tpl-pagination-bg').width(sliderBullet)
}, 50)
var mySwiper2 = new Swiper('.as-tpl-hm-banner02', {
loop: false,
pagination: {
el: '.swiper-pagination02',
clickable: true,
renderBullet: function (index, className) {
switch (index) {
case 0:
text = '时空推理 AI 悬架 X-APS'
break
case 1:
text = '晕车舒缓 3.0'
break
case 2:
text = ''
break
case 3:
text = ''
break
}
return (
// '' + text + "";
'' +
text +
''
)
},
},
navigation: {
nextEl: '.swiper-button-next02',
prevEl: '.swiper-button-prev02',
},
slidesPerView: 1,
loop: false,
autoplay: false,
spaceBetween: 4,
keyboard: true,
observer: true,
observeParents: true,
on: {
transitionStart: function (mySwiper2) {
let sliderWidth = $('.ias-tpl-hm-section03-02 .swiper-pagination-bullet').eq(this.activeIndex).innerWidth()
let sliderActiveWidth = $('.ias-tpl-hm-section03-02 .swiper-pagination-bullet').eq(this.activeIndex).position().left
$('.ias-tpl-hm-section03-02 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css({ 'left': sliderActiveWidth, 'width': sliderWidth })
$('.as-tpl-hm-banner02').find('img').trigger('appear')
},
slideChangeTransitionEnd: function () {
gatabswiper(this)
},
},
})
setTimeout(function () {
let sliderBullet = $('.ias-tpl-hm-section03-03 .swiper-pagination-bullet').eq(0).innerWidth()
$('.ias-tpl-hm-section03-03 .ias-tpl-hm-tool .ias-tpl-pagination-bg').width(sliderBullet)
}, 50)
var mySwiper2 = new Swiper('.as-tpl-hm-banner03', {
loop: false,
pagination: {
el: '.swiper-pagination03',
clickable: true,
renderBullet: function (index, className) {
switch (index) {
case 0:
text = '弯道运动矢量控制'
break
case 1:
text = '全地形自适应 X-ATA'
break
case 2:
text = ''
break
case 3:
text = ''
break
}
return (
'' +
text +
''
)
},
},
navigation: {
nextEl: '.swiper-button-next03',
prevEl: '.swiper-button-prev03',
},
slidesPerView: 1,
loop: false,
autoplay: false,
spaceBetween: 4,
keyboard: true,
observer: true,
observeParents: true,
on: {
transitionStart: function (mySwiper2) {
let sliderWidth = $('.ias-tpl-hm-section03-03 .swiper-pagination-bullet').eq(this.activeIndex).innerWidth()
let sliderActiveWidth = $('.ias-tpl-hm-section03-03 .swiper-pagination-bullet').eq(this.activeIndex).position().left
$('.ias-tpl-hm-section03-03 .ias-tpl-hm-tool .ias-tpl-pagination-bg').css({ 'left': sliderActiveWidth, 'width': sliderWidth })
$('.as-tpl-hm-banner03').find('img').trigger('appear')
},
slideChangeTransitionEnd: function () {
gatabswiper(this)
},
},
})
// WebP支持检测(首次运行时缓存结果)
function checkWebPSupport(callback) {
if (typeof localStorage !== 'undefined' && localStorage.getItem('webpSupport') !== null) {
return callback(localStorage.getItem('webpSupport') === 'true')
}
const img = new Image()
img.onload = function () {
const result = img.width > 0 && img.height > 0
localStorage.setItem('webpSupport', result)
callback(result)
}
img.onerror = function () {
localStorage.setItem('webpSupport', false)
callback(false)
}
img.src =
'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAQAAAC1HAwCAAAAC0lEQVR42mNkYAAAAAYAAjCB0C8AAAAASUVORK5CYII='
}
checkWebPSupport(function (isSupported) {
$('img').each(function () {
const $img = $(this)
let webpSrc = $img.closest('picture').find('source[type="image/webp"]').data('srcset')
const webpSrcMob = $img.closest('picture').find('source[type="image/webp"][media*="max-width: 768px"]').data('srcset')
if ($(window).width() < 800) {
if (webpSrcMob != undefined) {
webpSrc = webpSrcMob
}
}
const fallbackSrc = $img.data('src')
// 动态设置真实图片路径
$img.data('original', isSupported ? webpSrc : fallbackSrc)
})
$('img').lazyload({
threshold: 200,
effect: 'fadeIn',
appear: function () {
const realSrc = $(this).data('original')
$(this).attr('src', realSrc)
$(this).addClass('lazy-loaded')
},
load: function () {
$(this).addClass('lazy-loaded')
},
error: function () {
$(this).attr('src', 'img/error.jpg')
},
})
})
// 初始化懒加载
$('img').lazyload({
effect: 'fadeIn', // 淡入效果
threshold: 100, // 提前300px加载
failure_limit: 15, // 最大容错数量
skip_invisible: true, // 加载隐藏图片
appear: function () {
// 加载前回调
let _this = $(this)
if (_this.data("original") != undefined) {
_this.on("load", function () {
$(this).css('background', 'transparent')
$(this).removeClass('lazyload')
$(".ias-conctrol-kvtxt").removeClass("lazy-text")
$(".ias-tpl-play-icon").removeClass("lazy-text")
})
}
},
load: function () {
// 加载完成回调
$(this).addClass('lazy-loaded')
},
})
})