_transformToCenter(id) {
const increment = 1;
const myTarget = document.getElementById(id);
const { x, width } = myTarget.getBoundingClientRect();
const elementCenter = x + ((width / 2));
const diff = this.center - elementCenter;
if (diff < 0) {
this.container.scrollLeft += increment;
} else {
this.container.scrollLeft -= increment;
}
this._resizeAll();
if (diff < -SWIPE_THRESHOLD || diff > SWIPE_THRESHOLD) {
setTimeout(() => {
this._transformToCenter(id);
}, TRANSFORM_TIME);
}
}
_easeInOutQuad(x, t, b, c, d) {
if ((t /= d / 2) < 1) return c / 2 * t * t + b;
return -c / 2 * ((--t) * (t - 2) - 1) + b;
}
需要添加这样的函数(easeinoutquad),但我不知道如何添加。当我调用此函数时,它会将元素转换为中心,但希望添加ease-in函数,即如果元素的位置远离中心,则可以进行ease-in和ease-out
暂无答案!
目前还没有任何答案,快来回答吧!