Giter Site home page Giter Site logo

Comments (18)

 avatar commented on August 16, 2024

Hi,

latest fancyBox version 2.1.2 and turbolinks are working fine. Unfortunately fancyBox from version 2.0 is not free for commercial use anymore.

I'm closing the issue as probably the problem is on the fancyBox side...

from turbolinks-classic.

Rosey avatar Rosey commented on August 16, 2024

For those wondering how to get fancybox 1.3.4 working with turbolinks (because I didn't want to update my fancybox.) :

Call $.fancybox.init() on page:change

Update this line in the fancybox js file (function is _start, approx. line 76 on the non minified version):

selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));

to

currentOpts = selectedOpts = $.extend({}, $.fn.fancybox.defaults, (typeof $(obj).data('fancybox') == 'undefined' ? selectedOpts : $(obj).data('fancybox')));

This seemed to fix all my problems :)

from turbolinks-classic.

jd-erreape avatar jd-erreape commented on August 16, 2024

I've been able to use it without changing the fancybox.js file. Only with:

$(window).bind('page:change', function() {
    $.fancybox.init();
});

Thanks R-osey! :)

from turbolinks-classic.

 avatar commented on August 16, 2024

Cool!

Thanks for your help @jd-erreape and @R-osey!

Marek

from turbolinks-classic.

antpaw avatar antpaw commented on August 16, 2024

It doesnt work for me (v. 2.1.5)

i made this hack to make it work

// turbolinks vs fancybox bug
$galleryHolder = $('<div id="gallery_holder"></div>').appendTo(document.body);
$('.gallery').fancybox({
    parent: $galleryHolder,
    openEffect: 'none',
    closeEffect: 'none'
});

I guess something is cached wrong inside fancyBox.

from turbolinks-classic.

allaire avatar allaire commented on August 16, 2024

@antpaw thank you for this, I had this issue on iOS only, your code fixed it! Did you had the problem also on desktop or mobile only like me?

from turbolinks-classic.

allaire avatar allaire commented on August 16, 2024

@antpaw any idea why the parent attribute fix it?

from turbolinks-classic.

antpaw avatar antpaw commented on August 16, 2024

@allaire i think the part where the "parent" elem is cached in the fancyBox is broken because they dont let go of it after it was removed from the dom, pretty sure this is not a turbolink issue

from turbolinks-classic.

allaire avatar allaire commented on August 16, 2024

@antpaw Thanks for the additional info. It's still weird tho, since the parent is not truly the parent of the lightbox stack in the DOM (see https://cloudup.com/cBATDstodGb)

from turbolinks-classic.

antpaw avatar antpaw commented on August 16, 2024

@allaire no i think thats okay, the holder contains only the big images that you see when you click on the thumbs, im sure this element will get some children once you click

from turbolinks-classic.

allaire avatar allaire commented on August 16, 2024

@antpaw nothing change when I click, the container does not get any child elements, but I guess that's ok, as long as it fixes the issue :)

from turbolinks-classic.

joselo avatar joselo commented on August 16, 2024

@antpaw it works for me, thanks

from turbolinks-classic.

alpracka avatar alpracka commented on August 16, 2024

@antpaw thank you too. This problem is still relevant for v2.1.5 as it's the latest version.

from turbolinks-classic.

antpaw avatar antpaw commented on August 16, 2024

it still has some bugs after the popstate event (whenever you use the back button) :(
hope they stop caching $('body') soon

from turbolinks-classic.

tomasmuller avatar tomasmuller commented on August 16, 2024

Thank you @jd-erreape!

from turbolinks-classic.

henev avatar henev commented on August 16, 2024

Thank you @antpaw.

Working fine for me. I am using fancybox version 2.1.5

But I suggest you to use:

// turbolinks vs fancybox bug
var $galleryHolder = $('#gallery_holder');

if ($galleryHolder.length === 0) {
    $galleryHolder = $('<div id="gallery_holder"></div>').appendTo(document.body);
}

$('.gallery').fancybox({
    parent: $galleryHolder,
    openEffect: 'none',
    closeEffect: 'none'
});

from turbolinks-classic.

sheharyarn avatar sheharyarn commented on August 16, 2024

The solutions mentioned by @iceless58 and @antpaw not working for me.

Using Fancybox2-Rails (Fancybox 2.1.5) with Ruby 2.2.0, Rails 4.2.0 and Turbolinks 2.5.3. (cc: @Kyparn)

from turbolinks-classic.

benbonnet avatar benbonnet commented on August 16, 2024

This won"t work when using it programatically with $.fancybox.open

from turbolinks-classic.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.