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

  • Home
  • SEARCH
  • 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 702707
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:45:02+00:00 2026-05-14T03:45:02+00:00

Given the following jquery code.. jQuery.fn.sliding = function () { return this.each(function () {

  • 0

Given the following jquery code..

jQuery.fn.sliding = function () {

    return this.each(function () {

        $(this).bind('ON_CONTENT_CHANGING', function (e) {
            $(this).block({
                overlayCSS: { opacity: 1, color: '#000' },
                timeout: 800
            });
        });

        $(this).bind('ON_CONTENT_CHANGED', function (e) {
            $(this).sliding();
            $(this).unblock();
        });

        var $panels = $(this).find('.scrollContainer > div');
        var $container = $(this).find('.scrollContainer');
        var $resized = $panels.css({ 'width': $(this).width() - 44 });



        // if false, we'll float all the panels left and fix the width 
        // of the container
        var horizontal = true;

        // float the panels left if we're going horizontal
        if (horizontal) {
            $panels.css({
                'float': 'left',
                'position': 'relative' // IE fix to ensure overflow is hidden
            });

            // calculate a new width for the container (so it holds all panels)
            $container.css('width', $panels[0].offsetWidth * $panels.length);
        }

        // collect the scroll object, at the same time apply the hidden overflow
        // to remove the default scrollbars that will appear
        var $scroll = $(this).find('.scroll').css('overflow', 'hidden');

        // handle nav selection
        function selectNav() {
            $(this)
            .parents('ul:first')
                .find('a')
                    .removeClass('selected')
                .end()
            .end()
            .addClass('selected');
        }

        $(this).find('.navigation').find('a').click(selectNav);


        // go find the navigation link that has this target and select the nav
        function trigger(data) {
            var el = $(this).find('.navigation').find('a[href$="' + data.id + '"]').get(0);
            selectNav.call(el);
        }

        if (window.location.hash) {
            trigger({ id: window.location.hash.substr(1) });
        } else {
            $('ul.navigation a:first').click();
        }

        // offset is used to move to *exactly* the right place, since I'm using
        // padding on my example, I need to subtract the amount of padding to
        // the offset.  Try removing this to get a good idea of the effect
        var offset = parseInt((horizontal ? $container.css('paddingTop') : $container.css('paddingLeft')) || 0) * -1;


        var scrollOptions = {
            target: $scroll, // the element that has the overflow

            // can be a selector which will be relative to the target
            items: $panels,

            navigation: '.navigation a',

            // allow the scroll effect to run both directions
            axis: 'xy',

            onAfter: trigger, // our final callback

            offset: offset,

            // duration of the sliding effect
            duration: 500,

            // easing - can be used with the easing plugin: 
            // http://gsgd.co.uk/sandbox/jquery/easing/ 
            easing: 'swing'
        };

        $(this).serialScroll(scrollOptions);
        $.localScroll(scrollOptions);

        scrollOptions.duration = 1;
        $.localScroll.hash(scrollOptions);

    });
};

Then this is the actual html file…

    $('#toggle').toggle(function (e) {
        if ($("#sidebar:animated, #canvas:animated").length) {
            e.preventDefault();
            return;
        }

        $(".ui-sliding").trigger('ON_CONTENT_CHANGING');


        $('#sidebar').hide('slide', { direction: 'right' }, 100, function () {

            $('#canvas').switchClass('span-17', 'span-24', 100, function () {
                $(".ui-sliding").trigger('ON_CONTENT_CHANGED');
                $('#toggle').switchClass('close', 'open');
            });
        })
    },
            function (e) {
                if ($("#sidebar:animated, #canvas:animated").length) {
                    e.preventDefault();
                    return;
                }


                $(".ui-sliding").trigger('ON_CONTENT_CHANGING');

                $('#canvas').switchClass('span-24', 'span-17', 100, function () {
                    $('#sidebar').show('slide', { direction: 'right' }, 100, function () {
                        $(".ui-sliding").trigger('ON_CONTENT_CHANGED');
                        $('#toggle').switchClass('open', 'close');
                    });
                });
            });

Is there any way to prevent the toggle from being fired again if someone clicks while it is performing the function?

I referenced Tell jQuery to ignore clicks during an animation sequence and the technique did not work.

  • 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-05-14T03:45:02+00:00Added an answer on May 14, 2026 at 3:45 am

    You can do something like this, check if anything you animate is animating and cancel if so.

    Put this at the top of each toggle function:

    if($("#sidebar:animated, #canvas:animated").length) {
      e.preventDefault();
      return;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 405k
  • Answers 406k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer @Bill the WinExec function is deprecated, from MSDN Site this… May 15, 2026 at 6:00 am
  • Editorial Team
    Editorial Team added an answer When you create a gui with guide, for every button/textbox/graph… May 15, 2026 at 6:00 am
  • Editorial Team
    Editorial Team added an answer First, you need to call m_cpVoice->SetInterest(SPFEI(SPEI_VISEME), SPFEI(SPEI_VISEME)); that will tell… May 15, 2026 at 6:00 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.