-
Notifications
You must be signed in to change notification settings - Fork 13
Implement Geometry Module #8
Comments
WIP on https://github.com/kfranqueiro/dom/commits/geometry, currently with basic support + tests for the get APIs. Dojo 1's |
The
For example, if FWIW, Dojo 1 did not take the |
Paul has put a bunch of effort into the The problem is, outside of Dijit in Dojo 1.x, we can't really come up with any significant use cases for these APIs (either Moreover, there are a few loose ends / gray hairs with these APIs:
Ultimately, without convincing use cases at this point, it doesn't seem worth opening these cans of worms. I could fathom simplifying the I'd welcome comments from anyone who has had real use cases for these APIs in the past, to help figure out whether there's a convincing need for them in Dojo 2. |
The enterprise application I work on uses the "get" APIs in many situations to do various calculations for advanced layouts, dialog sizing, drag-fill editing popups for tables, and splitting up page content for printing. Unless there is a better way to get at this information, I would definitely appreciate the APIs existing in Dojo 2. We do not use the "set" APIs. Maybe CSS could be better used to solve some of these use cases, but don't think so for all. Migrating to Dojo 2 (if we choose to do so) would be that much easier if they were included. |
@rmaccracken are any of the get API calls you are making things that wouldn't be solved with getBoundingClientRect ( https://developer.mozilla.org/en-US/docs/Web/API/Element/getBoundingClientRect ) ? |
Adding on to Dylan's question, I'd be curious which |
I assume were are not talking about putting dom-geometry.position() on hold, only the set/get API, right? |
Initially we were thinking of including left/top/right/bottom information in each of the |
Ok, thank you for the clarification. |
@kfranqueiro We use getContentBox, getMarginBox, and position (with and without includeScroll). And we do use both the dimension and position properties. As far as the box model, we use the default (content-box). However, in terms of an API, I think I would rather have a function to get the box based on box-sizing rather than what getContentBox does (the comments say it ignores the box model). @dylans We have always used the geometry APIs rather than getBoundingClientRect, so I don't have any experience with it and can't really say if it can easily replace either getContentBox or getMarginBox. From what is said above, it does look like it could partially replace position. But looking at the getContentBox and getMarginBox source code which does not use getBoundingClientRect, I can't say without testing. From the getBoundingClientRect documentation, it does sounds like it could replace our uses of getContentBox, but I don't think that is the case for getMarginBox. |
What you mentioned about getting the box based on the effective value of |
@rmaccracken: out of curiosity, can you describe the sorts of use cases you have for using the various functions? That's what I've been the most curious about overall. The only cases I've really seen lately are for unit tests. |
@kfranqueiro I mentioned some of the use cases above, but I can go into a bit more detail on our main use case. Our product offers mainly 3 view types (layouts) that are used throughout - grid, gallery (something like google images), and property (shows images/properties belonging to single object). In addition, we have composite views that combine any number of these views together into a larger view. These views all have various options that affect how they are displayed. Some of these options cannot be satisfied by CSS, and so Javascript takes over to arrange the content as desired. Some of those calculations require these geometry functions to get the optimal layout and make sure everything lines up. In addition, we have the requirement that all of these views need to be printable, so that the content adapts to the chosen paper size/orientation and is split across pages so as to not crop content or span pages in an undesirable way. The code we use to split the content uses the geometry functions as well. There are various other places as well that use the functions, such as for dialog positioning, drag-fill editing as in Excel, and the list goes on. If our app has at least 10 different use cases for them, then I would think others have them as well. Our code base has been around for a while, so we may be able to take another look at these use cases and find ways to simplify or remove their use (through CSS or otherwise), but I highly doubt we could get rid of all cases. |
I'm definitely intrigued by the "Some of these options cannot be satisfied by CSS" statement. I would expect that dialog, tab container, and border container layouts should generally be achievable via CSS at this point using either position-related styles or flex-box. The one potential exception I can fathom would be anything intended to be draggable/resizable, which would still need JS. The print arguments may be valid, though I wonder whether The thing that makes the |
I'll just say that we currently use those functions, and unless we refactor/redesign all the various places we use them (if even possible), then we will need to recreate them. If they are not in Dojo 2, we will just have to add them to our own codebase. I would of course rather have them in Dojo though. We don't need the "set" functions, so if you are considering dropping these functions just because of those, then I would say just drop the "set" functions and keep the "get" functions. Anyways, I've added my 2 cents and I'll just wait and see what you decide and go from there. |
This is useful feedback, thanks. I think we're still more on the fence about the Dojo 2 is our first chance in roughly a decade to clean house and not be chained down by backwards compatibility, which is why I'm trying to nail down as much concrete information as possible on use cases that can't already be fulfilled natively. It's easier to add APIs later, whereas dropping things would ostensibly need to wait for another major version bump, hence the attempt to avoid unnecessarily increasing the API surface of 2.0 immediately out of the starting gate. |
I'd been thinking about this a couple of days ago and figured I would lay out a few options in terms of how far the The following list goes from least effort to most:
If you have opinions on what level of support your application needs, feel free to chime in. Personally I'd prefer to stay away from 4 if possible (if you need the level of support that Dojo 1's dom-geometry would give you with that flag, all you need to do is subtract |
Implement the following, along with associated unit tests:
get
APIsThe getter implementations would likely begin with
getBoundingClientRect
(which reports border-box) and build up from there. Dojo 1 does not implement all of these APIs, but it seems more consistent to do so.dom Proposal Reference
(Note there is an open question in the Rationales section regarding inclusion of a flag controlling behavior related to page scroll. It ought to be feasible to leave that out initially and add common logic to adjust for it in the future.)
The text was updated successfully, but these errors were encountered: