}
}
// 结尾几个
else if (this.options.htmls.length - dex <= this.options.count) {
this.transX = this.wrapWidth - this.width;// 设置应到位置。
if (this.startTransX > this.transX) {
let _sign = sign (this.transX - this.startTransX);
this.cssX = this.transX - _sign * this.tWidth;
requestAnimFrame (step.bind (this));
function step () {
this.cssX += _sign * speed;
if (_sign * (this.cssX - this.transX) < 0) requestAnimFrame (step.bind (this));
else {
this.cssX = this.startTransX = this.transX;
if (typeof this.options.slideCallback == "function") this.options.slideCallback (dex);
}
};
}
else {
this.cssX = this.startTransX = this.transX; //无需动画
if (typeof this.options.slideCallback == "function") this.options.slideCallback (dex);
}
}
//中
else {
this.transX = -this.tWidth * dex;// 设置应到位置。
let _sign = sign (this.transX - this.startTransX);
if (this.tWidth * (dex + 0.5 * (1 - _sign)) + this.startTransX >= 0 && this.tWidth * (dex + 0.5 * (1 - _sign)) + this.startTransX <= this.wrapWidth) {
//无需动画
this.cssX = this.transX = this.startTransX;
if (typeof this.options.slideCallback == "function") this.options.slideCallback (dex);
}
else {
//需要动画
this.cssX = this.transX - _sign * this.tWidth;
requestAnimFrame (step.bind (this));
function step () {
this.cssX += _sign * speed;
if (_sign * (this.cssX - this.transX) < 0) requestAnimFrame (step.bind (this));
else {
this.cssX = this.startTransX = this.transX;
if (typeof this.options.slideCallback == "function") this.options.slideCallback (dex);
}
};
}
}
},
isTop(){
var windowOffset = this.getWindowOffset (),
winOffsetY = windowOffset.offsetY,
isTop;
isTop = this.elemOffsetY <= winOffsetY;
if (isTop) {
this.$el.children[0].style['position'] = 'fixed';
this.$el.children[0].style['top'] = '0';
this.$el.children[0].style['left'] = '0';
}
else {
this.$el.children[0].style['position']='relative';
}
return isTop;
},
getWindowOffset(){
var t;
var win = window;
var pageXOffset = (typeof win.pageXOffset == 'number') ? win.pageXOffset : (((t = doc.documentElement) || (t = body.parentNode)) && typeof t.ScrollLeft == 'number' ? t : body).ScrollLeft;
var pageYOffset = (typeof win.pageYOffset == 'number') ? win.pageYOffset : (((t = doc.documentElement) || (t = body.parentNode)) && typeof t.ScrollTop == 'number' ? t : body).ScrollTop;
return {
offsetX: pageXOffset,
offsetY: pageYOffset
};
},
},
watch: {
options(){
this.tabsWrapID = parseInt (Math.random () * 1e10);
setTimeout (this.init.bind (this), 10);










