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

centering text is slow #90

Open
TheCollector2K opened this issue Aug 12, 2021 · 3 comments
Open

centering text is slow #90

TheCollector2K opened this issue Aug 12, 2021 · 3 comments

Comments

@TheCollector2K
Copy link

when text on the path is centered it is using this part of the code:
/* Center text according to the path's bounding box */ if (options.center) { var textLength = textNode.getComputedTextLength(); var pathLength = this._path.getTotalLength(); /* Set the position for the left side of the textNode */ textNode.setAttribute('dx', ((pathLength / 2) - (textLength / 2))); }

the getComputedTextLength() & getTotalLength() cause reflows in the browser and are very slow when a lot of text is added. I've tried replacing this and came up with adding these attributes to the path-element and remove the above code:

textPath.setAttribute('text-anchor', 'middle'); textPath.setAttribute('startOffset', '50%');

Maybe someone could check and (when it's ok) add it to the code.

@EliezerB123
Copy link

@TheCollector2K Have you found a workaround, in the meantime?

@samcrawford
Copy link

I have a similar issue with the 'repeat' option, which I see uses the same slow function calls. I can't see a way to remove these though. Any ideas? @TheCollector2K ?

@akamuza
Copy link

akamuza commented Oct 27, 2023

Same issue here. Long polylines are lagging heavily with markers on it.

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

No branches or pull requests

4 participants