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

Issues with ng-show/ng-hide #113

Open
lopsided opened this issue Oct 13, 2016 · 4 comments · May be fixed by #126
Open

Issues with ng-show/ng-hide #113

lopsided opened this issue Oct 13, 2016 · 4 comments · May be fixed by #126

Comments

@lopsided
Copy link
Contributor

Hi, firstly, great plugin, I love it.

I have an element that starts both off the page and hidden (ng-hidden). After some user interaction this is un-hidden and brought into view (other things on the page get hidden). However inview detects it as being "in-view" right from the start (or certainly from the first scroll, even when the hidden element is still far from the bottom of the viewport), so when it actually comes into view the event is not triggered.

I made a gist to give you the idea here: https://jsbin.com/yahovejexi/1/edit?html,js,output

Looking at the code I can fix this by changing lines 96-98 like so:

        var isVisible = !!(element[0].offsetWidth || element[0].offsetHeight || element[0].getClientRects().length);
        var info = {
          inView: isVisible && intersectRect(elementRect, viewportRect),

The new var isVisible uses the same code as jquery to check if an element is visible ($(el).is(':visible')). And then if not visible then inView always returns false.

This is exactly the behaviour I want, and I'm happy to PR it, but does this work for everyone else?

@lopsided
Copy link
Contributor Author

@joschne
Copy link

joschne commented Oct 26, 2016

Yes, this absolutely solved the problem also for me!

@thenikso
Copy link
Owner

thenikso commented Nov 17, 2016

cool! merged #116

@thenikso
Copy link
Owner

thenikso commented Nov 17, 2016

As per discussion in #119 merging PR #116 might have been premature.

Also in the jsbin above I think I could easily fix the problem by using ng-ifs instead of ng-show/ng-hide right? Why would one want to use the later over the former in those cases?

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 a pull request may close this issue.

3 participants