收藏
回答

看不懂小程序扩展组件提供的video-swiper的代码,求解?

子组件的

animationfinish: function animationfinish(e) {

console.log(e)

console.log(this.data)

var _data = this.data,

_last = _data._last,

_change = _data._change,

curQueue = _data.curQueue,

prevQueue = _data.prevQueue,

nextQueue = _data.nextQueue;


var current = e.detail.current;

var diff = current - _last;

if (diff === 0) return;

this.data._last = current;

this.playCurrent(current);

this.triggerEvent('change', {

activeId: curQueue[current].id

});

var direction = diff === 1 || diff === -2 ? 'up' : 'down';

console.log(direction)

if (direction === 'up') {

if (this.data._invalidDown === 0) {

var change = (_change + 1) % 3;

var add = nextQueue.shift();

var remove = curQueue[change];

if (add) {

prevQueue.push(remove);

curQueue[change] = add;

this.data._change = change;

} else {

this.data._invalidUp += 1;

}

} else {

this.data._invalidDown -= 1;

}

}

if (direction === 'down') {

if (this.data._invalidUp === 0) {

var _change2 = _change; //2

var _remove = curQueue[_change2];

var _add = prevQueue.pop();

if (_add) {

curQueue[_change2] = _add;

nextQueue.unshift(_remove);

this.data._change = (_change2 - 1 + 3) % 3;

} else {

this.data._invalidDown += 1;

}

} else {

this.data._invalidUp -= 1;

}

}

var circular = true;

if (nextQueue.length === 0 && current !== 0) {

circular = false;

}

if (prevQueue.length === 0 && current !== 2) {

circular = false;

}

this.setData({

curQueue: curQueue,

circular: circular

});

},

这些属性都代表啥意思?

_last: 1,

_change: -1,

_invalidUp: 0,

_invalidDown: 0,


回答关注问题邀请回答
收藏
登录 后发表内容
问题标签