Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

solidcoated

Javascript Scroller travando em link ancorado

Recommended Posts

Criei um link ancorado do tipo: "produtos.html#monitores", incluindo a id="#monitores" no seletor desejado. Assim sendo, ao abrir a página de produtos o conteúdo mostrado fica a partir do tópico "monitores" pra baixo.

 

O problema:

Estou usando um Scroller em Javascript para rolar meu conteúdo, mas a página está travando exatamente na âncora e então só permite que o conteúdo seja rolado daquele ponto (o tópico monitores) pra baixo, sem permitir voltar ao topo da página, aonde existe mais conteúdo de texto.

 

Alguma pista de como resolver isso?

Compartilhar este post


Link para o post
Compartilhar em outros sites

cara sem o script fica dificil ne =/

parece que ele marca o ponto 0 onde o usuario acessou pela primeira vez. e só rola para baixo.

voce tem que olhar onde tem essa função e tentar corrigir.

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ok, segue então o js script que estou usando:

 

//Written by Nathan Faubion: http://n-son.com

function jsScroller (o, w, h) {
	var self = this;
	var list = o.getElementsByTagName("div");
	for (var i = 0; i < list.length; i++) {
		if (list[i].className.indexOf("scroller_content") > -1) {
			o = list[i];
		}
	}
	
	//Private methods
	this._setPos = function (x, y) {
		if (x < this.viewableWidth - this.totalWidth) 
			x = this.viewableWidth - this.totalWidth;
		if (x > 0) x = 0;
		if (y < this.viewableHeight - this.totalHeight) 
			y = this.viewableHeight - this.totalHeight;
		if (y > 0) y = 0;
		this._x = x;
		this._y = y;
		with (o.style) {
			left = this._x +"px";
			top  = this._y +"px";
		}
	};
	
	//Public Methods
	this.reset = function () {
		this.content = o;
		this.totalHeight = o.offsetHeight;
		this.totalWidth	 = o.offsetWidth;
		this._x = 0;
		this._y = 0;
		with (o.style) {
			left = "0";
			top  = "0";
		}
	};
	this.scrollBy = function (x, y) {
		this._setPos(this._x + x, this._y + y);
	};
	this.scrollTo = function (x, y) {
		this._setPos(-x, -y);
	};
	this.stopScroll = function () {
		if (this.scrollTimer) window.clearInterval(this.scrollTimer);
	};
	this.startScroll = function (x, y) {
		this.stopScroll();
		this.scrollTimer = window.setInterval(
			function(){ self.scrollBy(x, y); }, 40
		);
	};
	this.swapContent = function (c, w, h) {
		o = c;
		var list = o.getElementsByTagName("div");
		for (var i = 0; i < list.length; i++) {
			if (list[i].className.indexOf("scroller_content") > -1) {
				o = list[i];
			}
		}
		if (w) this.viewableWidth  = w;
		if (h) this.viewableHeight = h;
		this.reset();
	};
	
	//variables
	this.content = o;
	this.viewableWidth  = w;
	this.viewableHeight = h;
	this.totalWidth	 = o.offsetWidth;
	this.totalHeight = o.offsetHeight;
	this.scrollTimer = null;
	this.reset();
};

Compartilhar este post


Link para o post
Compartilhar em outros sites

Eu não faço idéia de como resolver o problema, pois como estou usando um script gratuito, meu único trabalho foi formatar o CSS e inserir o JS Script no código HTML.

 

Quem puder me ajudar, eu realmente agradeço!

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.