Skip to content

Commit

Permalink
Change files (#5248)
Browse files Browse the repository at this point in the history
  • Loading branch information
robarbms authored Oct 4, 2021
1 parent a8e6ee6 commit 5f6c838
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "minor",
"comment": "feat: add scroll events to horizontal-scroll component",
"packageName": "@microsoft/fast-foundation",
"email": "robarb@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,20 @@ export class HorizontalScroll extends FoundationElement {
* Scrolling state
* @internal
*/
@observable
private scrolling: boolean = false;

/**
* Firing scrollstart and scrollend events
* @internal
*/
private scrollingChanged() {
if (this.scrollContainer) {
const event = this.scrolling == true ? "scrollstart" : "scrollend";
this.$emit(event, this.scrollContainer.scrollLeft);
}
}

/**
* Detects if the component has been resized
* @internal
Expand Down Expand Up @@ -404,14 +416,15 @@ export class HorizontalScroll extends FoundationElement {
return;
}

this.scrolling = true;

if (this.speed < 1) {
this.scrollContainer.style.scrollBehavior = "auto";
this.scrollContainer.scrollLeft = newPosition;
this.scrolling = false;
return;
}

this.scrolling = true;

const steps: number[] = [];
const direction: number = position < newPosition ? 1 : -1;
const scrollDistance: number = Math.abs(newPosition - position);
Expand Down

0 comments on commit 5f6c838

Please sign in to comment.