Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Heres how to make things go slidy

Featured Replies

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

neat, might have a try, ohh just one thing... what does it do? lol I seem not to know what it does...

it makes content scroll, like is the new fad in web design....so it seems.

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.

  • 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.

  • 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

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.

  • 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.

  • Author

worked for me... very strange

 

edit: bloody caching ... it was working till i cleared my cache, then your edit worked ...

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.

  • 1 month later...

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?

  • 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

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

is there any way to get this to work in IE, i can only use it in Fire Fox

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.