Skip to content
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

Hint positioning both vertically and horizontally #26

Closed
matias-pool opened this issue Jun 14, 2018 · 6 comments
Closed

Hint positioning both vertically and horizontally #26

matias-pool opened this issue Jun 14, 2018 · 6 comments

Comments

@matias-pool
Copy link

matias-pool commented Jun 14, 2018

It would be great if it was possible to position the hint both vertically and horizontally, like position="topLeft" or horizontalPosition="left" verticalPosition="top" or similar.

switch (at) {

We extended the switch statement in getHintData to handle our particular use case, but this approach may not be practical as a general solution.

      case 'topLeft':
        top = 0;
        left = -hintWidth;
        break;

What would be your suggestion?

@slmgc
Copy link
Owner

slmgc commented Jun 14, 2018

Hi, that's a good idea, actually. I need to check how it's usually implemented. We can have a discussion here about the implementation details. I would prefer top-left to topLeft though. I am not sure if the tooltip should be positioned exactly at the edge of the element or should it be close to the edge. What do you think? What's your use-case? Can you append some screenshots?

@matias-pool
Copy link
Author

Our use case is a multilingual questionnaire where the user should be able to listen to an audio clip
for any label. We are using react-hint to wrap the audio player. Extending the case statement is the simplest way, but it adds many lines of code.

react-hint

@matias-pool
Copy link
Author

For a more dynamic approach maybe a "top-left".split('-') could be done, and then top and left would be set for every item.

In a pseudo code fashion I mean:

const positions = "top-left".split('-');

if (positions.includes('top')) {
  top = 0;
}

if (positions.includes('left')) {
  left = -hintWidth;
}

@matias-pool
Copy link
Author

I'm adding a patch to show how it could be done.

  • There is no sanity checking or error handling
  • A case 'center': left = 0 could be added for consistency
  • The other switch must do something similar at
    switch (at) {

@slmgc
Copy link
Owner

slmgc commented Aug 2, 2018

@matias-pool after a second thought, it doesn't seem to be a simple decision. I don't think there is a universal solution to align tooltips vertically + horizontally. For example, let's take "bottom-left", there are 3 possible implementations:

  1. The arrow is centered horizontally:

screen shot 2018-08-02 at 12 48 24 pm

  1. The arrow is at the edge of the tooltip:

screen shot 2018-08-02 at 12 49 54 pm

  1. Your proposal shifts the whole tooltip to the left by its width (in this case, the arrow should be probably hidden completelly):

screen shot 2018-08-02 at 1 15 04 pm

I don't think there could be a solution that fits everyone's needs and I don't want to include something which won't be useful for majority of users. Do you have thoughts on this?

@slmgc
Copy link
Owner

slmgc commented Aug 9, 2018

Closing this issue for now as there is no obvious solution which fits all cases.

@slmgc slmgc closed this as completed Aug 9, 2018
@slmgc slmgc added the v4 label Aug 21, 2019
@slmgc slmgc reopened this Aug 21, 2019
@slmgc slmgc added the wontfix label Aug 21, 2019
@slmgc slmgc removed the v4 label Oct 31, 2019
@slmgc slmgc closed this as completed Oct 31, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants