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

Improved isVisible logic & readability. #230 #238

Merged
merged 3 commits into from
Dec 31, 2017

Conversation

sapierens
Copy link
Collaborator

@sapierens sapierens commented Dec 6, 2017

Hey, I have corrected the issue that was described in #230.

I also introduced a very simple Rect class, which in my opinion greatly improves the readability and simplicity of the isVisible function.
After some performance tests, the Rect implementation turned out to be slightly faster than the current one. ~1.54% faster on Chrome and ~20.75% faster on Firefox, tested with 10,000,000 iterations averaged over 3 runs.

The only "problem" with this implementation is that the onLoad event example page is not functioning anymore.
This happens because the example is flawed. It's because getBoundingClientRect returns 0 sized rectangle, if the element is hidden. So I don't think it's a problem with my implementation at all.
I will open a separate issue regarding the flawed implementation.
EDIT: The example is not a problem anymore with #240.

Copy link
Owner

@tjoskar tjoskar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow, great improvement! Thanks!


it('Should be vissible when only left side with no corners is in the viewport', () => {
const element = generateElement(-100, 500, 1200, 1200);
debugger;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All these debug statement should be removed. I know, it was me how added them and I'm ashamed.
(You do not have to do anything, I will clean up my mess)

@tjoskar tjoskar merged commit 606faad into tjoskar:master Dec 31, 2017
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.

None yet

2 participants