-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[🚀 ESL Popup] add position-origin attribute #2747
Merged
+76
−22
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
6be5133
feat(esl-popup): add position-origin attribute
dshovchko 2d7dc2e
chore(site): update esl-popup game with position-origin attribute
dshovchko 353a59f
docs(esl-popup): update README with position-origin attibute
dshovchko 638aac8
style(esl-popup): apply suggestions from code review
dshovchko File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,14 +12,16 @@ import {calcPopupPosition, isOnHorizontalAxis} from './esl-popup-position'; | |
import {ESLPopupPlaceholder} from './esl-popup-placeholder'; | ||
|
||
import type {ESLToggleableActionParams} from '../../esl-toggleable/core'; | ||
import type {PositionType, IntersectionRatioRect} from './esl-popup-position'; | ||
import type {PositionType, PositionOriginType, IntersectionRatioRect} from './esl-popup-position'; | ||
|
||
const INTERSECTION_LIMIT_FOR_ADJACENT_AXIS = 0.7; | ||
const DEFAULT_OFFSET_ARROW = 50; | ||
|
||
export interface ESLPopupActionParams extends ESLToggleableActionParams { | ||
/** popup position relative to trigger */ | ||
position?: PositionType; | ||
/** clarification of the popup position, whether it should start on the outside of trigger or the inside of trigger */ | ||
positionOrigin?: PositionOriginType; | ||
/** popup behavior if it does not fit in the window */ | ||
behavior?: string; | ||
/** Disable hiding the popup depending on the visibility of the activator */ | ||
|
@@ -74,6 +76,9 @@ export class ESLPopup extends ESLToggleable { | |
*/ | ||
@attr({defaultValue: 'top'}) public position: PositionType; | ||
|
||
/** From which side of the trigger starts the positioning of the popup: 'inner', 'outer' ('outer' by default) */ | ||
@attr({defaultValue: 'outer'}) public positionOrigin: PositionOriginType; | ||
|
||
/** Popup behavior if it does not fit in the window ('fit' by default) */ | ||
@attr({defaultValue: 'fit'}) public behavior: string; | ||
|
||
|
@@ -202,6 +207,7 @@ export class ESLPopup extends ESLToggleable { | |
// TODO: change flow to use merged params unless attribute state is used in CSS | ||
Object.assign(this, copyDefinedKeys({ | ||
position: params.position, | ||
positionOrigin: params.positionOrigin, | ||
behavior: params.behavior, | ||
container: params.container, | ||
marginArrow: params.marginArrow, | ||
|
@@ -401,10 +407,11 @@ export class ESLPopup extends ESLToggleable { | |
const triggerRect = Rect.from(this.activator).shift(window.scrollX, window.scrollY); | ||
const {containerRect} = this; | ||
|
||
const innerMargin = this._offsetTrigger + arrowRect.width / 2; | ||
const innerMargin = this._offsetTrigger + (this.positionOrigin === 'inner' ? 0 : arrowRect.width / 2); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need? Practically there is no limitation to have arrow for inner behaviour There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a limitation. This is just a position adjustment. |
||
|
||
const config = { | ||
position: this.position, | ||
hasInnerOrigin: this.positionOrigin === 'inner', | ||
behavior: this.behavior, | ||
marginArrow: this.marginArrow, | ||
offsetArrowRatio: this.offsetArrowRatio, | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: probably we can use
left
/right
key and some generic function for invertion in future