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

Logic exactly backwards? #11

Open
bigteejay opened this issue Mar 22, 2016 · 1 comment
Open

Logic exactly backwards? #11

bigteejay opened this issue Mar 22, 2016 · 1 comment

Comments

@bigteejay
Copy link

Isn't the logic for this line exactly backwards? Perhaps some of the other related checks too.

l + VISIBLE_PADDING > p.offsetWidth + p.scrollLeft ... return false;

...as l represents the el.offsetLeft and p is it's parent? For example, l in my code is about 950 (px), and p's left is around 600px.

In this case, the function isVisible should instead return true, affirming the checked el is visible given that el's left edge is a greater value (further to the right) than is the parent p (smaller value, closer to the left edge.)

I could understand if the function was isHidden. Am I missing something?

@bigteejay
Copy link
Author

It appears that this line specifically (the rest seem fine) is comparing apples and oranges (left edge of child vs overall width of parent) especially in light of what the comment seems to indicate...

//-- If the target element is to the right of the parent elm

We would expect child's left edge (el.offsetLeft + VISIBLE_PADDING) to be to the right of its parent's left edge (p.offsetLeft) regardless of parent's size (p.offsetWidth + p.scrollLeft) in order for it to be visible (at least for this first test.)

In which case, shouldn't it be...

l + VISIBLE_PADDING < p.offsetLeft ... return false

...to check if child's left edge is further left (smaller value) than the parent's left edge, and therefor return false ("not visible")?

@bigteejay bigteejay reopened this Jul 28, 2016
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

No branches or pull requests

1 participant