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

label/arrow position when data towards bottom #85

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

alfred-c
Copy link

RE: Issue #9 Arrows and description not displaying in correct position
If data is towards the bottom of the screen, label should be on top, but existing code would cause label and arrow to overlap.
To fix, I removed the following offending lines and cleaned up unused variables:

if (top_offset < label_shift_with_label_height && bottom_offset < label_shift_with_label_height) {
     label_y = data.center_y + label_margin;
}

Not sure why this was added. Please review this section as it looks like the result of a bad merge.

RE: Issue xbsoftware#9 Arrows and description not displaying in correct position
If data is towards the bottom of the screen, label should be on top, but existing code would cause label and arrow to overlap.
To fix, I removed the following offending lines and cleaned up unused variables:
if (top_offset < label_shift_with_label_height && bottom_offset < label_shift_with_label_height) {
     label_y = data.center_y + label_margin;
}
Not sure why these lines were needed.  Please review this section as it looks like the result of a bad merge.
@zapper59
Copy link

Hi, I'm working on merging bug fixes into https://github.com/darron1217/enjoyhint.js
I just tried this bug fix on that fork and it does not seem to fix the issue.
image

@alfred-c
Copy link
Author

alfred-c commented Jun 19, 2018 via email

@zapper59
Copy link

Didn't make that clear, I get the same behavior applying the bug fix to either branch. The js file in the root is auto generated by grunt. Take a look at the json file.

@arkauss83
Copy link

arkauss83 commented Jun 30, 2018

Hi, I found a couple of bugs related with this issue.

In one hand, I found out that the following code in renderLabel function was buggy:
var label_w = label.width();
var label_h = label.height();
var label_left = label.offset().left;
var label_right = label.offset().left + label_w;
var label_top = label.offset().top - $(document).scrollTop();
var label_bottom = label.offset().top + label_h;
So, basing on how is calculated label_top, I replaced label_bottom calculation with this:
var label_bottom = label.offset().top - $(document).scrollTop() + label_h;

In the other hand, these variables were calculated wrongly as well:
var is_top = (label_data.bottom < shape_data.top);
var is_bottom = (label_data.top > shape_data.bottom);
var is_mid = (label_data.bottom >= shape_data.y && label_data.top <= shape_data.y);
var is_mid_top = (label_data.bottom <= shape_data.y && !is_top);
var is_mid_bottom = (label_data.top >= shape_data.y && !is_bottom);
So I replaced the code with this:
var is_top = ((label_data.top + label_height) < shape_data.top);
var is_bottom = (label_data.top > shape_data.bottom);
var is_mid = ((label_data.top + label_height) >= shape_data.y && label_data.top <= shape_data.y);
var is_mid_top = (label_data.top + label_height <= shape_data.y && !is_top);
var is_mid_bottom = (label_data.top >= shape_data.y && !is_bottom);

After this, any scenario in my app when both the label and arrow are rendered above the highlighted canvas worked fine.
Hope it helps!

@rdorazio
Copy link

rdorazio commented Sep 2, 2018

arkauss83,
I had a problem with the arrow. With your code I was able to solve the problem.
Thank you

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

Successfully merging this pull request may close these issues.

4 participants