[wp-trac] [WordPress Trac] #33143: Twenty Fifteen uses jQuery window.width() - which is not synced with used media queries

WordPress Trac noreply at wordpress.org
Mon Jul 27 16:19:35 UTC 2015


#33143: Twenty Fifteen uses jQuery window.width() - which is not synced with used
media queries
--------------------------+-----------------------------
 Reporter:  th23          |      Owner:
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Themes        |    Version:  4.2.3
 Severity:  normal        |   Keywords:
  Focuses:  javascript    |
--------------------------+-----------------------------
 Hi there,

 while developing a child theme I came accross the point where I needed to
 use some JS elements depending on the screen size/ layout defined via CSS.

 Unfortunately the used JS and media queries in JS in Twenty Fifteen seem
 not be synced due to some browser differences handling $(window).width().

 For Firefox this JS excludes the scrollbar width, whereas the CSS media
 queries include this - resulting on no exact match.

 I would propose to add a differentiation based on the cross-browser usable
 {{{
 window.matchMedia("(min-width: 59.6875em)").matches
 }}}

 For all (recent) browsers this gives the appropriate result - and for
 downwards compatibility the approach using width() could still be
 utilized, if the above does not give a result/ fails!?

 Thanks for consideration!

--
Ticket URL: <https://core.trac.wordpress.org/ticket/33143>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list