Skip to content
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

Changing Overlay Implementation #9

Closed
wants to merge 4 commits into from

Conversation

Nour-Cheour10
Copy link
Contributor

No description provided.

_view_module = Unicode(module_name).tag(sync=True)
_view_module_version = Unicode(module_version).tag(sync=True)
overlay_type = Unicode().tag(sync=True)
position = List([0, 0]).tag(sync=True)

class ImageOverlay (BaseOverlay):
_view_name = Unicode('ImageOverlayView').tag(sync=True)
_model_name = Unicode('ImageOverlayModel').tag(sync=True)

overlay_type = Unicode('image').tag(sync=True)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems we don't need the overlay_type anymore

Comment on lines +40 to +41
this.element = document.createElement('img');
super.render();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That works, but the rule should be to always call super first.

I am actually surprised TypeScript is not complaining here.

The problem is that doing so would break your widget because this.element would not be defined when creating the overlay.

One approach could be to define an abstract createElement method in BaseOverlayView, and all subclasses would need to provide the implementation., then you can call createElement in your BaseOverlayView's createOverlay method

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants