-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Universal support for DimensionsHelper and ScrollbarHelper #1178
Conversation
…sions helper for serveeer service overrides based on params or client hints, using renderer2 vs render1
…lazy loaded module
Thanks for the PR, this looks awesome. Can you remove the built files? |
@@ -13,7 +14,7 @@ export declare class ScrollerComponent implements OnInit, OnDestroy { | |||
element: any; | |||
parentElement: any; | |||
onScrollListener: any; | |||
constructor(ngZone: NgZone, element: ElementRef); | |||
constructor(ngZone: NgZone, element: ElementRef, renderer: Renderer2); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you add Renderer here?
this.ngZone.runOutsideAngular(() => { | ||
this.parentElement.addEventListener('scroll', this.onScrolled.bind(this)); | ||
renderer.listen( | ||
this.parentElement, 'scroll', this.onScrolled.bind(this)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You actually shouldn't have to use the renderer to do this in v5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I originally started with v4
node.classList.add('resize-handle'); | ||
this.element.appendChild(node); | ||
const node = renderer2.createElement('span'); | ||
// node.classList.add('resize-handle'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove dead code.
export class DimensionsHelper { | ||
|
||
// tslint:disable-next-line:no-empty | ||
constructor() { } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why empty constructor?
@@ -808,7 +813,8 @@ export class DatatableComponent implements OnInit, DoCheck, AfterViewInit { | |||
* | |||
*/ | |||
recalculateDims(): void { | |||
const dims = this.element.getBoundingClientRect(); | |||
// const dims = this.element.getBoundingClientRect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove dead code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
PR should have all clean up now |
One last request, can you add your example config to the docs? |
…dditional DebugElements and cau
Added universal doc |
Thanks for your contribution!!! |
Your welcome |
What kind of change does this PR introduce? (check one with "x")
What is the current behavior? (You can also link to an open issue here)
Error when you load ngx-datagrid scrollbar width is calculated and grid width is calculated based on window size. With universal SSR we can't calculate it that same way so we need to replace implementation of DimensionHelper with a universal helpful version
What is the new behavior?
No error and you must implement your own DimensionsHelper. Here is a snippet of my version of SSR DimensionsHelper. I had to export this service in order to inject a different implementation.
Also had to create a ScrollbarHelper service implementation for server. Which returns my custom css style width of all scrollbars of 16.
I then added these two services using @NgModule providers
Does this PR introduce a breaking change? (check one with "x")
If this PR contains a breaking change, please describe the impact and migration path for existing applications: ...
Other information:
I did not include these sample implementations in my pull request since this strategy may not work for everyone.