PhotoSwipe icon indicating copy to clipboard operation
PhotoSwipe copied to clipboard

Bug in New Safari V 6.0.2 (8536.26.17) + V 6.0.3 (8536.28.10)

Open ghost opened this issue 13 years ago • 15 comments

Only occurs in the New Safari V 6.0.2 (8536.26.17) on Mac. Previous Safari version was OK.

When having an element in my page that was position: fixed, it creates more space above the image in photoswipe.

How to fix?

photoswipe-bug-safari-6_0_2

ghost avatar Jan 14 '13 15:01 ghost

I am having the same issue with a fixed scrollTop button which because the button is located in the lower section of the page sometimes the entire gallery image is hidden. When I resize the browser window the gallery image appears in the correct position. Any assistance is much appreciated. Thanks

mitchmccline avatar Feb 07 '13 23:02 mitchmccline

I Have the same problem has anyone solved this issue? Thanks in advance!!!

joeBlast avatar Mar 21 '13 08:03 joeBlast

Same problem here. Any update on this?

laszlo-horvath avatar Mar 27 '13 22:03 laszlo-horvath

The issue remains in Version 6.0.3 (8536.28.10)

mitchmccline avatar Mar 27 '13 23:03 mitchmccline

Well, I had a partially workaround: when clicking an image which you want to open Photoswipe for, you should let your browser scroll to the top.

ghost avatar Mar 28 '13 07:03 ghost

What do you mean by "let your browser"? Should I make the browser to scroll to top from script or what? Btw as you can see on your screenshot the browser already scrolled to top, didn't it? Sad thing for me, I don't have a Mac right now, only my friend told me that my protfolio website have this isssue..

laszlo-horvath avatar Mar 28 '13 09:03 laszlo-horvath

You need to scroll the page to the top: $('html, body').stop().animate({'scrollTop': 0}, 0); That should do the trick.

ghost avatar Mar 28 '13 10:03 ghost

// init photoswipe
var instance = $('#photoswipeElement').photoSwipe();

// on before show
$(instance).on(window.Code.PhotoSwipe.EventTypes.onBeforeShow, function(e)
{
    // scroll with 550 as speed
    scrollFix(550);
});

// Scroll fix, because photoswipe does some strange things in safari V 6.0.2
function scrollFix(speed)
{
    // get scroll element
    var scrollElement = 'html, body';

    // jump to top
    $(scrollElement).stop().animate({'scrollTop': 0}, speed);
};

That should do the trick.

ghost avatar Mar 28 '13 10:03 ghost

Awesome! :+1: I'm going to try this on my site and will get back to here, to tell you if it works! Thanks man!

laszlo-horvath avatar Mar 28 '13 11:03 laszlo-horvath

Hmm.. Good news! Your solution seems to be working! Scrolling to the top in the onBeforeShow function fixes the issue. Thanks a lot man! You should do a pull-request or something!

laszlo-horvath avatar Mar 28 '13 12:03 laszlo-horvath

I'm glad it helped you. It is not an all-covering solution, I also had a function for the "on hide" part. Where I wanted to scroll back to the original position I was on.

// on hide
$(instance).on(window.Code.PhotoSwipe.EventTypes.onHide, function(e)
{
    scrollFix(10);
});

Grtz Jeroen Desloovere

ghost avatar Mar 28 '13 12:03 ghost

Yeah, that's also a good idea to scroll back to the position where the page was. I imagine an option parameter for PhotoSwipe like "safariFix: true | false". If true, other two option parameters for scrolling speed are avalaible ("beforeShowScrollSpeed, hideScrollSpeed") and it would use your functions presented above. Good job!

laszlo-horvath avatar Mar 28 '13 14:03 laszlo-horvath

Thanks siesqo!

mitchmccline avatar Mar 28 '13 16:03 mitchmccline

@RynoRn : When will we set safariFix to true or false, for all safari versions?

ghost avatar Apr 10 '13 14:04 ghost

That is hard to define. It would need more testing to do but for me it was the exact same version you mentioned in the issue's title. It should be set for (major) version 6 maybe, but I'm not sure. As I tested your fix doesn't ruin anything for other browsers neither it should for other versions of Safari.

laszlo-horvath avatar Apr 10 '13 15:04 laszlo-horvath