Here’s the deal - I created a “sticky” menu as part of this website. It works great, but on this one page with the YouTube vids, Safari has problems with it staying fixed. Firefox and Chrome work great, just not Safari. Any ideas why not?
It’s a really small script, you can see it in the head but here is the git of it (I think):
The goal was to change the nav from a relative to fixed position just as it scrolls to the top of the window. Early experiments had exposed an animation stutter when this happened, so now the script targets an empty div (id="sticky-anchor") inline just before the nav (id="sticky-nav") so really pretty simple.
with comments in the script on what to do if you have called jquery
directly.
It uses onscroll to do the job. The #sticky-anchor div provides an offset
reference so we can compare with and know if users scroll down far enough.
If so, then #sticky-nav would be applied with a CSS class which fixes the
position to the page top. If not, then it removes the CSS class so it can
revert to the relative position it had when the page loaded.
Works perfectly on every page with no issue. Just this one with the
embedded videos - and then only in Safari.
–
Ernie Simpson
On Sun, Jan 27, 2013 at 5:14 AM, DeltaDave email@hidden wrote:
Yes I saw that but couldn’t see the jquery call or where the parameters
were being set.
That is why I was curious about where it came from so that I could look at
the blurb/docs for it.
Cool. If I remove the embedded youtube vids, then functionality works fine
in Safari (remember, FF and Chrome don’t have any issue on this one page).
So it is only Safari, only this one page with YouTube embeds.
Safari is used by the majority of mobile browsers, but only about 6% of
desktop users - so since this page is not really that tall and the
advantage of having the vids there instead of as links away from the site
makes me think that this problem is worth tolerating.
–
Ernie Simpson
On Sun, Jan 27, 2013 at 10:38 AM, DeltaDave email@hidden wrote:
JQuery is being called via Google’s Ajax library, here:
with comments in the script on what to do if you have called jquery
directly.
Yes I see - I wasn’t familiar with that javascript call.
I had noted the qualifiers in the script and wasn’t sure (still not) if it
was implemented correctly.
No obvious js errors on the page - just trying to rule out things.
The Sticker action would not be the solution here for two reasons:
I need the nav to stick ONLY when it reaches the top of the window. In
other words, it must scroll with the page only until it reaches the window
top, then scroll no more until the user scrolls back up again.
The Sticker action only works on layered html items. This is an inline
construction and therefore not compatible with Sticker.
–
Ernie Simpson
On Sun, Jan 27, 2013 at 2:26 PM, DeltaDave email@hidden wrote:
As a matter of interest did you try Walter’s Sticker action - does pretty
much the same thing.
Actually, by using Safari’s ‘Inspect Element’ feature you can see how the
code changes before and after the scroll triggers in either example. In the
Action example a top and left attribute are added.
Oh, I just looked, and yes that error is still in there. Your element must be a DIV, set with the CSS checkbox or Layer checkbox checked. That error is popped if the element isn’t found by line 325, which is looking specifically for a DIV. If you are using my HTML5 Actions, you might be trying to apply it to a section or article, and that could be the entire problem.
Walter
On Jan 28, 2013, at 10:09 AM, Ernie Simpson wrote:
Sorry Walter, when I tried it it gave me an error containing this line of
code
fwError('Sorry! This Action must be applied to a layered HTML box');
–
Ernie Simpson
On Mon, Jan 28, 2013 at 9:07 AM, Walter Lee Davis email@hiddenwrote:
Just tested it here, and no, it does not require a layered element.
Walter
On Jan 27, 2013, at 6:16 PM, DeltaDave wrote:
Yes you are correct - Sticker requires CSS positioned layered elements
but it does the ‘only stick when at the top’ thing.
That fixes the element relative to the window when the browser is resized. It’s a belt-and-braces approach to fix the issue of resizing causing the element in a centered layout to truly remain static rather than moving along with the content in the window.
Walter
On Jan 28, 2013, at 10:20 AM, Ernie Simpson wrote:
Actually, by using Safari’s ‘Inspect Element’ feature you can see how the
code changes before and after the scroll triggers in either example. In the
Action example a top and left attribute are added.