Make WordPress Core

Opened 11 years ago

Closed 11 years ago

Last modified 11 years ago

#27220 closed defect (bug) (fixed)

Twenty Fourteen - masthead-fixed does not work on IE when using header image

Reported by: salsaturation's profile salsaturation Owned by: lancewillett's profile lancewillett
Milestone: 4.0 Priority: normal
Severity: normal Version: 3.8.1
Component: Bundled Theme Keywords: has-patch commit
Focuses: Cc:

Description

Twenty Fourteen adds the

masthead-fixed

class to the #masthead element when a user begins to scroll but in Internet Explorer this is not the case if the user is using header image functionality

In Chrome the html output is

<body class="home page page-id-701 page-template page-template-template-page-with-sidebar-php custom-background group-blog header-image full-width grid masthead-fixed">

but in IE you get

<body class="home page page-id-701 page-template page-template-template-page-with-sidebar-php custom-background group-blog header-image full-width grid">

Without the header image the masthead-fixed class is added when page loads so functions as expected

Attachments (4)

Ticket-27220-twentytwelve-sticky-menu-2.jpg (796.7 KB) - added by salsaturation 11 years ago.
Ticket-27220-twentytwelve-sticky-menu-1.jpg (1.1 MB) - added by salsaturation 11 years ago.
27220.diff (678 bytes) - added by Kau-Boy 11 years ago.
27220.2.diff (1.3 KB) - added by lancewillett 11 years ago.
Better use of JS variable, remove extra parens, bump JS file version

Download all attachments as: .zip

Change History (16)

#1 @lancewillett
11 years ago

  • Keywords reporter-feedback added

Hi, thanks for posting. Can you describe in more detail what the bug is? What behavior did you expect to happen?

Screenshots / screencasts to help illustrate would be very welcome.

#2 @salsaturation
11 years ago

  • Keywords reporter-feedback removed

Hi Lance

Firstly if you look at Twenty Fourteen without a header imnage will see that it behaves consistently on IE, Webkit, Chrome when user scrolls up the page the menu remains in view as the 'masthead-fixed' class is added to the body class on page load. Now the bug

1) Go to Appearances >> Header and add a header image... Notice as per Ticket-27220-twentytwelve-sticky-menu-1.png in this situation the 'masthead-fixed' class is NOT added to the body class on page load.

2) Open up a Webkit browser or Chrome. As you scroll past the header image notice the 'masthead-fixed' class is added to the body class (see. Ticket-27220-twentytwelve-sticky-menu-2.png) forcing the menu to stick to the top. This is the expected behaviour

3) Now fire up IE and and repeat step no 2. As you scroll past the header image 'masthead-fixed' class is NOT added to the body class (see. Ticket-27220-twentytwelve-sticky-menu-2.png), thus, the menu never sticks to the top of the page. This is incorrect behaviour

FYI Chrome on left and IE on right on both screenshots

Last edited 11 years ago by salsaturation (previous) (diff)

#3 @lancewillett
11 years ago

  • Keywords needs-patch added
  • Milestone changed from Awaiting Review to Future Release

#4 @celloexpressions
11 years ago

This is a duplicate of the part of #25144 that was basically wontfixed.

Known issue and probably solvable (see solution to #23841), although a decision was made at one point to ignore it. However, if someone patches it it would be cool to fix.

@Kau-Boy
11 years ago

#5 @Kau-Boy
11 years ago

  • Keywords has-patch added; needs-patch removed

The Bug is rather easy to fix. IE dos not support window.scrollY but as WP is using jQuery, just use $( window ).scrollTop() instead (or something like document.body.scrollTop which should also be cross-browser and probably a lot more efficient).

I've added a path with the jQuery variant fixing the bug. I hope to see this fixed in 3.9 or upcoming versions.

Here is some reference for compability: https://developer.mozilla.org/en-US/docs/Web/API/Window.scrollY
And here for performance: http://jsperf.com/jquery-el-scrolltop-vs-el-0-scrolltop/2

Last edited 11 years ago by Kau-Boy (previous) (diff)

#6 @lancewillett
11 years ago

Thanks for the patch, we'll look for after 3.9 as it's a bit too late now to make a change.

#7 @lancewillett
11 years ago

  • Keywords needs-testing added
  • Milestone changed from Future Release to 4.0

#8 @celloexpressions
11 years ago

  • Keywords needs-testing removed

Patch works for me in IE11 Desktop & Immersive on Windows 8.1, and doesn't break Chrome or Firefox.

#9 @obenland
11 years ago

  • Keywords commit added

#wchh14

Last edited 11 years ago by obenland (previous) (diff)

#10 @lancewillett
11 years ago

I don't think the patch is quite right. The $( window ) call should use the local variable that is instantiated at the top of the file.

Also, the version for the JS file needs to be bumped in the functions.php file.

@lancewillett
11 years ago

Better use of JS variable, remove extra parens, bump JS file version

#11 @lancewillett
11 years ago

  • Owner set to lancewillett
  • Resolution set to fixed
  • Status changed from new to closed

In 28758:

Twenty Fourteen: fix masthead behavior in IE when a custom header image is present. Props Kau-Boy, lancewillett. Fixes #27220.

#12 @Kau-Boy
11 years ago

You are right @lancewillett. If there is already a stored jQuery object for window, we should use this one (haven't seen it two month ago, when I was writing the patch). It would still be better to use the document native function, but I can live with the rather costly scrollTop() function. That's why my patch had it ;-)

Note: See TracTickets for help on using tickets.