ScrollView: ScrollPos -> ScrollView.Pos
This commit is contained in:
@@ -208,7 +208,7 @@ class Column {
|
||||
this.stacked = !this.stacked;
|
||||
}
|
||||
|
||||
public isVisible(scrollPos: ScrollPos, fullyVisible: boolean) {
|
||||
public isVisible(scrollPos: ScrollView.Pos, fullyVisible: boolean) {
|
||||
if (fullyVisible) {
|
||||
return this.getLeft() >= scrollPos.getLeft() &&
|
||||
this.getRight() <= scrollPos.getRight();
|
||||
|
||||
@@ -78,7 +78,7 @@ class Grid {
|
||||
this.width = x - this.config.gapsInnerHorizontal;
|
||||
}
|
||||
|
||||
public getLeftmostVisibleColumn(scrollPos: ScrollPos, fullyVisible: boolean) {
|
||||
public getLeftmostVisibleColumn(scrollPos: ScrollView.Pos, fullyVisible: boolean) {
|
||||
const scrollX = scrollPos.getLeft();
|
||||
for (const column of this.columns.iterator()) {
|
||||
const x = fullyVisible ? column.getLeft() : column.getRight() + (this.config.gapsInnerHorizontal - 1);
|
||||
@@ -89,7 +89,7 @@ class Grid {
|
||||
return null;
|
||||
}
|
||||
|
||||
public getRightmostVisibleColumn(scrollPos: ScrollPos, fullyVisible: boolean) {
|
||||
public getRightmostVisibleColumn(scrollPos: ScrollView.Pos, fullyVisible: boolean) {
|
||||
const scrollX = scrollPos.getRight();
|
||||
let last = null;
|
||||
for (const column of this.columns.iterator()) {
|
||||
@@ -103,7 +103,7 @@ class Grid {
|
||||
return last;
|
||||
}
|
||||
|
||||
public getVisibleColumnsWidth(scrollPos: ScrollPos, fullyVisible: boolean) {
|
||||
public getVisibleColumnsWidth(scrollPos: ScrollView.Pos, fullyVisible: boolean) {
|
||||
let width = 0;
|
||||
let nVisible = 0;
|
||||
for (const column of this.columns.iterator()) {
|
||||
@@ -120,7 +120,7 @@ class Grid {
|
||||
return width;
|
||||
}
|
||||
|
||||
private getLeftOffScreenColumn(scrollPos: ScrollPos) {
|
||||
private getLeftOffScreenColumn(scrollPos: ScrollView.Pos) {
|
||||
const leftVisible = this.getLeftmostVisibleColumn(scrollPos, true);
|
||||
if (leftVisible === null) {
|
||||
return null;
|
||||
@@ -128,7 +128,7 @@ class Grid {
|
||||
return this.getPrevColumn(leftVisible);
|
||||
}
|
||||
|
||||
private getRightOffScreenColumn(scrollPos: ScrollPos) {
|
||||
private getRightOffScreenColumn(scrollPos: ScrollView.Pos) {
|
||||
const rightVisible = this.getRightmostVisibleColumn(scrollPos, true);
|
||||
if (rightVisible === null) {
|
||||
return null;
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
class ScrollPos {
|
||||
public readonly x: number;
|
||||
public readonly width: number;
|
||||
|
||||
constructor(x: number, width: number) {
|
||||
this.x = x;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public getLeft() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public getRight() {
|
||||
return this.x + this.width;
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,7 @@ class ScrollView {
|
||||
this.autoAdjustScroll();
|
||||
}
|
||||
|
||||
// calculates ScrollPos that scrolls the column into view
|
||||
// calculates ScrollView.Pos that scrolls the column into view
|
||||
public getScrollPosForColumn(column: Column) {
|
||||
const left = column.getLeft();
|
||||
const right = column.getRight();
|
||||
@@ -89,7 +89,7 @@ class ScrollView {
|
||||
}
|
||||
|
||||
private getScrollPos(scrollX: number) {
|
||||
return new ScrollPos(scrollX, this.tilingArea.width);
|
||||
return new ScrollView.Pos(scrollX, this.tilingArea.width);
|
||||
}
|
||||
|
||||
public getCurrentScrollPos() {
|
||||
@@ -111,7 +111,7 @@ class ScrollView {
|
||||
this.scrollX = force ? x : this.clampScrollX(x);
|
||||
}
|
||||
|
||||
private applyScrollPos(scrollPos: ScrollPos) {
|
||||
private applyScrollPos(scrollPos: ScrollView.Pos) {
|
||||
this.scrollX = scrollPos.x;
|
||||
}
|
||||
|
||||
@@ -151,4 +151,22 @@ module ScrollView {
|
||||
marginRight: number,
|
||||
overscroll: number,
|
||||
}
|
||||
|
||||
export class Pos {
|
||||
public readonly x: number;
|
||||
public readonly width: number;
|
||||
|
||||
constructor(x: number, width: number) {
|
||||
this.x = x;
|
||||
this.width = width;
|
||||
}
|
||||
|
||||
public getLeft() {
|
||||
return this.x;
|
||||
}
|
||||
|
||||
public getRight() {
|
||||
return this.x + this.width;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user