Ankündigung

Einklappen
Keine Ankündigung bisher.

jQuery Slider Problem

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • jQuery Slider Problem

    Hallo Leute,

    ich habe ein kleines Problem. Ich habe mir mittels jQuery einen Slider erstellt. Funktioniert auch wunderbar. Leider nicht perfekt. Wenn ich z.b. im Firefox von meienr HP in einen anderen Tab schalte und dort eien weile bleibe und dann wieder zurück auf meine HP schalte, begint der slider in einem schnell durchlaf, die "verpasste" animation durchzulaufen, die ich dadurch dass ich im anderen tab gewesen bin, quasi verpasst habe. Ich versteh nicht woran es liegen kann.


    hier ist das Script:
    Code:
    // JavaScript Document
    
    (function($){
    		
    		$.fn.slider = function(option)
    		{
    			
    			$this = $(this);
    		// Variablen
    			option = {
    				auto:true,
    				speed:5000
    			}
    		
    		opt = $.extend($.fn.slider.option,option);
    		
    		// objects
    		obj = {
    				
    				slider_body: $this.find(".slider_body"),
    				infobox: $this.find(".slider_infoBox"),
    				infobox_elemnts : $this.find(".slider_infoBox").find("h3,span,a"),
    				navi_elements:	$this.find("#slide_navigation ").find("li")
    			}	
    		
    	
    		// Css Einstellungen
    		obj.infobox.css("opacity",0.6)
    		obj.slider_body.hide();
    		
    		obj.navi_elements.css("opacity",0.6)
    		
    		
    		
    		
    	
    		//
    		
    		
    		/* ----------------------------------------------------------------------------------------
    		*	loop
    		*
    		*	leitet eine Schleife ein.
    		*/
    		function loop()
    		{
    		
    			if(!opt.auto){ return;}	// wenn auto deaktiviert ist, dann keine automatische Animation
    			
    			// wenn nicht
    			blend()
    			setTimeout(loop, opt.speed );
    
    		} // loop Ende
    		
    		/* ----------------------------------------------------------------------------------------
    		*	name: blend
    		*	type: function
    		*	führt die Slideeffekte durch
    		*/
    		function blend()
    		{
    			
    			var current = obj.slider_body.filter(".current");
    				current.find(".slider_infoBox").slideUp("slow"); // infobox Slideup
    			    obj.navi_elements.filter(".current").removeClass("current");
    			    current.fadeOut("slow")
    						.removeClass("current");
    						
    			current = (current.next(".slider_body").length) ?
    			current.next() : obj.slider_body.first();
    			obj.navi_elements.filter('[rel="'+ current.attr("id")+'"]').addClass("current")
    			current.fadeIn("slow").addClass("current");
    			
    			current.find(".slider_infoBox").delay(1000).slideDown("slow")
    			
    		}
    		// Starten der Animation
    		
    		/* ----------------------------------------------------------------------------------------
    		*	name: 
    		*	type: click
    		*	Navigation der Slider
    		*/
    		
    		obj.navi_elements.not(".current").click(function()
    		{
    			obj.navi_elements.removeClass("current");
    			
    			opt.auto=false; // Animation stoppen
    			
    			var current= obj.slider_body.filter(".current")
    							current.find(".slider_infoBox").slideUp("slow"); // infobox Slideup
    			   				current.fadeOut("slow")
    								.removeClass("current");
    						
    			current = obj.slider_body.filter('[id="'+$(this).attr("rel")+'"]')
    										.fadeIn("slow").addClass("current")
    									.find(".slider_infoBox").slideDown("slow"); // verstecken der infoBox
    					
    			$(this).addClass("current")
    			
    		
    		})
    	
    		
    		
    		obj.slider_body.first().fadeIn("slow",function(){
    			obj.navi_elements.filter('[rel="'+$(this).attr("id")+'"]').addClass("current");
    			$(this).find(".slider_infoBox").slideDown("slow")
    			setTimeout(loop, opt.speed );
    		}).addClass("current");
     		} // fn.slider ENDE
    	
    	
    
    })(jQuery)
    mfg
    atkaz

  • #2
    No more animation “worm holes”: We had high hopes for the browser’s requestAnimationFrame API when we added support into version 1.6. However, one of the highest-volume complaints we’ve received since then relates to the way requestAnimationFrame acts when a tab is not visible. All the animations initiated when the tab is invisible “stack” and are not executed until the tab is brought back into focus. Then they all animate at warp speed! We’ve removed support for this API (which has no impact on the way you call jQuery’s animation features) and plan to incorporate it into a future version of jQuery.
    http://blog.jquery.com/2011/09/01/jq...-6-3-released/

    Kommentar

    Lädt...
    X