WordPress.org

Ready to get started?Download WordPress

Forums

Sticky Element
[resolved] Page Refreshing (8 posts)

  1. chaochipp
    Member
    Posted 1 year ago #

    Hi, this plugin is great but may I ask about this code

    $(window).resize(function() {
          clearTimeout(this.id);
          this.id = setTimeout(doneResizing, 500);
      });
      function doneResizing(){
        if ($(window).width() != winwidth) {
          window.location.reload();
        }
      };

    This conflicts with other plugins on my page and make the page reloaded every 5s. Could you change this to use other codes more intuitive?

    http://wordpress.org/plugins/sticky-element/

  2. Youdaman
    Member
    Plugin Author

    Posted 1 year ago #

    Hi chaochipp, thanks for pointing this out. It shouldn't reload the page every 5 seconds, it should only reload it once, and only after a user resizes the browser.

    I'm not sure how to fix the problem you're having but if you could tell me what other plugins it is conflicting with maybe I can help identify why your page is refreshing every 5 seconds.

  3. calebweeks
    Member
    Posted 1 year ago #

    Hi Youdaman,

    Thank you for this awesome bit of code in plugin form!

    I have a quick question to piggy-back on chaochipp's subject line above: "Would there be a way to not have the page refresh upon resize in general?"

    You know more than I on how all this works but I'll explain a little.

    We are in development for a "floating" sticky navigation, and building it 100% on your plugin. The inspiration for it comes from the worldwildlife.org sticky nav which can be seen, for instance, here: worldwildlife.org/threats/bycatch. As the visitor scrolls down the page, the second navigation sticks to the top and joins them on their scroll.

    However they pulled it off, the page does not refresh upon resize and I would be curious if this is possible/could be made possible somehow with the Sticky Elements plugin.

    I don't expect your kind, free work to investigate too much. Just wondering if there is something we can do with the plugin to imitate that resizing effect where the Page doesn't reload every time.

    I also realize the refresh probably has something to do with whether to even show the sticky element or not so it checks the browser window size on each call.

    Thanks again for offering your replies here on this forum, and for the plugin! We are happy either way, whether it's possible or not :-)

  4. Youdaman
    Member
    Plugin Author

    Posted 11 months ago #

    You could add:

    jQuery(window).off("resize");

    just before the closing body tag in your footer.php -- see http://stackoverflow.com/a/13268437 for a more elaborate example.

  5. calebweeks
    Member
    Posted 10 months ago #

    Hi Youdaman - thanks for writing back!

    I pasted what you had above into the footer.php file but wondered what tag to put it in/any code before it, etc.

    Would you be able/willing to write once more and let me know if there are any opening/closing tags needed? I realize this is probably an elementary task but I couldn't seem to get the result and I wasn't able to find documentation for it elsewhere.

    If you have the time/a moment and know what's needed (if anything) I would be grateful and ready to give it a go.

    Thanks again for your reply above!

    PS I did read the StackOverflow article but am afraid I may still be a little lost/unsure when it comes to jquery as I couldn't seem to achieve the result. Thanks again for the plugin and your time answering our questions here. It is appreciated. :-)

  6. Youdaman
    Member
    Plugin Author

    Posted 10 months ago #

    Sorry for the late reply.

    You could add the following before the </body> (end body) tag:

    <script>
    jQuery(document).ready(function(){
        jQuery(window).off("resize");
    });
    </script>
  7. calebweeks
    Member
    Posted 10 months ago #

    Thanks, Youdaman – that worked!

    I'm not sure that others would benefit from this "option" but I do appreciate you taking the time to support us in this way.

    Thanks again!

  8. Youdaman
    Member
    Plugin Author

    Posted 9 months ago #

    No worries :)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.