• Resolved leggo-my-eggo

    (@leggo-my-eggo)


    What’s the easiest way to turn fancybox off on mobile platforms? I’ve got Modernizr installed, so I could do something like:

    if (Modernizr.touch){
       // method_to_disable_fancybox();
    }

    Not a perfect check, but good enough for my purposes. I just don’t know how to go about disabling the fancybox functionality.

    Or, is there a better way?

    http://wordpress.org/extend/plugins/easy-fancybox/

Viewing 9 replies - 1 through 9 (of 9 total)
  • With the current stable version, this is not possible.

    However, if you install the current development version, this migh work:

    if (Modernizr.touch){
      jQuery(document).unbind('ready');
    }

    Downside is that it will disable all javascript that is set to run un the ‘ready’ event.

    There will be a better solution in a future version but for now, it might suit your needs 🙂

    Or if you want to target all small screen devices (not only touch) or if you’re not using modernizr.js:

    if(window.screen.width < 500 || window.screen.height < 500) {
      jQuery(document).unbind('ready');
    }
    Thread Starter leggo-my-eggo

    (@leggo-my-eggo)

    Thanks for the answer. Unfortunately, neither of these work for me, because I have other jQuery elements set to run on the ready event, which I need to work on touch devices.

    Hi Leggo,

    I just submitted a new dev version (.10dev17) which should allow the use of a named handler to ‘unbind’ fancybox like this

    <script type="text/javascript">
    if(window.screen.width < 500 || window.screen.height < 500) {
      jQuery(document).off('ready', easy_fancybox_handler);
    }
    </script>

    (Are you using Gforms? Then you need to do the same for the ‘gform_post_render’ event)

    If you could delete your current install of Easy FancyBox and install the new dev version to test this, I’d be grateful for your feedback 🙂

    Thread Starter leggo-my-eggo

    (@leggo-my-eggo)

    @ravanh, wow, thank you, this is fantastic. I will test at my first opportunity, which is probably tomorrow, and let you know what I find.

    I am using Gravity Forms. Can you explain what you mean about the gform_post_render event? Do you mean that easy_fancybox fires on this event? Or that gforms itself will need to be disabled for mobile?

    Then it needs to become

    ...
    jQuery(document).off('ready gform_post_render', easy_fancybox_handler);
    ...

    Thread Starter leggo-my-eggo

    (@leggo-my-eggo)

    This seems to be working fine, thank you.

    And I’m intrigued by some of what I see in the dev version! Any chance fancybox 2 is coming?

    yes 🙂

    @ravanh
    Hello,
    Are the changes you made to be able to turn off fancybox in the latest version 1.3.4.9? Couldn’t find ‘easy_fancy_handler’? If not, are you planning on releasing a new version with this change soon?
    Thanks!

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘[Plugin: Easy FancyBox] Turn off fancybox for mobile’ is closed to new replies.