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

Changed Top Margin #9

Open
kaynenh opened this issue Nov 16, 2013 · 0 comments
Open

Changed Top Margin #9

kaynenh opened this issue Nov 16, 2013 · 0 comments

Comments

@kaynenh
Copy link

kaynenh commented Nov 16, 2013

Hi- nice plugin! It works well, but I noticed that if the top margin of the menu changes (ie something above the element in the DOM slides larger) the topMargin of the menu doesn't update accordingly, which can cause the menu to overlap elements above it. I believe the fix would be to check and see if the menu's initial y position has changed prior to this line:

if(vartop < varscroll + topMargin){

Maybe something like this (didn't test this):

var morePadding = 0;
//If the initial y position of the menu is now less than the y position of the menu
if (initial_y < current_y) {
  //give more padding to the margin before adding the isStuck class
  morePadding = current_y - initial_y;
}
if (vartop < varscroll + topMargin + morePadding) {

The only problem with the above approach is that it doesn't take into account the changing y position of the menu as you scroll down the page.

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

1 participant