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 6044597
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:01:47+00:00 2026-05-23T07:01:47+00:00

switch (options.effect) { case ‘h-blinds-fadein’: $(‘.child’).each(function(i) { $(this).stop().css({ opacity: 0 }).delay(100 * i).animate({ ‘opacity’:

  • 0
switch (options.effect) {

case 'h-blinds-fadein':
    $('.child').each(function(i) {
        $(this).stop().css({
            opacity: 0
        }).delay(100 * i).animate({
            'opacity': 1
        }, {
            duration: options.speed,
            complete: (i !== r * c - 1) ||
            function() {
                $(this).parent().replaceWith(prev);
                options.cp.bind('click', {
                    effect: options.effect
                }, options.ch);
            }
        });
    });

    break;

case 'h-blinds-fadein-reverse':
    $('.child').each(function(i) {
        $(this).stop().css({
            opacity: 0
        }).delay(100 * (r * c - i)).animate({
            'opacity': 1
        }, {
            duration: options.speed,
            complete: (i !== 0) ||
            function() {
                $(this).parent().replaceWith(prev);
                options.cp.bind('click', {
                    effect: options.effect
                }, options.ch);
            }
        });
    });

    break;

    ....more cases
}

I have alot of similiar other cases. One way i could think of is to write functions ? i’m not sure i’m still fairly new to the language

im sorry, i is the index of the each() function which is the size of $(‘.child’), and r and c are just the ‘rows’ and ‘columns’ of the grid which contains ‘.child’.
r and c can be any number, e.g. r=5 c=5

  • 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-23T07:01:48+00:00Added an answer on May 23, 2026 at 7:01 am

    Rather then using a switch, store the case specific data in a hash.

    Then run the main block of code and extract anything effect type specific from the hash.

    function doit(e) {
        var hash = {
            'h-blinds-fadein': {
                delay: function(i) { return i; },
                complete: function(i) { return (i !== r * c - 1); }
            },
            'h-blinds-fadein-reverse': {
                delay: function(i) { return (r * c - i); },
                complete: function(i) { return i !== 0; }
            }
        }
    
        $('.child').each(function(i) {
            $(this).stop().css({
                opacity: 0
            }).delay(100 * hash[e].delay(i)).animate({
                'opacity': 1
            }, {
                duration: options.speed,
                complete: hash[e].complete(i) ||
                function() {
                    $(this).parent().replaceWith(prev);
                    options.cp.bind('click', {
                        effect: options.effect
                    }, options.ch);
                }
            });
        });
    }
    
    doit(options.effect);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a shell script with a switch case and takes in options
Switch statements are typically faster than equivalent if-else-if statements (as e.g. descibed in this
the -w and -W options of vim have theoretically the following effect: -w {scriptout}
I am using an enum as my options for a switch statement and it
I have an Options Menu on my Activity with an MenuItem Start. When this
So I followed this thread: RootViewController Switch Transition Animation to transit the window.rootViewController from
This is my code to switch the class of my body tag when a
Where can I find the option to switch between the Windows Working Set in
Switch statement fallthrough is one of my personal major reasons for loving switch vs.
When writing a switch statement, there appears to be two limitations on what you

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.