PageSourceSearch

https://www.xfusion.com/wp-content/themes/xfusion/assets/js/home.js?ver=20231207

js xfusion.com collected 2026-09-28 07:37:29 UTC 12,289 bytes, 364 lines download raw bytes

1$(function () {
2
3    //首页header 添加 home_header 类
4    $('.home #header').addClass('home_header');
5    //pc - 导航hover 展开下拉
6    if (is_pc || is_ipad) {
7        $(".head_menu .menu_depth_0").hover(function () {
8            $('#header').removeClass('home_header');
9        }, function () {
10            $('#header').addClass('home_header');
11        });
12    }
13
14    var is_play = false; //记录是否手动暂停视频
15
16
17
18    //视频轮播时 添加 video 并且播放
19    video_play_event = (act_slide) => {
20        if (act_slide.find('.video_play_box').length < 1) {
21            //短视频地址 放本地的
22            let video_src = act_slide.attr('data-video-src');
23            //长视频地址 放远程服务器的
24            let video_src_long = act_slide.attr('data-video-src-long');
25            //拼接视频播放器
26            let video_html = `
27                    <div class="video_play_box swiper-no-swiping">
28                    <video class="_video"  muted loop >
29                        <source src="${video_src}" type="video/mp4">
30                    </video>
31                     <span class="long_video_box" data-video-src=${video_src_long}></span>
32                    </div>
33            `;
34            //添加当前的video
35            act_slide.find('.item_box').append(video_html);
36        }
37        if (!is_play) {
38            act_slide.find('.video_play_box').addClass('play');
39            //切换视频播放状态
40            video_play(act_slide.find('video').get(0));
41        }
42    }
43
44
45    //视频点击 切换长视频源
46    $(document).on('click', '.long_video_box', function () {
47        let video_src = $(this).attr('data-video-src');
48        let video = $(this).prev();
49        $(this).remove();
50        video.attr({ src: video_src, controls: 'controls' });
51        video_play(video.get(0));
52
53    });
54
55    //首页 banner轮播
56    //如果轮播图大于1张 在初始化轮播图
57    if ($('#iddeeHvF .swiper-slide').length > 1) {
58        var home_slide = new Swiper('#iddeeHvF', {
59            slidesPerView: 1,
60            effect: 'fade',
61            autoplay: {
62                delay: 5000,
63                disableOnInteraction: false,
64            },
65            loop: true,
66            speed: 500,
67            navigation: {
68                nextEl: '#iddeeHvF .swiper-button-next',
69                prevEl: '#iddeeHvF .swiper-button-prev',
70            },
71            pagination: {
72                el: '.pagination_iddeeHvF',
73                clickable: true,
74            },
75            on: {
76                transitionStart: function (swiper) {
77                    $('#iddeeHvF .slide_item').removeClass('css_in').addClass('css_out');
78                },
79                transitionEnd: function (swiper) {
80                    let act_slide = swiper.slides[swiper.activeIndex];
81                    $(act_slide).addClass('css_in').removeClass('css_out');
82
83                },
84                init: function (swiper) {
85                    let act_slide = swiper.slides[swiper.activeIndex];
86                    $(act_slide).addClass('css_in').removeClass('css_out');
87                }
88            },
89        });
90    } else {
91        //如果轮播图只有一张 显示第一张的进场动画
92        $('#iddeeHvF .swiper-slide').addClass('css_in swiper-slide-visible');
93        //隐藏指示器
94        $('.pagination_iddeeHvF').hide();
95    }
96
97    const handler = () => {
98        if (window.document.visibilityState === 'visible' && home_slide != undefined) {
99            // 当页签处于可见状态时,执行的操作
100            home_slide.slideNext();
101        }
102    };
103    window.document.addEventListener('visibilitychange', handler);
104
105    //首页 视频轮播
106    var activeIndex = 0;
107    var home_video_sldie = new Swiper('.home_video_sldie', {
108        slidesPerView: 1,
109        spaceBetween: 0,
110        centeredSlides: true,
111        noSwiping: true,
112        loop: true,
113        loopAdditionalSlides: 2,
114        speed: 400,
115        navigation: {
116            nextEl: '.home_video_sldie .swiper-button-next',
117            prevEl: '.home_video_sldie .swiper-button-prev',
118        },
119        pagination: {
120            el: '.home_video_sldie .swiper-pagination',
121            clickable: true,
122        },
123        on: {
124            transitionStart: function (swiper) {
125                debounce(() => {
126                    if (activeIndex == swiper.activeIndex) {
127                        return;
128                    }
129                    activeIndex = swiper.activeIndex;
130                    let act_slide = swiper.slides[swiper.activeIndex];
131                    $('.home_video_sldie .video_play_box').remove();
132                    //console.log(swiper.activeIndex);
133                    is_play = false;
134                    video_play_event($(act_slide));
135                }, 20)
136            },
137            init: function (swiper) {
138
139            }
140        },
141    });
142
143    //首页 解决方案左侧轮播
144    var home_solution_slide = new Swiper('.home_solution_slide', {
145        loop: true,
146        slidesPerView: 1,
147        autoplay: false,
148        navigation: {
149            nextEl: '.home_solution_slide .swiper-button-next',
150            prevEl: '.home_solution_slide .swiper-button-prev',
151        },
152        pagination: {
153            el: '.home_solution_slide .swiper-pagination',
154            clickable: true,
155        }
156    });
157
158
159
160    //首页 案例轮播
161    var home_case_slide = new Swiper(".home_case_slide", {
162        slidesPerView: 'auto',
163        loop: true,
164        loopAdditionalSlides: 3,
165        autoplay: false,
166        navigation: {
167            nextEl: '.case_slide_btn .swiper-button-next',
168            prevEl: '.case_slide_btn .swiper-button-prev',
169        },
170        pagination: {
171            el: '.home_case_slide .swiper-pagination',
172            clickable: true,
173        }
174    });
175
176    $.extend({
177        digital_timer: function (el) {
178            var cun_timer = [];
179            let num = parseInt(el.attr('data-number'));
180            let time = parseInt(1000 / num);
181            //console.log(time);
182            //获取el 的 indexOf
183            let el_index = el.index();
184            cun_timer[el_index] = [];
185            cun_timer[el_index]['num'] = num;
186            cun_timer[el_index]['current_num'] = parseInt(el.find('.text').text());
187            cun_timer[el_index]['timer'] = setInterval(function () {
188                let text_dom = el.find('.text');
189                let current_num = cun_timer[el_index]['current_num'];
190                if (current_num <= cun_timer[el_index]['num']) {
191                    text_dom.text(current_num++);
192                    cun_timer[el_index]['current_num'] = current_num;
193                } else {
194                    clearInterval(cun_timer[el_index]['timer']);
195                }
196            }, time);
197
198
199        }
200    })
201
202    //数字滚动
203    page_digital_timer = () => {
204        $('#digital_timer .num').each(function () {
205            $.digital_timer($(this));
206        });
207    }
208
209
210    //首页下拉时 顶部导航栏变化
211    home_header_change = () => {
212        var top = $(window).scrollTop();
213        if (top > 10) {
214            $('#header').addClass('fixed_header');
215            $('#header').removeClass('is_top_header');
216        } else {
217            $('#header').removeClass('fixed_header');
218            //延迟
219            setTimeout(() => {
220                $('#header').addClass('is_top_header');
221            }, 400);
222
223        }
224    }
225    home_header_change();
226
227    //可视区域内 添加效果
228    layout_add_event = (el) => {
229        let layout_name = el.attr('data-name');
230        switch (layout_name) {
231            case 'video_layout':
232                video_play_event(el.find('.swiper-slide-active.video_item'));
233                break;
234            case 'company_data':
235                //开始数字滚动
236                page_digital_timer();
237                break;
238        }
239    }
240    //离开可视区域 移除效果
241    layout_remove_event = (el) => {
242        let layout_name = el.attr('data-name');
243        switch (layout_name) {
244            case 'video_layout':
245                //播放视频
246                if (el.find('video').length > 0 && is_play) {
247                    is_play = false;
248                    el.find('video').get(0).pause();
249                    el.find('.video_play_box').removeClass('play');
250                }
251                break;
252
253
254        }
255    }
256    //离开可视区域 重置部分效果
257    layout_reset_event = (el) => {
258        let layout_name = el.attr('data-name');
259        switch (layout_name) {
260            case 'company_data':
261                //恢复数字为0
262                $('#digital_timer .num .text').text(0);
263                break;
264
265        }
266    }
267    //页面滚动时 执行css动画的添加或重置 恢复
268    page_scroll_change = () => {
269        //获取页面上所有 class aosdh的布局
270        //判断是否在可视区域内
271        //如果在 可视区域内 则添加 class aos-animate
272        $('.aosdh').each(function () {
273            let _this = $(this);
274            let top = _this.offset().top;
275            let height = _this.height();
276            let window_top = $(window).scrollTop();
277            let window_height = $(window).height() * zoom;
278
279            let is_visible = window_top > top - (window_height - window_height / 5) && window_top < top + height;
280
281            if (is_visible) {
282                if (_this.attr('data-aos') != 'false') {
283                    _this.addClass('css_in');
284                }
285
286                //部分事件特殊处理
287                layout_add_event(_this);
288            }
289            //不在可视区域 且在下部 则移除aosdh
290            if (window_top < (top + height - (window_height / 4 + window_height)) && !is_visible) {
291                _this.removeClass('css_in');
292                layout_reset_event(_this);
293            }
294            //不在可视区域内 上部或下部都会执行
295            if (!is_visible) {
296                layout_remove_event(_this);
297            }
298
299        });
300
301
302    }
303    page_scroll_change();
304
305    //页面滚动时 处理延迟加载的图片
306    page_scroll_lazy_img = () => {
307        let window_top = $(window).scrollTop();
308        let window_height = $(window).height() * zoom;
309        //获取页面上所有 class lazy_img的img 和 lazy_bg的div
310        $('img.lazy_img').each(function () {
311            let _this = $(this);
312            let top = _this.offset().top;
313            let height = _this.height();
314            let is_visible = window_top > top - (window_height + window_height / 5) && window_top < top + height;
315            if (is_visible) {
316                _this.attr('src', _this.attr('data-src'));
317                _this.removeClass('lazy_img');
318            }
319        });
320        $('.lazy_bg').each(function () {
321            let _this = $(this);
322            let top = _this.offset().top;
323            let height = _this.height();
324            let is_visible = window_top > top - (window_height + window_height / 5) && window_top < top + height;
325            if (is_visible) {
326                let img = _this.attr('data-src');
327                _this.css('background-image', 'url(' + img + ')');
328                _this.removeClass('lazy_bg');
329            }
330        });
331    }
332
333    page_scroll_lazy_img();
334
335    //滚动时
336    $(window).scroll(function () {
337        //防抖处理
338        debounce(() => {
339            //顶部导航栏变化
340            home_header_change();
341            //页面滚动时  处理一些事情
342            page_scroll_change();
343            page_scroll_lazy_img();
344        }, 20)
345    });
346
347    //加载视频 并且播放
348    function video_play(video) {
349        if (video.readyState < 3) {
350            video.ondurationchange = function () {
351                video.play();
352            }
353        } else {
354            video.play();
355        }
356        is_play = true;
357    }
358
359
360
361
362
363
364});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.