Skip to content
This repository has been archived by the owner on Nov 16, 2017. It is now read-only.

Extract rect position utility from BalloonPanelView #98

Closed
oleq opened this issue Oct 11, 2016 · 1 comment
Closed

Extract rect position utility from BalloonPanelView #98

oleq opened this issue Oct 11, 2016 · 1 comment

Comments

@oleq
Copy link
Member

oleq commented Oct 11, 2016

This chunk of code should be extracted and/or wrapped into a handy API and become a utility under ckeditor5-utils/src/dom.

The mentioned code is helpful to position elements in DOM using postion: absolute. For instance, if there are components in the "body" region of the editor, which are to be positioned with respect to another element, i.e. floating toolbar aligned to the editor, balloon aligned to the link in editable, tooltip aligned to the button in the toolbar, etc., this utility helps determining the absolute position (top and left in CSS) which should be set to achieve the desired composition.

It's not a trivial task because element.getBoundingClientRect returns a rect relative to the viewport, which is only useful when positioning with position: fixed. So to work with postion: absolute (relative to <body>), lots of things must be considered (like clientRect of <body>, scrolls of the window, etc.) to translate fixed–like position into absolute–like.

I see some pieces of code repeating in various places (StickyToolbarView, BalloonPanelView) and I think it's time to DRY.

@Reinmar
Copy link
Member

Reinmar commented Oct 11, 2016

Makes sense, of course, if this code is duplicated. I'm only unsure whether it better fits ckeditor5-utils/dom or ckeditir5-ui-default/utils. It's pretty specific for UI, isn't it? OTOH, I can see other using this and not the rest of our UI lib.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants