-
Notifications
You must be signed in to change notification settings - Fork 9
fix #540
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
base: main
Are you sure you want to change the base?
fix #540
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -825,9 +825,13 @@ export class LiveboardEmbed extends V1Embed { | |
| } | ||
|
|
||
| private sendFullHeightLazyLoadData = () => { | ||
| if (!this.iFrame?.getBoundingClientRect) { | ||
| return; | ||
| } | ||
|
|
||
| const data = calculateVisibleElementData(this.iFrame); | ||
| // this should be fired only if the lazyLoadingForFullHeight and fullHeight are true | ||
| if(this.viewConfig.lazyLoadingForFullHeight && this.viewConfig.fullHeight){ | ||
| if (this.viewConfig.lazyLoadingForFullHeight && this.viewConfig.fullHeight) { | ||
| this.trigger(HostEvent.VisibleEmbedCoordinates, data); | ||
| } | ||
|
Comment on lines
+828
to
836
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The if (this.viewConfig.lazyLoadingForFullHeight && this.viewConfig.fullHeight) {
if (!this.iFrame?.getBoundingClientRect) {
return;
}
const data = calculateVisibleElementData(this.iFrame);
this.trigger(HostEvent.VisibleEmbedCoordinates, data);
} |
||
| }; | ||
|
|
@@ -840,6 +844,11 @@ export class LiveboardEmbed extends V1Embed { | |
| */ | ||
| private requestVisibleEmbedCoordinatesHandler = (data: MessagePayload, responder: any) => { | ||
| logger.info('Sending RequestVisibleEmbedCoordinates', data); | ||
|
|
||
| if (!this.iFrame?.getBoundingClientRect) { | ||
| return; | ||
| } | ||
|
|
||
| const visibleCoordinatesData = calculateVisibleElementData(this.iFrame); | ||
| responder({ type: EmbedEvent.RequestVisibleEmbedCoordinates, data: visibleCoordinatesData }); | ||
| } | ||
|
|
@@ -1033,7 +1042,7 @@ export class LiveboardEmbed extends V1Embed { | |
| private unregisterLazyLoadEvents() { | ||
| if (this.viewConfig.fullHeight && this.viewConfig.lazyLoadingForFullHeight) { | ||
| window.removeEventListener('resize', this.sendFullHeightLazyLoadData); | ||
| window.removeEventListener('scroll', this.sendFullHeightLazyLoadData); | ||
| window.removeEventListener('scroll', this.sendFullHeightLazyLoadData, 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.
The
calculateVisibleElementDatafunction is called and its result is computed even when thelazyLoadingForFullHeightandfullHeightconditions are not met. SincecalculateVisibleElementDatainternally callsgetBoundingClientRect, which can trigger a browser reflow/layout, it is more efficient to perform the configuration check first and only proceed with the calculation if the event is actually going to be triggered.