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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T21:24:38+00:00 2026-05-15T21:24:38+00:00

I have two functions I would like to use in my before callback with

  • 0

I have two functions I would like to use in my before callback with jquery cycle. One slides the pager over as the user cycles through, and other other centers the image horizontally and vertically inside the containing div. Both work great separately, yet I can seem to get them to work together both on the before callback. I have an example that shows what I’ve got yet the slide function is set on the after callback. – http://tinyurl.com/27pmzj5

Here is the code I have so far.

$(function() {

$('#photo-slideshow').cycle({ 
    timeout: 0,
    next: '#next-btn', 
    prev: '#prev-btn',
    before: align,
    after: slide,
    pager:  '#nav', 
    // callback fn that creates a thumbnail to use as pager anchor 
    pagerAnchorBuilder: function(idx, slide) { 
        return '<li><a href="#"><img src="' + slide.src + '" width="75" height="75" /></a></li>'; 
    } 
});


//Play and Pause
$('#pause-btn').click(function() { $('#photo-slideshow').cycle('pause'); return false; });
$('#play-btn').click(function() { $('#photo-slideshow').cycle('resume'); return false; });


//Align Image       
function align(curr,next,opts) {

    //center the image
    var $slide = $(next);
    var w = $slide.outerWidth();
    var h = $slide.outerHeight();
    $slide.css({
        marginTop: (800 - h) / 2,
        marginLeft: (800 - w) / 2
    });


    //centers the DIV vertically!!!!    
    var divHeight = 800;
    var theImageHeight = $slide.outerHeight();
    var newTopMargin = (divHeight - theImageHeight) / 2;
    if(theImageHeight > 800){
        $('#photo-slideshow').css({
            marginTop: newTopMargin
        });
    }


    //Adds caption and credit line
    $('#photo-info').html(this.title) 
        .append('<p>' + "Credit: "  + this.alt + '</p>'); 


}


//Slide Pager
function slide(a,b,c,d) {
    if ( c.currSlide < c.slideCount-3 || c.nextSlide == 0 ){
            var p = ( c.nextSlide - 2 < 0 ) ? 0 : -(75*(c.nextSlide-2));
            $("#nav").animate({"left":p+"px"},500);
        }

    }

}); 

Any help on getting this two to both work on the before callback would be greatly appreciated!

  • 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-15T21:24:39+00:00Added an answer on May 15, 2026 at 9:24 pm

    Maybe I’m misunderstanding the question, but can’t you just do:

    before: function(a, b, c, d) {
      align(a, b, c);
      slide(a, b, c, d);
    }
    

    ?? In other words, just set the “before” handler to a function that calls your other two functions. You could write it as a separate function if you like:

    function callBoth(a, b, c, d) {
      align(a, b, c, d);
      slide(a, b, c, d);
    }
    

    To make it a little less ugly you could do this:

    function callBoth() {
      align.apply(this, arguments);
      slide.apply(this, arguments);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So let's say I have two different functions. One is a part of the
I have two functions to add and remove table rows that contain a form
EDIT: I also have access to ESXLT functions. I have two node sets of
I have a PHP file, Test.php, and it has two functions: <?php echo displayInfo();
Say I have the following code: function One() {} One.prototype.x = undefined; function Two()
I have a function which parses one string into two strings. In C# I
I have two constructor : function clsUsagerEmailUserName($nickName, $email) { $this->nickName = $nickName; $this->email =
I have two classes that each need an instance of each other to function.
I have two applications written in Java that communicate with each other using XML
I have two arrays of animals (for example). $array = array( array( 'id' =>

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.