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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:22:28+00:00 2026-06-18T16:22:28+00:00

that’s probably a silly question, but i have a problem not with the code

  • 0

that’s probably a silly question, but i have a problem not with the code not functioning – it’s rather the code is too long…

everything works fine but for example is there a way to shorten the if/else ?
or is it possible to track 4 different var but with a shorter code ?

var transitionState_N = '-';
var transitionState_X = '-';
var transitionState_Y = '-';
var transitionState_Z= '-';

// carousel 4way
function carousel_4way_N (n, el, m) {
    var carousel = '#carousel-4way-nav-' + n
    var carousel_content = '#carousel-4way-' + n
        if (transitionState_N == '-')
          {
          transitionState_N = '+';
          }
          else
          {
          transitionState_N = '-';
          }
        $(carousel_reset).hide();
        $(carousel).transition(
        {y: m + '=10',delay:200}
        );
        };

function carousel_4way_X (n, el, m) {
    var carousel = '#carousel-4way-nav-' + n
    var carousel_content = '#carousel-4way-' + n
        if (transitionState_X == '-')
          {
          transitionState_X = '+';
          }
          else
          {
          transitionState_X = '-';
          }
        $(carousel_reset).hide();
        $(carousel).transition(
        {y: m + '=10',delay:200}
        );
        };

function carousel_4way_Y (n, el, m) {
    var carousel = '#carousel-4way-nav-' + n
    var carousel_content = '#carousel-4way-' + n
        if (transitionState_Y == '-')
          {
          transitionState_Y = '+';
          }
          else
          {
          transitionState_Y = '-';
          }
        $(carousel_reset).hide();
        $(carousel).transition(
        {y: m + '=10',delay:200}
        );
        };

function carousel_4way_Z (n, el, m) {
    var carousel = '#carousel-4way-nav-' + n
    var carousel_content = '#carousel-4way-' + n
        if (transitionState_Z == '-')
          {
          transitionState_Z = '+';
          }
          else
          {
          transitionState_Z = '-';
          }
        $(carousel_reset).hide();
        $(carousel).transition(
        {y: m + '=10',delay:200}
        );
        };

$('#carousel-4way-nav-1').click(function(event){
    $(carousel_reset_nav).not(this).transition(
    {y:0});
    return carousel_4way_N(1, this, (transitionState == '-') ? '+' : '-');
    event.preventDefault();
});

$('#carousel-4way-nav-2').click(function(event){
    $(carousel_reset_nav).not(this).transition(
    {y:0});
    return carousel_4way_X(2, this, (transitionState == '-') ? '+' : '-');
    event.preventDefault();
});

$('#carousel-4way-nav-3').click(function(event){
    $(carousel_reset_nav).not(this).transition(
    {y:0});
    return carousel_4way_Y(3, this, (transitionState == '-') ? '+' : '-');
    event.preventDefault();
});

$('#carousel-4way-nav-4').click(function(event){
    $(carousel_reset_nav).not(this).transition(
    {y:0});
    return carousel_4way_Z(4, this, (transitionState == '-') ? '+' : '-');
    event.preventDefault();
});
  • 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-18T16:22:29+00:00Added an answer on June 18, 2026 at 4:22 pm

    The ternary operator makes it somewhat more readable:

    transitionState_N  = (transitionState_N == '-') ? '+' : '-';
    

    Your functions are really repetitive. Look for code you repeat often and write a function to replace it.

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

Sidebar

Related Questions

... that is the question. I have been working on an algorithm which takes
I have a French site that I want to parse, but am running into
This could be a duplicate question, but I have no idea what search terms
That's not entirely accurate. I have a user table and some/most Users are Trainers.
That's my question, and here's my example code. HTML: <a class=fancybox rel=group href=img1.jpg> <img
That is my first question around here, my name is Anna! My problem: My
That sounds familiar I'm sure, but it's not a CSS hack issue. I'm literally
That's the question. Give only one reason you think why have OODB failed or
That's it. It's a dumb dumb (embarrassing!) question, but I've never used C# before,
That's very simple question I believe. Could anybody explain why this code outputs 1000,

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.