5

I have a JQuery slideshow where some text/slide fades in and out.

At the same time I have a navigation/spots to click. When you click on a spot the slide/text changes.

The problem is when the text/slide is fading and the user clicks on a spot, the fading is interrupted. And if the user clicks on all the spots fast, then there is text from different slides that is shown at the same time.

I want the fading to end and then the users can click. In short: when fading no click.

I have made a little example that shows the problem.

Head-part of the html:

<style type="text/css">
     .slideshow
     {
         width:600px;
         height:30px;
         background-color:#0FF;                      
         overflow:hidden;
         margin:50px;
     }
     .slideshow_text_font
     {
         font:Verdana, Geneva, sans-serif;
         font-size:22px;
         font-weight:bold;       
     }
  </style>

  <script type="text/javascript" src="js/jquery.min.js"></script>
  <script type="text/javascript" src="js/jquery.cycle.all.latest.js"></script>

  <script type="text/javascript"> 
     $(document).ready(function() {
         $('.slideshow').cycle({                        
            fx: 'custom',
             sync: 0,
             cssBefore: {
                 opacity:0,
                 display: 'block'
             },
             animIn:  {
                 opacity:1               
             },
             animOut: {
                 opacity:0
             },
             timeout:5000,
             speed:2000
         });
     });

     if (document.images) {
         function setSlide(index) { 
           $('.slideshow').cycle(index);
         } 
     }
   </script>

Body-part of the html:

<div class="slideshow">
    <div><a class="slideshow_text_font">1. Some text for slide number one</a></div>
    <div><a class="slideshow_text_font">2. Lorem Ipsum is simply dummy text of the</a></div>
    <div><a class="slideshow_text_font">3. Contrary to popular belief, Lorem Ipsum</a></div>
    <div><a class="slideshow_text_font">4. The standard chunk of Lorem Ipsum used</a></div>
    <div><a class="slideshow_text_font">5. It is a long established fact that a</a></div>
    <div><a class="slideshow_text_font">6. There are many variations of passages</a></div>    
  </div>

  <div>
    <a class="slideshow_text_font" onclick="setSlide(0)">Show slide 01</a><br />
    <a class="slideshow_text_font" onclick="setSlide(1)">Show slide 02</a><br />
    <a class="slideshow_text_font" onclick="setSlide(2)">Show slide 03</a><br />
    <a class="slideshow_text_font" onclick="setSlide(3)">Show slide 04</a><br />
    <a class="slideshow_text_font" onclick="setSlide(4)">Show slide 05</a><br />
    <a class="slideshow_text_font" onclick="setSlide(5)">Show slide 06</a>
  </div>
jackJoe
  • 11,078
  • 8
  • 49
  • 64

2 Answers2

2

You could use add this plugin code to block all clicks:

(function($) {
    var blocker = $("<div/>", {
            id: "clickBlocker",
            style: 'position:absolute; top:0; left:0; width:100%; height:100%; z-index:100000; display:none; background:url(#);'
        }).click(function(e) {
            e.stopPropagation();
        });

    $.fn.blockClicks = $.blockClicks = function() {
        if(arguments[0]===false) {
            blocker.hide();
        } else {
            blocker.show();
        }
        return (typeof this=="function") ? undefined : this;
    }

    $(function() {
        $("body").append(blocker);
    });
})(jQuery);

To start blocking all clicks, use .blockClicks() while chaining, or just use $.blockClicks(); To stop blocking clicks, just send false:

$.blockClicks(false);

See this jsfiddle for a demonstration.

uɥƃnɐʌuop
  • 14,022
  • 5
  • 58
  • 61
1

Try setting prevNextEvent to null.

axel22
  • 32,045
  • 9
  • 125
  • 137
Matt
  • 11
  • 1