Skip to content

centering text is slow #90

@TheCollector2K

Description

@TheCollector2K

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions