Git Product home page Git Product logo

Comments (6)

lukejacksonn avatar lukejacksonn commented on July 20, 2024

Humm.. have you managed to find out what is causing this?

from greedynav.

sktollman avatar sktollman commented on July 20, 2024

I haven't. (I also know very little about front-end development.) My guess was that check() isn't responding properly when it's called on document ready, but it is triggered when scrolling. I tried a few other document/window listeners but couldn't fix the problem.

from greedynav.

lukejacksonn avatar lukejacksonn commented on July 20, 2024

Weird.. I would have hope that at least, jQuery would normalize this kinda behavior across different browsers. the codepen example seems to work in the iOS emulator in dev tools.. have you tried it on your device? This would suggest if the lib is broke or your implementation.

from greedynav.

barsa-net avatar barsa-net commented on July 20, 2024

I have a similar issue, and since both of us use the same jekyll theme, it seems the issue it's influenced by minimal-mistakes theme
My guess is: there could be elements added by the theme that are not computed correctly by the script, I'll try to investigate further, but for some reason I can reproduce only on my phone, in dev tools everything seems to work seamlessy.

from greedynav.

barsa-net avatar barsa-net commented on July 20, 2024

Ok after some stress tests, it seems that in the following function

GreedyNav/greedynav.js

Lines 19 to 23 in 605f64f

$vlinks.children().outerWidth(function(i, w) {
totalSpace += w;
numOfItems += 1;
breakWidths.push(totalSpace);
});

w variable could get some smaller value than what is the real width of elements (in my case, 32 pixel less for every element in the menu)

Since the script start at $(document).ready I'm pretty sure that is caused by some "racing" between jQuery and CSS.

The only reliable fix I could so far is by replacing $(document).ready( with $(window).on("load", in

https://github.com/mmistakes/minimal-mistakes/blob/64a34ee5ae8a37e92b2051828627a957639d911e/assets/js/plugins/jquery.greedy-navigation.js#L7
Obviously that change comes with the downside of waiting everything being loaded...

It's far from being a clean fix, but unfortunately I'm not fluent enough in JS 😥
Since minimal-mistakes uses a different version of the file, I doubt the issue belongs here...

from greedynav.

erikw avatar erikw commented on July 20, 2024

I've been looking in to this a bit with the browser debugger and found that the outerWidth() reported on the navigation items are not always correct. In my case, the reported width on the first nav element is almost the full browser window width some times (but should be around a 100px only), which causes greedy-nav to hide all items in the overflow menu.

I've not been able to capture with the debugger the case in your screenshot that the element overflows, but I would believe it could be the same issue (I do get the same behavior as you on mobile browser with overflow as in the screenshot), that the reported with is not the actual.

Unfortunately the workaround $(window).on("load" does not make a difference for me.

from greedynav.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.