
Elevator.js – A “back to top” button that behaves like a real elevator - gitgud
http://tholman.com/elevator.js/
======
cool-RR
The "back to top" functionality is so useful in web pages. I wish they would
make a dedicated button on keyboards that just takes you to the top of the
page. Better yet, it can work in other apps too! It could, for example, take
you to the beginning of a line when you're writing text.

 _Edit:_ Wow, I thought I was going the extra mile to make the joke obvious by
saying the key should also take you to the beginning of a text line, but I
guess it wasn't obvious enough for the first 3 commentators.

~~~
colmvp
Hacker News attracts a lot of smart readers, so I'm kind of surprised that
your comment actually 'fooled' people. It was very obvious sarcasm.

~~~
wojcikstefan
Plenty of Mac users out there without a “Home” button.

~~~
FractalParadigm
If I'm not mistaken, Fn + Left Arrow is Home on a Mac. Similar to Fn + up/down
is Page Up/Down, and IIRC Fn + Right is End.

~~~
jasonkester
It still amazes me that people tolerate that as a substitute.

It's a key combo that requires two hands, for what on a regular keyboard is
one finger.

Perhaps Mac people never hold a cup of coffee in their hand while using a
computer?

~~~
yolomcsuperswag
Accelerated scrolling makes the home key superfluous. Just scroll "fast".

~~~
raxxorrax
I use both home and end constantly while coding. Writing text not so much, but
it still does happen. Sure, you could do without, but...

~~~
Gracana
On a mac you'd use Control-A and Control-E to navigate to the beginning and
end of a line. IIRC Home and End navigate the document, not the line.

[https://support.apple.com/en-ca/HT201236](https://support.apple.com/en-
ca/HT201236)

~~~
raxxorrax
Hm, that would indeed be an alternative. I never tried hooking up a (windows-)
keyboard to a mac, but don't see why it shouldn't work. Question is if the
software or editors support the key layout.

------
Mirioron
This is pretty funny, but God do I hate back to the top buttons.

I'm reading a story on a page with a back to the top button. I get distracted
in real life and change the grip on my phone. I look back at my phone to
continue reading and I'm at the top of the page. Now I have to find where I
was again.

I've probably lost more time from accidentally hitting the back to the top
button than the button has saved me time. This has made me paranoid about
those buttons and I definitely prefer sites not to have them. Sometimes I
switch to desktop mode on my phone just so I don't have that button on the
screen.

~~~
saagarjha
I _really_ hate them on iOS, because the system comes with back-to-top
functionality so all these buttons are doing are looking ugly and covering
part of the page. And don’t even get me started on when AMP breaks scrolling…

~~~
bdibs
For anyone else who was wondering, you can tap the top of the address bar on
iOS Safari. I think it has to be expanded first. I didn’t know that and hope
it helps.

~~~
hackmiester
It works just about anywhere, actually. Just tap the time (or tap the
earpiece, on a notched phone) to scroll to the top. Works in Safari, Chrome,
Messages, Reddit, Tumblr, Twitter... the list of exceptions is short.

------
kabacha
"back to top" is just such an epitome of how out of touch some modern design
is.

We had buttons on our keyboards that did this for half a century now. As for
phones it should be up to the web-browser to implement it, nobody wants to use
your idea of how scrolling should work. My machine already knows how I want to
browse my content, don't pretend you know better.

~~~
dgb23
> out of touch

This is ironic. The vast majority of users don't know about most of these
functions. They just use their mouse. Even for basic things like:

\- navigating & selecting text (words, lines etc.)

\- switching between windows

\- opening search (like spotlight, if they use it at all...)

\- opening & closing windows/tabs, saving files etc.

The list goes on. UI design is not about teaching you how to use a computer.
And you certainly cannot expect users to already know.

That said. I think fixed position "back to top" buttons are terrible as well
and I would put fixed position header-menus in the same category. They just
add clutter and worsen the UX, even for those who almost exclusively use the
mouse (as you can simply drag the scroll-bar).

~~~
leonardteo
True. Whenever I sit and watch people use the computer (just watch when they
are giving a presentation/screen sharing), I often cringe.

Many don't use the scroll on their mouse/trackpad - they literally look for
the scrollbar, click and drag to scroll.

Many are blissfully unaware that the keys Page Up and Page Down move the page
up and down or that Home and End move the whole page to the beginning and the
end.

BUT, they do know about the Back button on the browser so they end up
resubmitting forms/double posting, etc. lol

------
gchokov
It woke up my wife, as I tried it on my phone when the stupid elevator music
played it out loud :/

In all seriousness, I hope this will not become another 250kb JS framework we
use in our projects..

~~~
chefandy
First if all, fuck webpages that play sound unexpectedly. Secondly, what
percentage of elevators even play music these days?

~~~
reaperducer
_Secondly, what percentage of elevators even play music these days?_

Pretty much every elevator I've been in for the last ten years. I note it
mentally because spirit of the music is always at odds with the messages on
the display screens.

I think the only elevators where I haven't heard music recently are in
residential buildings.

~~~
taylorlunt
Maybe it's regional, as I've never heard music in an elevator before.

~~~
chefandy
Same. Weird. I never imagined something so seemingly consistent as elevators
having regional dialects.

------
scared2
Nice one. Something important missing in this framework is a logic to check
the number of people in the elevator. You should use webRTC to count the
number of users using the elevator. And if it is more than 8 it should sound
alarm!

~~~
scared2
So the modified algorithm will be as follows. When the user clicks elevator,
it first sends a distributed query to all browsers and each browser replies
with 0, if elevator is not being used, or 1 when it is used. After the polling
is done, it sums all responses. If sum_resp_elev<8:move() else Ring_alarm()

~~~
sriku
Nope. When you're at the bottom of the page, you should first have to call the
elevator. Then it should stop at all those levels at which other people have
also called it before coming to your position. Then you get a chance to be
kicked out for being overweight.

------
xrd
How many other people are quitting web development after seeing this? I think
the work is done, there isn't anything else needed here.

~~~
encom
What's the opposite of development?

I think we need web un-development to get us out of this javascript tar pit.

~~~
izzydata
Clearly it would be velopment.

------
leonardteo
A lot of people already mentioned here the Home button. Anecdote: for years we
kept getting users asking for a back to top button and we always told them to
just use the Home button and they thought it was the most amazing thing ever.
Most of our users are on Windows.

Anyway, we did end up having to put a Back to top button. It was clear that
users just don’t get it. Most people really don’t know what the Home button
does.

That, and you should never use the Mailto: link without writing the email as
the text itself. Thanks to webmail, most users do not have their browsers
configured to open mailto: so they complain that contact email links on their
pages don’t work. Sigh....

~~~
kevincox
I don't know why this is "thanks to webmail". At least firefox can handle this
perfectly fine.

That being said seeing the email is nice anyways in case you need to share it
with someone or type it into your phone.

~~~
leonardteo
To clarify, all browsers CAN handle the mailto link as long as the user
configures it to open the correct email client. That’s key because there’s
many oblivious users who don’t even know about this setting (we know from the
number of support requests we get from users angry that the contact link they
created on their websites “don’t work”!). :)

Because of the prevalence of webmail like gmail (most of our users are on
gmail) there’s many users who aren’t aware that it needs to be configured to
open the said webmail page, so the mailto links does nothing. A “Contact me”
or “contact support” mailto link won’t open anything, or it will open the
default mail client like Mac Mail on Mac....On Windows in the past it would
open outlook express lol. :)

~~~
kevincox
I still don't see how webmail has anything to do with it. In fact opening
Gmail prompts me to make it my default mail handler.

Users can fail to configure mailto links to point at their preferred email
client irrespective of it being web-based or native. (Unless it is the default
for the platform I guess)

~~~
leonardteo
> Users can fail to configure mailto links to point at their preferred email
> client irrespective of it being web-based or native. (Unless it is the
> default for the platform I guess)

That's more the issue. It's just misconfiguration and users who are oblivious
to that setting. In the past, I don't believe that Gmail prompts you to make
it your default handler, and from the number of support requests we received
due to this issue, it's clear that a good number of users do not have their
mailto handlers configured.

Cheers!

------
CGamesPlay
I was expecting the button to light up and having to wait before being taken
to the top. Maybe an improvement for version 2.0!

~~~
nirui
And then you have to select the floor before it's going up, Ha!

Joke aside, maybe add a feature to allow user to pause/suspend the "Lifting"?
This will give user a chance to "Hey! oh wait" when they "Passed the desired
floor by mistake".

------
thunderbong
Warning - There's elevator music as well!

Wish this was mentioned on the page, it was a bit embarrassing when it started
playing in the middle of our daily standup!

~~~
Wowfunhappy
I respect that it put you in a bind, but a warning would have totally ruined
the joke for me.

------
alpaca128
I have never needed a "back to top" button in a web browser. However on almost
all sites that offer one I've been missing a "jump to where I just was before
I misclicked" button.

Those endless, highly volatile feeds that often can't even keep the ordering
of content between page refreshes are annoying.

------
dmos62
Back to the top buttons are a symptom of the system-within-a-system feature of
Web. The Web page isn't a document: it's a system, a virtual machine. Just
like running another OS in VirtualBox implies bad interoperability and a lot
of duplicated effort with the host OS, so too does running web pages. In a
quest to be everything, Web became a bogged down, developer-time devouring
beast. It can do almost anything, but you don't want to do anything on it.

~~~
sergeykish
It means _universal_ , think smalltalk. Has ups and downs - not much
integration with a host comes with independence from a host. IE was created
because Microsoft feared web would make OS inconsiderable. There was bold
claim even before Netscape's Constellation [1]. So everything goes like it was
predicted years ago.

[1]
[https://people.apache.org/~jim/NewArchitect/webrevu/1997/02_...](https://people.apache.org/~jim/NewArchitect/webrevu/1997/02_07/developers/02_07_97_2.html)

------
kens
Is there any way to tell Chrome not to make sound unless I explicitly want it?
Maybe I have less tolerance than most people, but I just can't stand it when
my computer makes unexpected noise.

~~~
WrtCdEvrydy
Right click mute tab (i think it might be experimental)

~~~
theon144
Haha, it used not to be, but then Google crippled the feature. Firefox is
looking better by the day.

~~~
rnotaro
Google changed it for "Mute website" when right-clicking a tab and it's not
experimental.

It's better than "Mute tab" because it's persistant over multiple sessions.

------
yefim
For those that didn't get it, turn your sound on.

~~~
cmbell715
I didn’t realize I had my volume all the way up. Scared the crap out of me.

------
fnordsensei
Very good, but it should also be non-functioning 60% of the time due to
repairs and/or inspections.

~~~
esperent
I'm trying to think of times when I've seen a non-functional elevator and
can't think of one.

~~~
52-6F-62
Come live in my building... we're usually operating at half-capacity.
Presently we're down to 1/4 elevators for a 32-story residential building.
It's a little on the frustrating side.

Our elevators break down quarterly, and for some reason the wait for Otis-
approved parts is weeks to months at a time.

------
teknopurge
I think other than being kitchy, the part I love the most is NO FRAMEWORK:
plain js. No pre/mid/post/art-deco processor that turns 4 hours of work into
40 hours.

~~~
Aperocky
I've been developing some games and frontend on my free time for fun. I've
been using typescript and Pixi.js but other than that nothing else. As a
backend engineer, I've always thought about learning a frontend framework but
I've never actually had a strong need of it.

So question if you're a frontend engineer: Should I? I never felt the need of
a framework despite I render quite a bit of dom elements. Do I have a need
that I just don't know right now?

~~~
csande17
If you want to get a job as a frontend engineer, you should learn React
because it's a tick-box on a lot of job postings these days.

If you just want to make personal projects, it depends a lot on what kinds of
projects you want to make. React won't really help you with the sort of
2D-game-type programming you're using Pixi.js for. On the other hand, if you
think the Reddit redesign is really good and you want to make a website that
works exactly like that, the React community is a good place to start.

But one of the main benefits of using React that I've heard about is that it
forces all the members of a development team to organize (certain parts of)
their code the same way. This isn't really an issue on personal projects.
Personally, I spent about a year working with React for a job, but I continue
to write vanilla JavaScript on my own time.

(You can learn other frameworks than React, but React is a good starting point
because it's the most popular one. Then you can learn about Framework X by
reading "how is Framework X different from React" articles online.)

~~~
Wowfunhappy
> if you think the Reddit redesign is really good

Conversely, if I think the reddit redesign is horrible, I guess I should stay
well away? ;)

------
alan_n
I thought this was going to scroll up to each heading and stop scrolling if
you touched the screen. Now that would have been useful. Otherwise I tend to
hate scroll to top buttons. I'm always accidentally touching them and usually
they won't stop till you're at the top. It's terrible.

------
rosstex
I was hoping for a Koyaanisqatsi-esque visual interlude as the page scrolled
back up, but this is still satisfying.

------
enriquto
In a few years mankind will "discover" the scroll bar and the inventor will be
hailed a hero.

~~~
hathym
and few years later they will re-discover the Home keyboard key.

------
codetrotter
I thought “behaves like a real elevator” meant that it would make stops along
the way. Oh well ¯\\_(ツ)_/¯

------
carlhjerpe
Nobody went through source and noticed the Dalek hiding in the comments? Made
my day.

~~~
retpirato
I did.

------
mysterydip
This is so useful and silly I love it. Would have been perfect for my late 90s
geocities site, had the functionality existed back then.

------
LordFast
Scrolling back to top like an animal? No thanks, I just refresh the page
instead as a civilized person would do.

~~~
just-ok
Which only works if haven’t hit any in-page anchor links ;) otherwise, you’d
snap right back to a particular section after a refresh.

------
zanderwohl
This gave me a good laugh. Great project.

------
retpirato
Is there any way to make this work as a bookmarklet that I could just click to
use on any site?

=== On a side note: There is an alternative to this that does far more. Vimium
is available
at:[https://chrome.google.com/webstore/detail/vimium/dbepggeogba...](https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb)
It's based on Vim commands so It helps if you have some familiarity with that.
It allows you to perform all basic features you would use in a web browser,
like scrolling, refresh, forward/back etc; using only keystrokes.

------
sv3k
I don't like "back to top" buttons because they take visible space and could
be anywhere (if any) depending on the website. I don't like Cmd+Up keystrokes
either on my mac.

Instead, it would be great to have something:

\- That works on any website

\- That can scroll to top, to bottom, _and back_ to the place where you've
scrolled from.

\- Doesn't alter the websites appearance.

So I've created a tiny Chrome extension that solves all of this:
[https://github.com/sv3k/topscroll](https://github.com/sv3k/topscroll)

After some time, you get used to it on reflexes level.

~~~
retpirato
vimium does that & a lot more.

------
andai
Had my volume turned up, Christ this nearly gave me a heart attack.

------
mafriese
There is a bug when it's finished and you instantly scroll down and press the
button again that it then won't play the arrive sound if it arrives.

------
Wowfunhappy
We need a “ding!” sound effect when you get to the top!

~~~
disillusioned
It does?

~~~
Wowfunhappy
Huh, that didn’t play on my iPhone. The music just stops.

------
rglover
That was charming. Always a fan of little doodles like this that are
completely unnecessary but you're glad they exist.

------
nsarafa
Made me laugh! Would be way more awesome if gates closed above the page like
an old school elevator before it went back up

------
wtvanhest
Clever, really is a better experience. I’d love to see this used more. I
haven’t seen anything like this in a long-time.

------
numlock86
Can we just go back to buttons that _jump_ straight to the top instead of
scrolling? Please?

What problem is this even trying to solve?

~~~
fbnlsr
That's what I did on my blog [1]. I tried different methods and realized that
it should be a simple link that jumps you straight to the top and nothing
fancy. The only JavaScript used it to determine when to display the link.

[1] [https://www.primative.net/blog/how-to-get-rid-of-the-
flash-o...](https://www.primative.net/blog/how-to-get-rid-of-the-flash-of-
unstyled-content/)

------
joe_momma
I expected a few stops along the way

------
ara24
Don't use it in case of a fire

------
infogulch
I prefer rockets to elevators:
[https://factorio.com/blog/post/fff-353](https://factorio.com/blog/post/fff-353)

------
nielsbot
What, no closing doors? ("The little lights, they’re not twinkling.")

------
genezeta
Just in case author reads this...

Movement is _janky_ on latest Firefox on Win10, 4K screen. I don't know if
that matters much, but I'll leave it here just in case you actually wanted
feedback.

------
rgoulter
"Elevator" and "JS" reminds me of Elevator Saga.
[https://play.elevatorsaga.com/](https://play.elevatorsaga.com/)

~~~
volkanvardar
I was about to write the same thing. The perfect puzzle for a programmer.

------
sideproject
Hahaha. Nice one. As soon as the muzak came on, I had to chuckle. :)

------
t0astbread
I'm on mobile, does this framework at least disable the home button? I would
consider that a must-have for elevator frameworks.

------
OakNinja
Feedback: The back to to top button gets obscured by the navigation keys on
iPhone. Also, the page would benefit from a more fitting viewport on small
devices.

------
firasd
For those that don't know: on iPhone, touching the top (like near the front
facing camera) works like a jump to top button in many contexts.

------
dellinspiron
A real elevator would have stopped at each level.

------
jaekash
Wow that button is like a portal straight to hell, well done I guess. Most
soul destroying thing I have yet encountered.

------
notfound404
Just wondering, is it possible to add a global 'back to top' button on mobile？
Shall the browser implement it?

------
SoylentOrange
This is so pointless I absolutely love it

------
Romanulus
Implement this on infinite scrolling sites with sounds of crying and
screaming, then we're talkin'.

------
XCSme
I expected it to stop at each floor. :(

~~~
neop1x
Not enough procrastination already?

------
gnarbarian
I love stupid fun stuff like this.

------
noodlesUK
And here I was thinking that websites didn’t play sound without a nag prompt
on iOS...

------
globular-toast
Ugh, I thought I had tabs muted by default in my browser... Clearly I was
mistaken. Turns out I need an extension for it. But now I have ugly mute
symbols on every single tab which isn't "default" at all. What I want is sound
symbols on tabs that I have expressly un-muted.

~~~
jaifraic
With Chromium based browsers you should be able to set every website to be
muted at first. You'll only see a mute symbol on the tab when the tab tries to
play sound.

If there is no sound at all, there shouldn't be an icon.

~~~
globular-toast
That does sound like what I want. This is the first time I've heard of a
compelling reason to use Chromium over Firefox. Hope I can find a decent
solution for Firefox.

------
duxup
This both absurd....and seems more natural than most browser experiences...

------
aabbcc1241
That's the point of this library ?

It scroll up slowing, harmful to my eyes. I'd rather "teleport to the top" or
quickly scroll to top on my own than watching the animation…

And I cannot cancel the scrolling in the middle of process if I accidentally
click it.

~~~
anonytrary
He did it for fun. From the Github:

> Finally, a "back to top" button that behaves like a real elevator, by adding
> elevator music to quietly soothe the awkwardness that can ensue when being
> smoothly scrolled to the top of the screen. This is very serious stuff,
> here's a demo!

~~~
aabbcc1241
I missed the music! This is awesome

------
_theory_
Gosh, I could press that button all day.

------
realYitzi
wow. When I have the time I'll have to add a janky gate that closes but you
can still see the text passing by.

Can also be a bit bumpy when it passes "floors".

------
Nebasuke
Cute, but the movement actually made me feel nauseous.

------
rickyplouis
If this were a chrome extension, I'd be down.

------
keyle
That's fun. Take that infinite scrolling pages!

------
Sodman
I love the Dalek Easter Egg in the js source code

------
Tade0
Growing up in a post-communist country I have very different expectations
regarding how an elevator operates, namely that instead of a smooth start/stop
it should have two speeds - the slower used for stopping exclusively.

------
baybatu
I have just found a website for author: [https://www.usa.gov/find-a-
job](https://www.usa.gov/find-a-job)

------
Gigablah
The demo page needs a lot more floors.

------
INTPenis
Could have done without the music in a coffee shop right now. :)

I normally always have my laptop on mute, because I'm paranoid about bothering
people.

~~~
dfee
I think the music was the punchline.

------
vishwajeetv
This is fun, but on the serious note, we should not be modifying the scroll
behaviour of the browser in any way. It is not as usable.

~~~
anonytrary
It's not a bad argument. Similarly, I think everyday life would also be
confusing if the laws of physics changed depending on what restaurant you
walked into.

------
arrayjumper
Now we need a go to bottom button.

------
beshrkayali
Playing music is a terrible idea.

~~~
dfee
That’s the punchline.

------
djohnston
I love it!

------
ybbond
sound alert really needed there.

I was shocked, but that was a fun one, I laughed too.

------
baylearn
Thanks, you made my day.

------
visarga
with fucking music, I wasn't prepared for that

~~~
mhd
Well, I just clicked the link to see if this also includes the Girl from
Ipanema…

------
sidcool
This is entertaining. HN continues to pleasantly surprise me.

------
raobit
nice tune though while going to top !!

------
raobit
nice tune though while going to top

------
jimmykang1016
scared the beejesus out of me haha

------
pikuseru
double tap the status bar on iOS

------
QuadrupleA
Cute gag, but why is this top story? Not that there's anything wrong with
/r/ProgrammerHumor but I go to HN for different reasons.

~~~
trevordixon
Because a few hundred people upvoted it over the last few hours. That I know
for sure, though I can't speak to their reasons for visiting HN in the first
place.

