Skip to content
This repository has been archived by the owner on Feb 18, 2020. It is now read-only.

Best way to handle window.scroll? #72

Open
westwick opened this issue Feb 14, 2014 · 4 comments
Open

Best way to handle window.scroll? #72

westwick opened this issue Feb 14, 2014 · 4 comments

Comments

@westwick
Copy link

I have this small function working fine:

$(window).scroll(function() {
    console.log($(window).scrollTop());
  })

... but as soon as I call jPM.on(), it no longer works. Is this because it's placing all the page content inside the jPanelMenu-panel class, and the window is no longer scrolling but rather just the content inside the jPanelMenu-panel class? If so, what is the best to handle/detect how far down a user has scrolled? It seems I can't use $('.jPanelMenu-panel).scroll(...) or .scrollTop(), etc.

@westwick
Copy link
Author

After some more google searching I found this: http://stackoverflow.com/questions/21592433/jpanelmenu-and-scrolling-not-working-together

I altered the setjPanelMenuStyles function to change the overflow-x to visible and it indeed solved my problem. However I'm not 100% what all this could be affecting and I assume there is a reason it is being set this way, even though it seems to function perfectly without it. Any thoughts?

As a side note, I also had problems with my fixed position elements being screwed up after calling jPM.on(), and by simply commenting out the entire checkFixedChildren function, I no longer have the problem and the functionality is still there for me. Would love to hear any thoughts on that as well!

@thisisjamessmith
Copy link

Without overflow-x:hidden you'll get a horizontal scrollbar on your mobile layout when the nav is open surely?

@westwick
Copy link
Author

You are right, don't know how I didn't notice that.

@thisisjamessmith
Copy link

The real problem is complex, summarised here: http://www.brunildo.org/test/Overflowxy2.html ... Basically using different values of overflow-x and overflow-y can have unexpected results. I've hacked around this just now by adding body{overflow-x:visible!important} - this leaves the jPanelMenu's overflow-x:hidden style intact.

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

No branches or pull requests

2 participants