DEV Community

Cover image for How to Create the Drawing Interaction on DEV's Offline Page

How to Create the Drawing Interaction on DEV's Offline Page

Ali Spittel on July 03, 2019

Since more and more people have been noticing DEV's offline page, I thought I would do a quick tutorial on how to replicate the code for it! Canv...
Collapse
 
dotnetcoreblog profile image
Jamie • Edited

I've always loved working with the canvas element. Back when I still wanted to be a games developer, it seemed like the quickest watly to make an (almost, because it was a few years ago) browser agnostic HTML5 game without having to rely on this party adons and plugins.

I even ended up writing a super simple game (which I called "Run Away") using it and vanilla javascript. I don't think that I have it hosted anywhere right now (I might fling it up on Netlify tonight), but the source code is available at my github. I'd love to see what folks think of it.

EDIT:

And it's live. You can now play the game over at Netlify.

One thing to note: it has support for touch (on mobile and tablets), but it doesn't use it. So you'll need to use a physical keyboard to play it.

tl;dr: run away from the scary monster. The further you run, the more fatigued you'll get. The longer you last, the hungrier (and faster) the monster gets.

Collapse
 
chriscoyier profile image
Chris Coyier

Interactive offline pages are the new funny 404 pages. 💜

Collapse
 
deadcoder0904 profile image
Akshay Kadam (A2K)

Holy cow. This is the first tutorial I've read of yours. You really explain things systematically. Cheers :)

Collapse
 
aspittel profile image
Ali Spittel

thank you so much!!!

Collapse
 
ben profile image
Ben Halpern

Seriously. Crushed this Ali 💪

Collapse
 
lauragift21 profile image
Gift Egwuenu

This is amazing Ali! I love the idea

Collapse
 
rhymes profile image
rhymes

Love this article, thanks!

Collapse
 
jeromehardaway profile image
Jerome Hardaway

Will be using this for our 404 page, kthanksbye.

Collapse
 
jeremy profile image
Jeremy Schuurmans • Edited

This is so cool! When my wifi cut out and I saw it the first time, I tried to learn how to code it but couldn't quite figure it out. Thank you for this! Also, I really like that you put your style into the design with the colors and everything. When I saw that page, before I noticed your initials at the bottom, I thought, "Hey, Ali made this."

Collapse
 
aaronpowell profile image
Aaron Powell
Collapse
 
rolandixor profile image
Roland Taylor

Found this lying around in the millions of tabs I have open on my phone - looking forward to diving in the near future. Seems pretty straightforward and is surprisingly easy to follow along to (for some reason I always figured working with the canvas would be complicated, so I never bothered).

Collapse
 
harken24 profile image
Jozo

Amazing job :)

Collapse
 
ankursheel profile image
Ankur Sheel
Collapse
 
voidjuneau profile image
Juneau Lim

Sweet lovely post. Thank you for the tip and wonderful examples!

Collapse
 
harrypham profile image
Harry Pham

Nice Page!

1 small feedback I have is "Should we add cursor:pointer for those color so user know they're clickable" :D

Collapse
 
harrypham profile image
Harry Pham • Edited

Hmm maybe I can make a pull request for that too :D

github.com/thepracticaldev/dev.to/...

Collapse
 
tallship profile image
Bradley D. Thornton

Great write up Ali :)

Collapse
 
sendilkumarn profile image
Sendil Kumar

Recreated this with Rust and WebAssembly :))))

dev.to/sendilkumarn/create-dev-s-o...

Collapse
 
emmabostian profile image
Emma Bostian ✨

Excuse me but this is FLIPPING COOL

Collapse
 
rishikc profile image
Rishi Kumar Chawda

Reminded me of an old high school project that I did one time. Makes me want to update that repo! Thanks @aspittel 😄 On a side note, You might also want to disable scroll on iOS when you try to draw.

Collapse
 
n8chz profile image
Lorraine Lee

Speaking of DEV offline page, I encountered this today (for the first time). Being pretty sure I was in fact connected, tried visiting in Chromium instead of Firefox and DEV operates normally.

Collapse
 
emmiep profile image
Emmie Päivärinta

I once tried doing something like that but with WebSockets (or maybe WebRTC) for collaborative drawing, it was a lot of fun, I should try to finish that project one day.

Collapse
 
threkk profile image
Alberto de Murga

How is this offline page triggered? I always have the feeling to end up there for absolutely the wrong reason, like go backwards and forwards in the browser or opening a tab in a container :(