Skip to content

Commit

Permalink
Merge branch '0.0.39'
Browse files Browse the repository at this point in the history
  • Loading branch information
mayakwd committed Dec 20, 2020
2 parents b9e0eba + f4d416c commit 6179df2
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 27 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ deploy:
api_key: $GITHUB_TOKEN
file_glob: true
file: "pixi-yoo-ai-*.tgz"
skip_cleanup: true
cleanup: true
on:
tags: true
- provider: npm
edge: true
skip_cleanup: true
cleanup: true
email: "[email protected]"
api_key: $NPM_TOKEN
on:
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Changelog
All notable changes to this project will be documented in this file.

# 0.0.37 - 2020-12-06
# 0.0.39 - 2020-12-20
- Fixed: All scroll methods of the lists now works with the `animated` flag as expected.

# 0.0.38 - 2020-12-06
- Feature: Added setters for `centerX` and `centerY`

# 0.0.37 - 2020-11-30
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pixi-yoo-ai",
"version": "0.0.38",
"version": "0.0.39",
"description": "Yoo Ai. Extensive UI library for PixiJS v5",
"author": "Ilya Malanin",
"license": "MIT",
Expand Down
2 changes: 2 additions & 0 deletions src/yooai/containers/List.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,15 @@ export class List<T> extends VirtualScrollList<T> {
this.scrollTo(
index * (this.rowHeight + this.verticalGap),
this.horizontalScrollPosition,
animated
);
}

public scrollToPage(index: number, animated: boolean = true): void {
this.scrollTo(
this.pageHeight * index,
this.horizontalScrollPosition,
animated
);
}

Expand Down
10 changes: 5 additions & 5 deletions src/yooai/containers/TileList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class TileList<T> extends List<T> {
this.componentWidth = (this.horizontalGap + this.columnWidth) * value - this.horizontalGap + this.contentPadding * 2;
}

public scrollToIndex(index: number): void {
public scrollToIndex(index: number, animated: boolean = true): void {
let verticalPosition: number = this.verticalScrollPosition;
let horizontalPosition: number = this.horizontalScrollPosition;
switch (this._direction) {
Expand All @@ -60,7 +60,7 @@ export class TileList<T> extends List<T> {
horizontalPosition = Math.floor(index / this.rowsCount) * (this.columnWidth + this.horizontalGap);
break;
}
this.scrollTo(verticalPosition, horizontalPosition);
this.scrollTo(verticalPosition, horizontalPosition, animated);
}

public scrollToPage(index: number, animated = true): void {
Expand All @@ -74,7 +74,7 @@ export class TileList<T> extends List<T> {
horizontalPosition = this.pageWidth * index;
break;
}
this.scrollTo(verticalPosition, horizontalPosition);
this.scrollTo(verticalPosition, horizontalPosition, animated);
}

public scrollPageUp(animated = true): void {
Expand Down Expand Up @@ -109,10 +109,10 @@ export class TileList<T> extends List<T> {
);
}

protected scrollBy(verticalOffset: number, horizontalOffset: number, animated: boolean) {
protected scrollBy(verticalOffset: number, horizontalOffset: number, animated: boolean = true) {
const verticalPosition: number = this.verticalScrollPosition + verticalOffset;
const horizontalPosition: number = this.horizontalScrollPosition + horizontalOffset;
this.scrollTo(verticalPosition, horizontalPosition);
this.scrollTo(verticalPosition, horizontalPosition, animated);
}

protected calculateDrawListIndexes(): { startIndex: number; endIndex: number } {
Expand Down
32 changes: 14 additions & 18 deletions src/yooai/containers/VirtualScrollList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ import {
import {BaseScrollPane} from "./BaseScrollPane";

export abstract class VirtualScrollList<T> extends BaseScrollPane {
public get animated(): boolean {
return this._animated;
}

public set animated(value: boolean) {
this._animated = value;
}

public get maxSelectedItemsCount(): number {
return this._maxSelectedItemsCount;
}
Expand Down Expand Up @@ -341,51 +333,55 @@ export abstract class VirtualScrollList<T> extends BaseScrollPane {
return index !== -1 && this._selectedIndices.indexOf(index) !== -1;
}

public scrollToSelected(): void {
this.scrollToIndex(this.selectedIndex);
public scrollToSelected(animated: boolean = true): void {
this.scrollToIndex(this.selectedIndex, animated);
}

public abstract scrollToIndex(index: number): void;
public abstract scrollToIndex(index: number, animated: boolean): void;

public abstract scrollToPage(index: number): void;
public abstract scrollToPage(index: number, animated: boolean): void;

public scrollPageUp(): void {
public scrollPageUp(animated: boolean = true): void {
this.scrollTo(
this.verticalScrollPosition - this.pageHeight,
this.horizontalScrollPosition,
animated,
);
}

public scrollPageDown(): void {
public scrollPageDown(animated: boolean = true): void {
this.scrollTo(
this.verticalScrollPosition + this.pageHeight,
this.horizontalScrollPosition,
animated,
);
}

public scrollRowUp(): void {
public scrollRowUp(animated: boolean = true): void {
this.scrollTo(
this.verticalScrollPosition - this.rowHeight - this.verticalGap,
this.horizontalScrollPosition,
animated,
);
}

public scrollRowDown(): void {
public scrollRowDown(animated: boolean = true): void {
this.scrollTo(
this.verticalScrollPosition + this.rowHeight + this.verticalGap,
this.horizontalScrollPosition,
animated
);
}

public scrollTo(verticalPosition: number, horizontalPosition: number) {
public scrollTo(verticalPosition: number, horizontalPosition: number, animated: boolean = true) {
verticalPosition = Math.min(Math.max(0, verticalPosition), this.maxVerticalScrollPosition);
horizontalPosition = Math.min(Math.max(0, horizontalPosition), this.maxHorizontalScrollPosition);

if (verticalPosition === this.verticalScrollPosition && horizontalPosition === this.horizontalScrollPosition) {
return;
}

if (this._animated) {
if (animated) {
const distance = Math.sqrt(
Math.pow(this.verticalScrollPosition - verticalPosition, 2) +
Math.pow(this.horizontalScrollPosition - horizontalPosition, 2),
Expand Down

0 comments on commit 6179df2

Please sign in to comment.