Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat: Add scroll event listener to ScrollBox #187

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/ScrollBox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@
protected lastScrollY!: number | null;
protected proximityCheckFrameCounter = 0;
public onProximityChange = new Signal<(data: ProximityEventData) => void>();
public onScroll: Signal<(value: number) => void> = new Signal();

/**
* @param options
Expand Down Expand Up @@ -567,6 +568,9 @@

protected onMouseScroll(event: WheelEvent): void
{
const isVertical: boolean = this.options.type !== 'horizontal';
const oldScrollPos = isVertical ? this.scrollY : this.scrollX;

if (!this.isOver && !this.options.globalScroll) return;

this.renderAllItems();
Expand Down Expand Up @@ -610,6 +614,13 @@
}

this.stopRenderHiddenItems();


Check warning on line 618 in src/ScrollBox.ts

View workflow job for this annotation

GitHub Actions / build

More than 1 blank line not allowed
const newScrollPos = isVertical ? this.scrollY : this.scrollX;

if (newScrollPos !== oldScrollPos) {

Check warning on line 621 in src/ScrollBox.ts

View workflow job for this annotation

GitHub Actions / build

Opening curly brace appears on the same line as controlling statement
this.onScroll?.emit(newScrollPos);
}
}

/** Makes it scroll down to the last element. */
Expand Down Expand Up @@ -872,4 +883,12 @@
item.children.forEach((child) => this.revertClick(child));
}
}

get scrollHeight(): number {

Check warning on line 887 in src/ScrollBox.ts

View workflow job for this annotation

GitHub Actions / build

Opening curly brace appears on the same line as controlling statement
return this.list.height;
}

get scrollWidth(): number {

Check warning on line 891 in src/ScrollBox.ts

View workflow job for this annotation

GitHub Actions / build

Opening curly brace appears on the same line as controlling statement
return this.list.width;
}
}
Loading