Skip to content

Conversation

@lukePeavey
Copy link
Owner

Fixes two issues with absolute position:

  1. Text disappear when text is split into lines only, and target
    element does not contain any nested elements.

  2. Splitting text with absolute position slightly changes the visual
    appearance of the text. This was due to the fact that we used
    offsetTop and offsetLeft, which do not have sub-pixel precision.
    Now, we use getBoundingClientRect to determine the size and
    position of split text nodes. This has a slight negative impact on
    performance. But it prevents text from visibly shifting when it
    is split/un-split.

Before

The characters shift around slightly when text is split/un-split

before-absolute-position.2.mov

After

No visible change when text is split/un-split

after-absolute-position.mov

Fixes two issues with absolute position:

1. Text disappears when text is split into lines only, and target
element does not contain any nested elements.

2. Splitting text with absolute position slightly changes the visual
appearance of the text. This was due to the fact that we used
`offsetTop` and `offsetLeft`, which do not have sub-pixel precision.
Now, we use `getBoundingClientRect` to determine the size and
position of split text nodes. This has a slight negative impact on
performance. But it prevents text from visibly shifting when it
is split/un-split.
Changes:

1. Removed property `instance.originals.`  We store the original
html content of the target elements in the data store. This makes
it possible to revert the elements even if they were split by a
different instance. I don't think its necessary to also store them
as an instance property.
@lukePeavey lukePeavey merged commit b336c30 into master Jun 5, 2022
@lukePeavey lukePeavey deleted the fix/absolute-position-issues branch June 13, 2022 04:28
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