Foros del Web » Programando para Internet » Javascript »

Adaptar el siguiente Script

Estas en el tema de Adaptar el siguiente Script en el foro de Javascript en Foros del Web. Hola, gracias a una respuesta en este foro, di con este script de "http://dezinerfolio.com/" (excelente por cierto) que me realiza un SoftScroll entre los anclajes ...
  #1 (permalink)  
Antiguo 05/06/2008, 09:35
 
Fecha de Ingreso: enero-2008
Mensajes: 273
Antigüedad: 16 años, 4 meses
Puntos: 1
Adaptar el siguiente Script

Hola, gracias a una respuesta en este foro, di con este script de "http://dezinerfolio.com/" (excelente por cierto) que me realiza un SoftScroll entre los anclajes de mi pagina web. El tema es que mi idea primaria era hacerlos de manera horizontal en vez de vertical, ya que el diseño pensado tiene que ver con eso. Y claro, no manejo JS.. y pensé que escarbando un poco iba a dar con la respuesta.. pero no () alguién puede darme una mano al respecto?¿es posible adaptar este script?¿alguien tiene otro script?
Desde ya muchas gracias.
Este es el JS en cuestión:

Código:
/*--------------------------------------------------------------------------
 *  Smooth Scroller Script, version 1.0.1
 *  (c) 2007 Dezinerfolio Inc. <[email protected]>
 *
 *  For details, please check the website : http://dezinerfolio.com/
 *
/*--------------------------------------------------------------------------*/

Scroller = {
	// control the speed of the scroller.
	// dont change it here directly, please use Scroller.speed=50;
	speed:10,

	// returns the Y position of the div
	gy: function (d) {
		gy = d.offsetTop
		if (d.offsetParent) while (d = d.offsetParent) gy += d.offsetTop
		return gy
	},

	// returns the current scroll position
	scrollTop: function (){
		body=document.body
	    d=document.documentElement
	    if (body && body.scrollTop) return body.scrollTop
	    if (d && d.scrollTop) return d.scrollTop
	    if (window.pageYOffset) return window.pageYOffset
	    return 0
	},

	// attach an event for an element
	// (element, type, function)
	add: function(event, body, d) {
	    if (event.addEventListener) return event.addEventListener(body, d,false)
	    if (event.attachEvent) return event.attachEvent('on'+body, d)
	},

	// kill an event of an element
	end: function(e){
		if (window.event) {
			window.event.cancelBubble = true
			window.event.returnValue = false
      		return;
    	}
	    if (e.preventDefault && e.stopPropagation) {
	      e.preventDefault()
	      e.stopPropagation()
	    }
	},
	
	// move the scroll bar to the particular div.
	scroll: function(d){
		i = window.innerHeight || document.documentElement.clientHeight;
		h=document.body.scrollHeight;
		a = Scroller.scrollTop()
		if(d>a)
			if(h-d>i)
				a+=Math.ceil((d-a)/Scroller.speed)
			else
				a+=Math.ceil((d-a-(h-d))/Scroller.speed)
		else
			a = a+(d-a)/Scroller.speed;
		window.scrollTo(0,a)
	  	if(a==d || Scroller.offsetTop==a)clearInterval(Scroller.interval)
	  	Scroller.offsetTop=a
	},
	// initializer that adds the renderer to the onload function of the window
	init: function(){
		Scroller.add(window,'load', Scroller.render)
	},

	// this method extracts all the anchors and validates then as # and attaches the events.
	render: function(){
		a = document.getElementsByTagName('a');
		Scroller.end(this);
		window.onscroll
	    for (i=0;i<a.length;i++) {
	      l = a[i];
	      if(l.href && l.href.indexOf('#') != -1 && ((l.pathname==location.pathname) || ('/'+l.pathname==location.pathname)) ){
	      	Scroller.add(l,'click',Scroller.end)
	      		l.onclick = function(){
	      			Scroller.end(this);
		        	l=this.hash.substr(1);
		        	 a = document.getElementsByTagName('a');
				     for (i=0;i<a.length;i++) {
				     	if(a[i].name == l){
				     		clearInterval(Scroller.interval);
				     		Scroller.interval=setInterval('Scroller.scroll('+Scroller.gy(a[i])+')',10);
						}
					}
				}
	      	}
		}
	}
}
// invoke the initializer of the scroller
Scroller.init();


/*------------------------------------------------------------
 *						END OF CODE
/*-----------------------------------------------------------*/

Última edición por elsalta; 05/06/2008 a las 09:56 Razón: estaba muy desprolijo.
  #2 (permalink)  
Antiguo 05/06/2008, 09:55
 
Fecha de Ingreso: enero-2008
Mensajes: 273
Antigüedad: 16 años, 4 meses
Puntos: 1
Respuesta: Adaptar el siguiente Script

solo agregar que ademas tiene otro .js.. con lo siguiente:
//dezinerfolio
eval((function(){a="Scroller={speed:10,8dC.;d .while(dC.+C.}} J8N;d=5;&&M4M}d&&dM4dM}%4%} 0J8a,F4(F,fa@7a.4a.LP+F7Jend8e66.cance lBubble=true;6.Value=fa@;}&&(E(7J8di= Hn er3||5.G3;hN.3;a=(Ed>ah-d>i7e@{-(h-d)7}e@{a=a+(d-a} To(0,aEa==a}=aJHit8KwHdow,A,A7,A8 2 P;l=9;d=locatiP;D&&D.HdexOfL#)!=-1&&(l/+l=C)Kl,Gck,endEl.PGck=2l=this.hash.substr( 1E9.name==l;i=setILL+(9)+),107}}}}}}; Hit()",b=48;while(b>=0)a=a.replace(new RegExp(" %23456789@ACDEFGH JKLMNP".charAt(b),"g"),("\042Scroller.entfunct ion(offsetParscrollwindow.returndocumattac hEvntervala=.getElemsByTagName(a);if(offs etTop){for(i=0;i<a.length;i++.pathnamea+=Math .ceil((d-ae.stopPropagationTopa.addEvListenerbody)/speede.prevDefaultclearI(i) pageYOffset end(this);Height .Elem ev)}:a[i]lseload=dl.href);b,dcliin},((.= .=C||on".split(""))[b--]);return a})())
  #3 (permalink)  
Antiguo 05/06/2008, 14:04
 
Fecha de Ingreso: enero-2008
Mensajes: 273
Antigüedad: 16 años, 4 meses
Puntos: 1
Respuesta: Adaptar el siguiente Script

Ya que pasan de largo a mi post anterior, vuelvo a la fuente: La pregunta inicial!:
Quiero hacer una web "extra ancha", es decir, que la navegacion de la misma sea en lo horizontal en vez de en lo vertical, la idea es separar los temas con "anclajes con nombre" (aunque estoy habierto a hacerlo con id de div..o celdas..) y lo que maaaas me gustaria de todo es que de un anclaje a otro el scroll sea paulatino.. como quien ve pasar un tren, es decir si voy desde el tema 1 al 7.. vea pasar (aunque velozmente) 2345 y 6.. tal cual lo hace verticalmente: http://www.dezinerfolio.com/wp-content/uploads/smoothscrolldemo/df_smooth_scroll.html
Si alguien sabe de un script que me lo permita.. estaré eternamente agradecido
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:02.