// 滚动到指定位置---begin function getscrolltop() { return (document.scrollingelement && document.scrollingelement.scrolltop) || document.documentelement.scrolltop || document.body.scrolltop; } function setscrolltop(st) { if (!st) st = 0; document.documentelement.scrolltop = document.body.scrolltop = st; } function scrolltop(scrolltop, time) { scrolltop = scrolltop ? scrolltop : 0; time = time ? time : 500; const cubic = function (value) { return math.pow(value, 3) }; const easeinoutcubic = function (value) { return value < 0.5 ? cubic(value * 2) / 2 : 1 - cubic((1 - value) * 2) / 2 } const begintime = date.now(); const beginvalue = getscrolltop(); const raf = window.requestanimationframe || (function (func) { return settimeout(func, 16) }); const framefunc = function () { if (isnan(+time) || +time === 0) { setscrolltop(scrolltop); return; } const progress = (date.now() - begintime) / time; if (progress < 1) { setscrolltop( scrolltop + (beginvalue - scrolltop) * (1 - easeinoutcubic(progress)) ); raf(framefunc); } else { setscrolltop(scrolltop); } }; raf(framefunc); }; /** 获取指定元素距离页面顶部距离 */ function getelementtopagetop(el) { if(el.parentelement) { return getelementtopagetop(el.parentelement) + el.offsettop } return el.offsettop } /** 获取指定元素高度 */ function getelementheight(el) { return el.clientheight; } function playfirstvideo() { var videocontain = $($('.index-top-banner .swiper-slide')[0]); var curvideo = videocontain.find('video'); if (curvideo.length) { curvideo.trigger('play'); } } // 滚动到指定位置---end // 首页,滚动到到“我们能做什么时动画” $(function(){ var ua = navigator.useragent; var ipad = ua.match(/(ipad).*os\s([\d_]+)/), isiphone =!ipad && ua.match(/(iphone\sos)\s([\d_]+)/), isandroid = ua.match(/(android)\s+([\d.]+)/), ismobile = isiphone || isandroid; if(ismobile){ window.location.replace('/cn/m/'); } try { var navheight = getelementheight(document.getelementsbyclassname('top-nav')[0]); var top = getelementtopagetop(document.getelementbyid('weare')); $('.arrow-down').click(function() { scrolltop(top - navheight, 500); }); } catch (error) { console.log(error) } //try { // var myindextopswiper = new swiper('.index-top-banner.swiper-container', { // autoplay: 5000, // autoplaydisableoninteraction : false, // pagination: '.index-top-banner .swiper-pagination', // nextbutton: '.index-top-banner .swiper-button-next', // prevbutton: '.index-top-banner .swiper-button-prev', // resize: function() { // //窗口变化了 // myindextopswiper.updatesize(); // }, // oninit: function(swiper){ // //playfirstvideo(); // }, // onslidechangeend: function (swiper){ // var videocontain = $($('.index-top-banner .swiper-slide')[this.activeindex]); // var curvideo = videocontain.find('video'); // if (curvideo.length) { // curvideo.trigger('play'); // } // //var othervideo = videocontain.siblings().find('video'); // //for (var i = 0; i < othervideo.length; i++) { // // if (!!window.activexobject || "activexobject" in window) { // // return false; // // } else { // // othervideo[i].currenttime = 0; // // othervideo.trigger('pause'); // // } // //} // } // }); //} catch (error) { // console.log(error) //} //try { // function controlvideo() { // var videocontain = $($('.index-top-banner .swiper-slide')[0]); // var videos = videocontain.find('video'); // if (videos.length > 0) { // myindextopswiper.stopautoplay(); // videos[0].onended = function(){ // myindextopswiper.startautoplay(); // settimeout(() => { // myindextopswiper.slidenext() // }, 300); // } // } else { // myindextopswiper.startautoplay(); // } // } // controlvideo(); //} catch (error) { // console.log(error) //} });