-
Notifications
You must be signed in to change notification settings - Fork 18
feat(component): implemented breakpoints utlity in the post-header
component
#4652
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(component): implemented breakpoints utlity in the post-header
component
#4652
Conversation
🦋 Changeset detectedLatest commit: 07738fc The changes in this PR will be included in the next version bump. This PR includes changesets to release 15 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
…he-new-composible-header
packages/components/src/components/post-megadropdown/post-megadropdown.tsx
Show resolved
Hide resolved
c634e57
to
52d2081
Compare
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.
The calls seem to be made at the right time now, but on scroll the header height is not reduced anymore in desktop
0aaebc0
to
9e3448a
Compare
…he-new-composible-header
…he-new-composible-header
…he-new-composible-header
…he-new-composible-header
Depends on #4764 |
…he-new-composible-header
…he-new-composible-header
|
*/ | ||
@Event() postUpdateDevice: EventEmitter<DEVICE_SIZE>; | ||
connectedCallback() { | ||
window.addEventListener('postBreakpoint:name', this.breakpointChange.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.
Since this.breakpointChange is a private function of the component class (getting the context of the class anyway), do we really need to bind(this) here?
Make sure you update the removeEventListener respectively!
@Event() postUpdateDevice: EventEmitter<DEVICE_SIZE>; | ||
connectedCallback() { | ||
window.addEventListener('postBreakpoint:name', this.breakpointChange.bind(this)); | ||
window.addEventListener('resize', this.throttledResize, { passive: true }); |
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.
this.thottledScroll is not thorttling at all and only returns a function call.
Can be simplified by:
window.addEventListener('resize', this.throttledResize, { passive: true }); | |
window.addEventListener('resize', this.handleScrollEvent, { passive: true }); |
Make sure you update the removeEventListener respectively!
And you can then remove the line above private throttledScroll = () => this.handleScrollEvent();
BTW: This event gets binded twice in the component.
Once in the componentWillRender
and once in the connectedCallback
lifecylce hook.
I would suggest to remove the binding in the componentWillRender
hook and only keep the other.
this.switchLanguageSwitchMode(); | ||
}); | ||
} | ||
this.device = breakpoint.get('name'); |
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.
This should not be necessary, because you're setting this.device
initially and then everytime a breakpointChange happens.
this.device = event.detail; | ||
}); | ||
} | ||
window.addEventListener('postBreakpoint:name', this.breakpointChange.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.
Is the context binding (.bind(this)
) really necessary?
If not, remove it and update the removeEventListener respectively.
on hold until cargo go live |
After discussion in the dev roundtable, we've decided to close this PR and create a new ticket: #5357. Reasons: |
No description provided.