Tema: Sobre jquery
Ver Mensaje Individual
  #4 (permalink)  
Antiguo 05/05/2011, 09:43
matucats
 
Fecha de Ingreso: mayo-2011
Mensajes: 8
Antigüedad: 13 años
Puntos: 0
Respuesta: Sobre jquery

Este es el script principal del slide:

/*
* jQuery SmoothDivScroll 1.1
*
* Copyright (c) 2010 Thomas Kahn
* Licensed under the GPL license.
*
* http://www.maaki.com/thomas/SmoothDivScroll/
*
* Depends:
* jquery.ui.widget.js
*
*/
(function($){$.widget("thomaskahn.smoothDivScroll" ,{options:{scrollingHotSpotLeft:"div.scrollingHotS potLeft",scrollingHotSpotRight:"div.scrollingHotSp otRight",scrollableArea:"div.scrollableArea",scrol lWrapper:"div.scrollWrapper",hiddenOnStart:false,a jaxContentURL:"",countOnlyClass:"",scrollStep:15,s crollInterval:10,mouseDownSpeedBooster:3,autoScrol l:"",autoScrollDirection:"right",autoScrollStep:5, autoScrollInterval:10,visibleHotSpots:"",hotSpotsV isibleTime:5,startAtElementId:""},_create:function (){var self=this,o=this.options,el=this.element;el.data(" scrollWrapper",el.find(o.scrollWrapper));el.data(" scrollingHotSpotRight",el.find(o.scrollingHotSpotR ight));el.data("scrollingHotSpotLeft",el.find(o.sc rollingHotSpotLeft));el.data("scrollableArea",el.f ind(o.scrollableArea));el.data("speedBooster",1);e l.data("motherElementOffset",el.offset().left);el. data("scrollXPos",0);el.data("hotSpotWidth",el.fin d(o.scrollingHotSpotLeft).width());el.data("scroll ableAreaWidth",0);el.data("startingPosition",0);el .data("rightScrollInterval",null);el.data("leftScr ollInterval",null);el.data("autoScrollInterval",nu ll);el.data("hideHotSpotBackgroundsInterval",null) ;el.data("previousScrollLeft",0);el.data("pingPong Direction","right");el.data("getNextElementWidth", true);el.data("swapAt",null);el.data("startAtEleme ntHasNotPassed",true);el.data("swappedElement",nul l);el.data("originalElements",el.data("scrollableA rea").children(o.countOnlyClass));el.data("visible ",true);el.data("initialAjaxContentLoaded",false); el.data("enabled",true);if(o.autoScroll!=="always" ){switch(o.visibleHotSpots){case"always":self.show HotSpotBackgrounds();break;case"onstart":self.show HotSpotBackgrounds();el.data("hideHotSpotBackgroun dsInterval",setTimeout(function(){self.hideHotSpot Backgrounds("slow")},(o.hotSpotsVisibleTime*1000)) );break;default:break}}el.data("scrollingHotSpotRi ght").bind("mousemove",function(e){var x=e.pageX-(this.offsetLeft+el.data("motherElementOffset"));e l.data("scrollXPos",Math.round((x/el.data("hotSpotWidth"))*o.scrollStep));if(el.data ("scrollXPos")===Infinity){el.data("scrollXPos",0) }});el.data("scrollingHotSpotRight").bind("mouseov er",function(){if((o.autoScroll==="onstart"&&el.da ta("autoScrollInterval")!==null)){clearInterval(el .data("autoScrollInterval"));el.data("autoScrollIn terval",null);self._trigger("autoScrollIntervalSto pped")}el.data("rightScrollInterval",setInterval(f unction(){if(el.data("scrollXPos")>0&&el.data("ena bled")){el.data("scrollWrapper").scrollLeft(el.dat a("scrollWrapper").scrollLeft()+(el.data("scrollXP os")*el.data("speedBooster")));self._showHideHotSp ots()}},o.scrollInterval));self._trigger("mouseOve rRightHotSpot")});el.data("scrollingHotSpotRight") .bind("mouseout",function(){clearInterval(el.data( "rightScrollInterval"));el.data("scrollXPos",0)}); el.data("scrollingHotSpotRight").bind("mousedown", function(){el.data("speedBooster",o.mouseDownSpeed Booster)});$("body").bind("mouseup",function(){el. data("speedBooster",1)});el.data("scrollingHotSpot Left").bind("mousemove",function(e){var x=el.data("scrollingHotSpotLeft").innerWidth()-(e.pageX-el.data("motherElementOffset"));el.data("scrollXPo s",Math.round((x/el.data("hotSpotWidth"))*o.scrollStep));if(el.data ("scrollXPos")===Infinity){el.data("scrollXPos",0) }});el.data("scrollingHotSpotLeft").bind("mouseove r",function(){if((o.autoScroll==="onstart"&&el.dat a("autoScrollInterval")!==null)){clearInterval(el. data("autoScrollInterval"));el.data("autoScrollInt erval",null);self._trigger("autoScrollIntervalStop ped")}el.data("leftScrollInterval",setInterval(fun ction(){if(el.data("scrollXPos")>0&&el.data("enabl ed")){el.data("scrollWrapper").scrollLeft(el.data( "scrollWrapper").scrollLeft()-(el.data("scrollXPos")*el.data("speedBooster")));s elf._showHideHotSpots()}},o.scrollInterval));self. _trigger("mouseOverLeftHotSpot")});el.data("scroll ingHotSpotLeft").bind("mouseout",function(){clearI nterval(el.data("leftScrollInterval"));el.data("sc rollXPos",0)});el.data("scrollingHotSpotLeft").bin d("mousedown",function(){el.data("speedBooster",o. mouseDownSpeedBooster)});$(window).bind("resize",f unction(){if(!(o.hiddenOnStart)){self._showHideHot Spots()}self._trigger("windowResized")});if(o.ajax ContentURL.length>0){self.replaceContent(o.ajaxCon tentURL)}else{self.recalculateScrollableArea()}if( o.hiddenOnStart){self.hide()}if((o.autoScroll.leng th>0)&&!(o.hiddenOnStart)&&(o.ajaxContentURL.lengt h<=0)){self.startAutoScroll()}},showHotSpotBackgro unds:function(fadeSpeed){var self=this,el=this.element;if(fadeSpeed!==undefined ){el.data("scrollingHotSpotLeft").css("opacity","0 .0");el.data("scrollingHotSpotRight").css("opacity ","0.0");el.data("scrollingHotSpotLeft").addClass( "scrollingHotSpotLeftVisible");el.data("scrollingH otSpotRight").addClass("scrollingHotSpotRightVisib le");el.data("scrollingHotSpotLeft").fadeTo(fadeSp eed,0.35);el.data("scrollingHotSpotRight").fadeTo( fadeSpeed,0.35)}else{el.data("scrollingHotSpotLeft ").addClass("scrollingHotSpotLeftVisible");el.data ("scrollingHotSpotLeft").removeAttr("style");el.da ta("scrollingHotSpotRight").addClass("scrollingHot SpotRightVisible");el.data("scrollingHotSpotRight" ).removeAttr("style")}self._showHideHotSpots()},hi deHotSpotBackgrounds:function(fadeSpeed){var el=this.element;if(fadeSpeed!==undefined){el.data( "scrollingHotSpotLeft").fadeTo(fadeSpeed,0.0,funct ion(){el.data("scrollingHotSpotLeft").removeClass( "scrollingHotSpotLeftVisible")});el.data("scrollin gHotSpotRight").fadeTo(fadeSpeed,0.0,function(){el .data("scrollingHotSpotRight").removeClass("scroll ingHotSpotRightVisible")})}else{el.data("scrolling HotSpotLeft").removeClass("scrollingHotSpotLeftVis ible");el.data("scrollingHotSpotLeft").removeAttr( "style");el.data("scrollingHotSpotRight").removeCl ass("scrollingHotSpotRightVisible");el.data("scrol lingHotSpotRight").removeAttr