Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shiftContentOver({ silently = false } = {}): void {
- this.contentTransitionDuration = `${silently ? '0' : this.animDuration}s`;
- this.contentLeft = `-${this.blockWidth}`;
- }
- shiftContentBack({ silently = false } = {}): void {
- this.contentTransitionDuration = `${silently ? '0' : this.animDuration}s`;
- this.contentLeft = '0';
- }
- shift(forward: boolean): void {
- if (this.isAnimating) return;
- this.isAnimating = true;
- const coefficient = forward ? this.blocksAtOnce : -1;
- const newBlock = this.blocks.atBeyond(this.index + coefficient);
- this.visibleBlocks.insert(newBlock, forward);
- this.shiftContentOver({ silently: !forward });
- if (!forward) setTimeout(this.shiftContentBack, 0);
- this.index += forward ? 1 : -1;
- setTimeout((): void => {
- this.visibleBlocks.remove(!forward);
- if (forward) this.shiftContentBack({ silently: true });
- this.isAnimating = false;
- }, this.animDuration * 1000);
- }
- shiftLeft(): void {
- this.shift(true);
- }
- shiftRight(): void {
- this.shift(false);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement