You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
where <x-tethered-element> may have any content inside it.
The problem we run into is that we want to move the <div> on the inside that a consumer gives us, and put render it inside our shadow DOM / shadow DOM polyfill.
Tether attempts to move this to the end of the body, for CSS reasons. I understand that that's important in most use cases, but we'd be willing to accept the additional burden of positioning the element in the correct place in the DOM. For that reason, we'd like an option.
@nadiam84 has made a PR for it below. We'd love to use and support the main line of tether without forking, so please have a look if you have a minute. Thanks a lot!
-Josh
Reacted by natcohen, Vedran Opačić and William Dibbern
I'm not sure about this. I suspect that if you enabled this doNotMoveInDOM flag in #192, you would break several of Tether's positioning assumptions, which would require us to add more special-casing to the already complex core code. Is there no other possible solution here?
It doesn't interfere with the existing positioning assumptions. Without this flag, everything is staying as it was before.
I checked the behavior with the simple positioning (where in normal situation there would be position: absolute), with the positioning inside a parent with the position: relative (in normal situation it would be moved to the bottom of the body). Also it works inside scrollable parent.
Could you maybe tell me where I can get a list of all this 'positioning assumptions'? I'm happy to check all possible situations, I don't want to break anything either.
Honestly I doubt that your PR will be enough to properly position the tooltips in all the edge cases, with my library there are a lot of lines to make sure that everything works in such conditions, Tether assumes that the tooltip is always on body so their computations are much less flexible. More work is needed.
I had this problem a while back when trying to integrate Tether.js with Ember, specifically with regards to animations. Tether.js currently makes the assumption that all of its calculations must be relative to the body, so warping it up to the body makes sense.
However, with Ember and React and other JS frameworks, there are times when we will have elements which are known to be the exact same size and position of the document (e.g. because they are attached to the root without any styles, or because they are an animation container which purposefully has the same sizing as the body). So, maybe the best option would be to remove the logic introduced in my earlier PR (#98) and introduce an option to specify what the "body" element should be for this tether. That way the element that it is warped to can be in the control of the user.
It would be the user's responsibility to determine that the element in question does have the exact same constraints as the body, and any element positioned in it would line up as if it were positioned relative to the body. This would just give users the ability to manage which element that is, exactly.
I believe this is possible using the bodyElement option. We do probably need to document it, but we'll have to look through all the code and ensure we update docs soon anyway.
Activity
adevnadia commentedon Jul 11, 2016
I created a pull-request with possible solution: #192
@TrevorBurnham @geekjuice Could you maybe have a look at this? We really need this feature, to make Tether work well with web components.
TrevorBurnham commentedon Jul 14, 2016
I'm not sure about this. I suspect that if you enabled this
doNotMoveInDOMflag in #192, you would break several of Tether's positioning assumptions, which would require us to add more special-casing to the already complex core code. Is there no other possible solution here?adevnadia commentedon Jul 14, 2016
It doesn't interfere with the existing positioning assumptions. Without this flag, everything is staying as it was before.
I checked the behavior with the simple positioning (where in normal situation there would be
position: absolute), with the positioning inside a parent with theposition: relative(in normal situation it would be moved to the bottom of the body). Also it works inside scrollable parent.Could you maybe tell me where I can get a list of all this 'positioning assumptions'? I'm happy to check all possible situations, I don't want to break anything either.
FezVrasta commentedon Aug 8, 2016
Honestly I doubt that your PR will be enough to properly position the tooltips in all the edge cases, with my library there are a lot of lines to make sure that everything works in such conditions, Tether assumes that the tooltip is always on body so their computations are much less flexible. More work is needed.
pzuraq commentedon Aug 26, 2016
I had this problem a while back when trying to integrate Tether.js with Ember, specifically with regards to animations. Tether.js currently makes the assumption that all of its calculations must be relative to the body, so warping it up to the body makes sense.
However, with Ember and React and other JS frameworks, there are times when we will have elements which are known to be the exact same size and position of the document (e.g. because they are attached to the root without any styles, or because they are an animation container which purposefully has the same sizing as the body). So, maybe the best option would be to remove the logic introduced in my earlier PR (#98) and introduce an option to specify what the "body" element should be for this tether. That way the element that it is warped to can be in the control of the user.
It would be the user's responsibility to determine that the element in question does have the exact same constraints as the body, and any element positioned in it would line up as if it were positioned relative to the body. This would just give users the ability to manage which element that is, exactly.
pzuraq commentedon Aug 29, 2016
I made #204 to implement my suggestion, comments welcome!
jrmyio commentedon Sep 29, 2016
You might want to add a way to support a string as the bodyElement.
pzuraq commentedon Sep 30, 2016
Good idea! If this PR gets sanctioned I'll do that
RobbieTheWagner commentedon Sep 18, 2019
I believe this is possible using the
bodyElementoption. We do probably need to document it, but we'll have to look through all the code and ensure we update docs soon anyway.