Skip to content

Potential / Infrequent Issues #6

@mlisook

Description

@mlisook

Let me say first that these do not affect my use case - I'm happy with the element as is. They could be issues in other use cases. Feel free to close this if you don't feel they are important or likely to affect real world use.

  • scrollLeft is truncated to a whole number (effectively Math.floor()) at least in chromium based browsers, while getBoundingClientRect().width is not. This can lead to a situation where this.container.scrollLeft >= (this._numberOfImages-1) * this._getRect().width evaluates to something like 375 >= 375.75 (container is 501px, 4 images, last image). One could imagine fractions creeping in also if the width of the control is set by percentages also.

  • _computeNumberOfImages() is only called in the connectedCallback(). This can be a potential problem if the images are populated by <template is="dom-repeat" ...> and the array is retrieved via ajax such as a fetch. In that case the template could be rendered after connectedCallback() and the _numberOfImages property will remain at zero - dots will not appear, right/left navigation will not hide/display correctly.

  • Depending on the content, it might be desirable to have a default z-index on .right-icon and .left-icon. Of course, if needed, that can be set in --left-navigation-icon-mixin or --right-navigation-icon-mixin.

  • getBoundingClientRect() triggers a repaint and it can be called multiple times during an image change. It's not that bad since it is in response to a user action or the timer on auto scroll, but it could be optimized by just calling it once and saving the result.

Again, these do not affect my use case, but I can cause them if I am deliberate.

Thanks for publishing this.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions