Skip to content

Position.within fails when parent dom tree contains css transformations #322

Open

Description

@qsiebers

Position.within fails to take into account transformations performed by the CSS transform properties. The cause is probably located within Element.cumulativeOffset.

I'm not sure on how to fix this, or if it's even wanted.

Activity

  1. savetheclocktower commented on Oct 14, 2016

    @savetheclocktower
    Collaborator

    Yeah, not sure there's much to do about that. Last time I checked (though it's been a few years) there wasn't a reliable way to figure out where an element was on the screen with transforms taken into account. Properties like offsetLeft don't "see" transforms, and even stuff like getBoundingClientRect didn't behave uniformly across browsers when transforms are applied.

    But I should check again, so I'll leave this open for now.

  2. qsiebers commented on Oct 16, 2016

    @qsiebers
    Author

    It seems you can use window.getComputedStyle() to get the transformation matrix. You can then calculate the new transformed position of the element. I think I'll change my own workaround to use the translate values provided by the matrix.

    It might be a nice feature to use all the transformation matrix information in calculating correct location, although this would hardly be optimal unless there is a way to get this information directly from the browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions