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

Problem with detecting if element is inView #35

Closed
karooolis opened this issue Sep 3, 2014 · 1 comment
Closed

Problem with detecting if element is inView #35

karooolis opened this issue Sep 3, 2014 · 1 comment

Comments

@karooolis
Copy link

On my website I have been experiencing a problem with the script where it doesn't detect correctly whether an element is in view or not. It's because some images on my website ( bredymer.dk/biler.aspx ) return ele.getBoundingClientRect().left value less than zero meaning that their left coordinate starts outside viewport. This has caused some of the images not to load and I fixed it by

I have fixed it by modifying

    function elementInView(ele) {
        var rect = ele.getBoundingClientRect();
        var bottomline = winHeight + options.offset;

        return (
         // inside horizontal view
         rect.left >= -20
         && rect.right <= winWidth + options.offset  
         && (
         // from top to bottom
         rect.top  >= 0
         && rect.top  <= bottomline
         // from bottom to top
         || rect.bottom <= bottomline
            && rect.bottom >= 0 - options.offset
            )
        );

        return inView;
     }

where I set rect.left >= -20 . This is not a universal solution and only helped fixed problem in my website. Perhaps there are some universal ways to solve it?

dinbror pushed a commit that referenced this issue Jan 23, 2015
@dinbror
Copy link
Owner

dinbror commented Jan 23, 2015

Fixed in version 1.3.0

@dinbror dinbror closed this as completed Jan 23, 2015
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

2 participants