August 26, 200719 yr So i figure i might as well try... heres a full code drop of a basic, but working version (attached at end) it requires a couple of markup nonsenses to work cos of how gay javascript is, basically that the <A> element has to have the same ID as the <div> it is linking to. however this does not break it from working in non-JS browsers. Enjoy btw to make it go vertical instead, simply add clear:both to the #sainner > div, and change right to top in the tween. you will need to change the tween.js.txt to just tween.js Tween.js.txt scroll.html
August 26, 200719 yr neat, might have a try, ohh just one thing... what does it do? lol I seem not to know what it does...
August 26, 200719 yr When I click "one" I get a blank page, when I click "two" I get page one, when I click "three" I get page two. And why do they have to use the same id? Can you instead give the links a classname similar to the div's id and use that? or pick out the id from the href? (trimming the #)? Did you make the tween.js file? I like that it creates a non-linear movement. When I make animations I usually make them move quickly in the beginning and ease in at the end to enhance the feel of speed, like the animation you used in this example.
August 26, 200719 yr Author i used the id because it is the easiest to access (element.id) and i was getting pretty pissed off. feel free to modify it, using the trimmed href is a "neater" idea. to fix the scroll problem, remove the -1 from the line above the tween: ind = names[ind.id] -1; becomes ind = names[ind.id]; FF was spazzing out last night, and i uploaded the wrong version. the tween file was made by someone else - its a lot easier to use someone elses work than reinvent the wheel most of the time.
August 26, 200719 yr Author ok heres an updated version - another lazy fix just so you know it no longer requires an ID in the <a> tag, it just uses the href, and I've removed some unnecessary lines. thanks for the suggestions tomas scroll.html
August 26, 200719 yr That update didn't quite work. Here's some tweaks that fixes it: function scrollTo( ind ) { ind = names[ind.href.split('#')[1]]; tweenObj = new Tween(document.getElementById("sainner").style,"right",Tween.regularEaseInOut, (currentindex*500), (ind*500), 1, 'px'); tweenObj.start(); currentindex = ind; } function bindclicks() { var container = document.getElementById("fixedarea"); var elements = container.getElementsByTagName("a"); for( var i = 0; i < elements.length; i++ ) { elem = elements[i]; var namse = elem.href.split('#')[1]; names[ namse ] = i; elem.onclick = function() { scrollTo( this ); return false; }; } } The changes are in the scrollTo function: ind = names[ind.href.split('#')[1]]; This was previously refering to the id of the passed element, which now is no longer there. bindClicks: var namse = elem.href.split('#')[1]; you're method of using splice only extracted the last three letters from the href, which didn't work with anything other than "#one" and #two". I removed the elem.href = "#"; as it was requited by the scrollTo function. And instead I added a return false; to prevent the click event to be further processed by the brower.
August 26, 200719 yr Author tomas: it did work with three and four, however it extracted "ree" and "our", this method would only be a problem in the case of you having more then thirteen items, which is not very likely. however, the split is a more obvious solution - i just used the first one i got that worked.
August 26, 200719 yr Author worked for me... very strange edit: bloody caching ... it was working till i cleared my cache, then your edit worked ...
August 26, 200719 yr Ah! yea that explains it. It's so annoying trying to debug something only for your fix never to work because the script is cached. I think I've mostly had this problem in IE due to it's aggressive caching.
October 10, 200719 yr didnt work for me, looking at the code, how do you set this to a anchor and link?! i have a little understanding of code but i cant work out how to make this link to anything EDIT :: Got it working now, how do you slow down the scrolling though?
October 10, 200719 yr Author change some of the javascript .. it requires a modicum of jQuery knowledge though. look for the string "animate" in the javascript, then change one of the numbers to make it bigger, or the word "medium" to "slow"... its been a while since I did this, so i can't righly remember
October 10, 200719 yr that is really cool! the edges seem a little bit glitchy when it scrolls though, is there anything that can be done about that? also doesn't seem to work in IE ... pitty
Create an account or sign in to comment