// javascript document $("#my-menu").mmenu({ slidingsubmenus:true, extensions: ["pagedim-black","pageshadow"], "offcanvas": { "position": "right" } }); var api = $("#my-menu").data( "mmenu" ); $("#hamburger").click(function() { api.open(); }); $(function() { $('#gototop a').click(function() { $('html , body').animate({ scrolltop: 0 }, 'slow'); }); }); /*手机导航按钮*/ $(".m-header").on("click", ".hamburger", function() { var next = $(this).next(); next.slidetoggle("slow"); $(".panel-body").not(next).slideup(); }) var foreach = function(t, o, r) { if ("[object object]" === object.prototype.tostring.call(t)) for (var c in t) object.prototype.hasownproperty.call(t, c) && o.call(r, t[c], c, t); else for (var e = 0, l = t.length; l > e; e++) o.call(r, t[e], e, t) }; var hamburgers = document.queryselectorall(".hamburger"); if (hamburgers.length > 0) { foreach(hamburgers, function(hamburger) { hamburger.addeventlistener("click", function() { this.classlist.toggle("is-active"); }, false); }); } function floor(totop,fixedevery,louceng,header) { this.totop = totop; this.fixedevery = fixedevery; this.louceng = louceng; this.header = header; } floor.prototype = { init: function () { var that = this; that.start(); this.totopclick(); this.fixedeveryclick(); }, start: function () { var that = this; $(window).scroll(function(){ var winh=$(window).height(); var itop = $(window).scrolltop();//鼠标滚动的距离 $(that.fixedevery).parent().fadein(); $(that.totop).fadein(); $(that.louceng).each(function(){ if(winh+itop - $(this).offset().top>winh/2){ $(that.fixedevery).removeclass('active'); $(that.fixedevery).eq($(this).index()).addclass('active'); } }) }); }, totopclick: function () { var that = this; $(that.totop).click(function(){ $('body,html').animate({"scrolltop":0},500) }) }, fixedeveryclick: function () { var that = this; $(that.fixedevery).click(function(){ var t = $(that.louceng).eq($(this).index()).offset().top - 114; $('body,html').animate({"scrolltop":t},500); $(this).addclass('active').siblings().removeclass('active'); }); } } $(".search").click(function () { $(".hide-center").fadein("slow"); $(".overcurtain").fadein("slow"); }) $(".overcurtain").click(function () { $(".hide-center").fadeout("slow"); $(".overcurtain").fadeout("slow"); }) $(function(){ $(window).on('scroll', function(){ if($(window).scrolltop() > 200){ $('.header').addclass('h-showdown'); } else { $('.header').removeclass('h-showdown'); } }); }); $(function(){ $(window).on('scroll', function(){ if($(window).scrolltop() > 200){ $('#hamburger').addclass('h-showdown'); } else { $('#hamburger').removeclass('h-showdown'); } }); });