//详情页固定 function fix (options){ if(!options || !options.selector) {throw new error('必须传入selector属性')} if(options.tip == undefined || options.tip === true ){this.tip()} this.selector = document.queryselector(options.selector) this.top = parseint(options.top) || 0 this.offsety = this.selector.getboundingclientrect().y this.offsetx = this.selector.getboundingclientrect().x window.addeventlistener('scroll', this.handle.bind(this)) } fix.prototype.handle = function(event){ this.scrolltop = document.documentelement.scrolltop || document.body.scrolltop if((this.offsety - this.scrolltop ) < this.top){ this.set() }else{ this.reset() } } fix.prototype.set = function(){ this.selector.style.position = 'fixed' this.selector.style.top = 0 this.selector.style.left = this.offsetx + 'px' } fix.prototype.reset = function(){ this.selector.style.position = 'static' this.selector.style.top = null } fix.prototype.tip = function(){ console.log("fix配置对象参数:",{selector:'进行固定的标签选择器',top:'距离顶部多少时开始固定,默认:0',tip:'开启参数提示,默认为true'}) } //职位页下拉 function slide(options){ if(typeof options.tip == 'undefined' || options.tip === true ){this.tip()} if(!options || !options.selector) {throw new error('配置为对象类型,必须传入的属性有:selector,slide')} this.list = document.queryselectorall(options.selector + ' ' + options.list) this.slide = options.slide this.height = typeof options.slideheight !='undefined' ? parseint(options.slideheight) + 'px' : '330px' this.speed = typeof options.speed !=='number' ? '0.5s' : (options.speed / 1000 + 's') for(var i=0,length=this.list.length;i