Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Using the 'sidr' or 'meanmenu' styles at least, the issue persists. It's due to the presence of a vertical scroll bar, so the breakpoint is about 15px or so off (the width of the vertical scrollbar).
Here's the patch I used to fix 'sidr'.
Comment | File | Size | Author |
---|---|---|---|
#6 | responsive_menus-window-width.patch | 3.39 KB | lgerndt |
#4 | responsive_menus-window-width.patch | 2.4 KB | lgerndt |
Comments
Comment #1
perennial.sky CreditAttribution: perennial.sky commentedIn responsive_menus_simple.js
Change 132 line
In $(window).resize() function
remove this line -> windowWidth = window.innerWidth || document.documentElement.clientWidth || document.body.clientWidth;
Add this line -> windowWidth = $(window).width();
Comment #2
jwjoshuawalker CreditAttribution: jwjoshuawalker commentedSure, so what I was originally taking into account was this:
http://www.w3schools.com/js/js_window.asp?output=print
I had briefly tested some things using code like this page is doing:
http://ryanve.com/lab/dimensions/
So taking that into consideration, along with:
http://jsperf.com/jq-width-vs-client-width/5
(Run the test) Results:
-----------------------------
jQuery.width()
43,769 Ops/sec
±1.86%
100% slower
versus:
javascript native selector & .clientWidth
15,881,736 Ops/sec
±0.83%
fastest
-----------------------------
What I'll do is remove the window.innerWidth altogether and leave .clientWidth as the primary.
It's also mentioned on the page showing all the widths that $(window).width() uses the same .clientWidth, but the latter is faster (a lot faster):
"jQuery(window).width() uses document.documentElement.clientWidth and is regarded as cross-browser compatible. Directly using .clientWidth is faster and equally compatible. "
Comment #3
jwjoshuawalker CreditAttribution: jwjoshuawalker commentedResponsive Menus 1.4 is out.
This issue is resolved with new release.
https://drupal.org/node/2151023
Comment #4
lgerndt CreditAttribution: lgerndt commentedUsing the 'sidr' mode at least, the issue persists. It's due to the presence of a vertical scroll bar, so the breakpoint is about 15px or so off (the width of the vertical scrollbar).
Here's the patch I used to fix this.
Comment #5
lgerndt CreditAttribution: lgerndt commentedComment #6
lgerndt CreditAttribution: lgerndt commentedHere's the patch I used to fix 'meanmenu'. It patches
jquery.meanmenu.js
. Note that Drupal calls the minified one,jquery.meanmenu.min.js
, so you'll have to do the minification yourself and commit the new minified file.Comment #7
jwjoshuawalker CreditAttribution: jwjoshuawalker commented@lgerndt
Sorry, I meant to reply to the first patch you made. Have you tried with the -dev version of Responsive Menus?
It uses a different function which accounts for the vertical scroll bar (this was updated after the 1.5 release).
I need to do a 1.6 release but there are other things I want to get committed first.