Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8976683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T19:12:13+00:00 2026-06-15T19:12:13+00:00

I wrote a function that hides and toggle a top bar div: jQuery(document).ready(function($) {

  • 0

I wrote a function that hides and toggle a top bar div:

jQuery(document).ready(function($) {

        $.fn.myTopBar = function() {

                var sipPosTop = 0;
                var topDivHeight = $("#top").outerHeight();

                $('#top').css('top' , -topDivHeight+10).show().animate({top: '+=0'}, 2000);


                $("#top-toggle").click(function(e) {
                    e.preventDefault();
                    $("#top").animate({ top: sipPosTop }, 200, 'linear', function() {
                        if(sipPosTop == 0) { sipPosTop = -topDivHeight+10; }
                        else { sipPosTop = 0; }
                    });
                });
        };
});

Works nice on page load, but on window resize the #top div height changes and it breaks the layout. How can I recalculate it and re-run the function on window resize? I tried the following:

jQuery(document).ready(function($){
    $.fn.myTopBar();
});

jQuery(window).resize(function($){
    $.fn.myTopBar();
});

But does not work. Thanks for any help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T19:12:14+00:00Added an answer on June 15, 2026 at 7:12 pm

    Edit — Based upon your comments, I’ve written this plugin that (hopefully) will have the functionality that you are seeking. If anything, you may be able to extract some information on how to go about doing it.

    Call the plugin with this —

    $(function () {
        $('.someFlyoutContainerClass').flyout({
            flyButton : $('.someButtonClass'), // button that toggles the flyout
            topOffset : 50, // (px) offset from the top of the window
            fade : { // (fade speeds/durations) -- remove object if not needed
                inSpeed : 350,
                easingIn : 'swing', // by removing easing, it will default to linear
                outSpeed: 250,
                easingOut : 'swing'            
            },
            slide : { // (slide speeds/durations) -- remove object if not needed
                inSpeed : 350,
                easingIn : 'swing',
                outSpeed : 250,
                easingOut : 'swing'      
            },
            closeButton : $('.close-flyout'), // you may remove if not needed
            clickOffClose: true // click anywhere but modal/flyout to close it
        });
    });
    

    Here is a working version of the script — (updated 12/13)
    http://jsfiddle.net/jmsessink/fC8ht/5/

    I hope this helps and let me know if you have any questions.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i wrote a custom jquery function that accept a callback but not being able
I wrote a script that shows/hides a div depending on which checkbox is selected.
is this function that i wrote in jquery, will be a good way to
I wrote a function that scans a tab delimited file of baseball stats. public
So I wrote this function that is given possible numbers, and it has to
I wrote a simple function, that makes emacs add matching quotes (so when I
I've got a function I wrote quite some time ago that works fine, but
I have a C++ DLL that I wrote that has a single exposed function,
I wrote a function that gets the balance from PayPal. To connect properly I'm
I wrote a function in haskell that takes a few parameters like Word32, String

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.