Skip to content

Commit

Permalink
add loggin
Browse files Browse the repository at this point in the history
  • Loading branch information
wouter-willems committed Jul 26, 2024
1 parent 17c738e commit 96fef4e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
2 changes: 1 addition & 1 deletion projects/klippa/ngx-enhancy-forms/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@klippa/ngx-enhancy-forms",
"version": "14.22.7",
"version": "14.22.8",
"publishConfig": {
"access": "public"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,23 +180,17 @@ export class FormElementComponent implements AfterViewInit {
}
}

getPageOffset(elem): number {
let topOffset = elem.getBoundingClientRect().top;

while (elem !== document.documentElement) {
elem = elem.parentElement;
topOffset += elem.scrollTop;
}
return topOffset;
}

scrollTo(): void {
const parent = this.getScrollableParent(this.internalComponentRef.nativeElement);
const pageOffsetElement = this.getPageOffset(this.internalComponentRef.nativeElement);
const pageOffsetParent = parent === window.document.documentElement ? 0 : this.getPageOffset(parent);
const parentTop = parent === window.document.documentElement ? 0 : parent.getBoundingClientRect().top;
const elementTop = this.internalComponentRef.nativeElement.getBoundingClientRect().top;
const parentScrollTop = parent.scrollTop;
const answer = elementTop - parentTop + parentScrollTop;
console.log('answer', parentTop, elementTop, parentScrollTop, answer);
console.log(parent, this.internalComponentRef.nativeElement);

parent.scrollTo({
top: pageOffsetElement - pageOffsetParent - 30,
top: answer - 30,
behavior: 'smooth'
});
}
Expand Down

0 comments on commit 96fef4e

Please sign in to comment.