0

I am using JQuery cycle for an slide show for my home page. The main idea is that certain groups of images appear together, So I want to synch the intervals some how that I have the following pattern 1-2-3 -> 1-4-3 -> 5-4-6 -> 1-4-3 -> 1-2-3 ->... (imagine that I have images 1,2,3,4,5,6, for example 1-2-3 shows that images 1 and 2 and 3 appear together, and -> shows the transition). Here is my code for this:

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<style type="text/css">
pre { display:none }
#main h2 { text-align: center }
#right { cursor: pointer }
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5/jquery.min.js"></script>
<script type="text/javascript" src="http://malsup.github.com/jquery.cycle.all.js"></script>
<script type="text/javascript">

$(function() {
// run the code in the markup!
$('#demos pre code').each(function() {
    eval($(this).text());
});

});
</script>
</head>
<body>

<div id="main">

<div id="demos">
 <div id="slider">

    <div id="bxo" class="pics">
        <img id="letter-b" src="01.jpg" width="300" height="330" />
        <img id="veggi1" src="02.jpg" width="300" height="330" />
        <img id="letter-o" src="03.jpg" width="300" height="330" />

    </div>
    <div id="bio" class="pics">
        <img id="letter-b" src="01.jpg" width="300" height="330" />
        <img id="letter-i" src="05.jpg" width="300" height="330" />
        <img id="letter-o" src="03.jpg" width="300" height="330" />
    </div>
    <div id="xix" class="pics">
        <img  id="veggi2" src="04.jpg" width="300" height="330" />
        <img id="letter-i" src="05.jpg" width="300" height="330" />
        <img  id="veggi3" src="06.jpg" width="300" height="330" />
    </div>
    <div id="bio" class="pics">
        <img id="letter-b" src="01.jpg" width="300" height="330" />
        <img id="letter-i" src="05.jpg" width="300" height="330" />
        <img id="letter-o" src="03.jpg" width="300" height="330" />
    </div>



       </div>
       <pre><code class="mix">$('#slider').cycle(
    { 
                    fx:     'fade', 
                    speed:   500, 
                    timeout: 3000, 
                    pause:   1 
                    });
                    </code></pre>
 </body>
 </html>

Now I need that some of the slides appear in a brief moment. Therefore I need to define different speed for the slides. I need a pattern like this: 1-2-3 -----> 1-4-3 -> 5-4-6 -----> 1-4-3 -> 1-2-3 -----> (I need two speeds, one fast and one slow, the longer arrows show the slow transition while shorter arrows show fast transition). I was thinking of defining a custem transition to get two values for speed and switch between them in each cycle, but I don't know how to implement it with JQuery Cycle...

Cœur
  • 37,241
  • 25
  • 195
  • 267
mahsa.teimourikia
  • 1,664
  • 9
  • 32
  • 64

1 Answers1

0

I solved this problem by modifying the plugin a bit, in the JQuery Cycle source code the function that is getting executed in each transition is function go(els, opts, manual, fwd) So I simply defined a global variable which get increased in each transition, and used it to reduce the timeout in every odd transition. Something like this:

function go(els, opts, manual, fwd) {
    $.cycleno++;
    if($.cycleno%2==0)
        opts.timeout=3000;
    else
        opts.timeout=10;
    ....
}

And now I have the effect I wanted: slide1 -----> slide2 -> slide3 -----> slide4 -> slide5 ----->...

BenMorel
  • 34,448
  • 50
  • 182
  • 322
mahsa.teimourikia
  • 1,664
  • 9
  • 32
  • 64