Closed rcoopr closed 1 month ago
Hey, thanks for the investigation! I don't have any experience with Preact and I wasn't planning on doing an official wrapper for it, but I may change my mind once I get a few more out. In the future I want to make it easier for other people to create framework wrappers for NumberFlow. Converting this to a discussion for now 👋
Would love to integrate this in some of my current projects, but many use preact. There are a few outstanding issues though
Component mount:
There is a call to
this.attachShadow({ mode: "open" })
here https://github.com/barvian/number-flow/blob/366217dfd7262172d40efd5ff232f5a773a49821/packages/number-flow/src/index.ts#L93If we make this conditional on
!this.shadowRoot
, the component mounts.Trend (auto)
We run into an issue with
trend
. Leavingtrend
on default, the transition from 9 -> 10 loops the last digit through 8, 7, ..., 1, 0 - instead of the correct behaviour of simply going from 9 to 0.Steps to reproduce:
Add this code to the homepage:
HMR
There is another issue with HMR.
customElements.define
may be called after already having defined the custom element. The steps to reproduc this are:<NumberFlow />
element and save the file.<NumberFlow />
element and save.This error is produced:
So it looks like we need to check if the custom element has already been defined before calling
define
I have not worked with custom elements before, but I could potentially look into these issues in the coming couple of weeks.
Thanks again for the library.