Re:Ben the Bodyguard: Gorgeous HTML5 Website
by mortenjorck on Thursday December 02, 2010 @02:07PM
(#1963262)
Javascript's onscroll event is a wonderful tool. It's one of the best ways to leverage an extremely common and expected interaction pattern (scrolling down a web page) to do interesting and unexpected things. I used it to create a sort of paginated-persistent-bookmark navigation for my new portfolio site earlier this year (in profile, if you're curious).
Re:Ben the Bodyguard: Gorgeous HTML5 Website
by GavinB on Thursday December 02, 2010 @03:16PM
(#1963490)
Clickable: http://rclayton.net
I think it's very elegantly done. Kudos.
Re:Ben the Bodyguard: Gorgeous HTML5 Website
by etcet on Thursday December 02, 2010 @04:32PM
(#1963736)
is beautiful in firefox but it looks like this in my default chromium: http://imgur.com/NVP1i.png
D:
Re:Ben the Bodyguard: Gorgeous HTML5 Website
by mortenjorck on Friday December 03, 2010 @09:23AM
(#1965866)
Wow, I thought I had tested it in Chrome. Thanks!
Re:Ben the Bodyguard: Gorgeous HTML5 Website
by msquared on Friday December 03, 2010 @09:07AM
(#1965806)
Yeah, Chrome doesn't like this site. Which is a shame - when I opened it in Firefox I was impressed, but if I had not been prompted to check it out by the comments on this thread I would have moved on...
Re:Ben the Bodyguard: Gorgeous HTML5 Website
by maushu on Friday December 03, 2010 @09:23AM
(#1965865)
Rendering problems in Chrome, first time I've seen this.
Very unusable in mobiles too
Re:Ben the Bodyguard: Gorgeous HTML5 Website
by retroryan on Friday December 03, 2010 @04:01AM
(#1965236)
This website http://www.hellokeepa.com is also doing some interesting things with what looks to be the onscroll event, the page continuously wraps around. Also notice how you can drag the page left and right.
Ben is just an image positioned in the centre of the screen using a CSS property called "position: fixed", which means he doesn't move even when the content scrolls.
The walking animations are created using a technique called CSS sprites, where instead of having multiple images, you just create one and move it within the frame so that only one image is visible at a time - sort of like a film strip. The CSS property to do that is called "background-position" - and you can see an original image here: http://benthebodyguard.com/images/bensprite.png
The whole thing is driven by a function called "scrollEventHandler", which is registered with the javascript "onscroll" event, so it's triggered every time you scroll. It updates the animations for Ben, the thief, train, textboxes etc based on how far you've scrolled in the document. Source here: http://benthebodyguard.com/js/speechBubbles.js
The other animations (flickering lights and such) are all animated gifs, and the background is just a really long image: http://benthebodyguard.com/images/city-background.jpg