WordPress.org

Ready to get started?Download WordPress

Forums

Easy FancyBox
[resolved] Turn off fancybox for mobile (10 posts)

  1. leggo-my-eggo
    Member
    Posted 1 year ago #

    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/

  2. RavanH
    Member
    Plugin Author

    Posted 1 year ago #

    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 :)

  3. RavanH
    Member
    Plugin Author

    Posted 1 year ago #

    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');
    }
  4. leggo-my-eggo
    Member
    Posted 1 year ago #

    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.

  5. RavanH
    Member
    Plugin Author

    Posted 1 year ago #

    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 :)

  6. leggo-my-eggo
    Member
    Posted 1 year ago #

    @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?

  7. RavanH
    Member
    Plugin Author

    Posted 1 year ago #

    Then it needs to become

    ...
    jQuery(document).off('ready gform_post_render', easy_fancybox_handler);
    ...
  8. leggo-my-eggo
    Member
    Posted 1 year ago #

    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?

  9. RavanH
    Member
    Plugin Author

    Posted 1 year ago #

    yes :)

  10. officeninjas
    Member
    Posted 1 year ago #

    @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!

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags