Skip to content

Commit

Permalink
fix multiple logos
Browse files Browse the repository at this point in the history
  • Loading branch information
illetid authored and SlicedSilver committed Jul 25, 2024
1 parent bea721a commit eeb2b64
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
12 changes: 6 additions & 6 deletions src/gui/attribution-logo-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,7 @@ export class AttributionLogoWidget {
this._render();
}

private _shouldUpdate(): boolean {
return this._visible !== this._shouldBeVisible() || this._theme !== this._themeToUse();
}

private _removeElement(): void {
public removeElement(): void {
if (this._element) {
this._container.removeChild(this._element);
}
Expand All @@ -43,6 +39,10 @@ export class AttributionLogoWidget {
this._cssElement = undefined;
}

private _shouldUpdate(): boolean {
return this._visible !== this._shouldBeVisible() || this._theme !== this._themeToUse();
}

private _themeToUse(): LogoTheme {
return colorStringToGrayscale(this._chart.options().layout.textColor) > 160 ? 'dark' : 'light';
}
Expand All @@ -64,7 +64,7 @@ export class AttributionLogoWidget {
if (!this._shouldUpdate()) {
return;
}
this._removeElement();
this.removeElement();
this._visible = this._shouldBeVisible();
if (this._visible) {
this._theme = this._themeToUse();
Expand Down
9 changes: 6 additions & 3 deletions src/gui/pane-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ export class PaneWidget implements IDestroyable, MouseEventHandlers {
treatHorzTouchDragAsPageScroll: () => this._startTrackPoint === null && !this._chart.options().handleScroll.horzTouchDrag,
}
);

this._attributionLogoWidget = new AttributionLogoWidget(this._paneCell, this._chart);
}

public destroy(): void {
Expand Down Expand Up @@ -187,8 +185,13 @@ export class PaneWidget implements IDestroyable, MouseEventHandlers {
}

this.updatePriceAxisWidgetsStates();
if (this._attributionLogoWidget) {

if (this._chart.paneWidgets().indexOf(this) === this._chart.paneWidgets().length - 1) {
this._attributionLogoWidget = this._attributionLogoWidget ?? new AttributionLogoWidget(this._paneCell, this._chart);
this._attributionLogoWidget.update();
} else {
this._attributionLogoWidget?.removeElement();
this._attributionLogoWidget = null;
}
}

Expand Down

0 comments on commit eeb2b64

Please sign in to comment.