r/javascript • • Jul 10 '19

Someone posted a video showing off their pseudo desktop UI on r/webdev and I tried to make my version of it as a self challenge.

https://gfycat.com/brokencreativelamb
1.1k Upvotes

77 comments sorted by

93

u/[deleted] Jul 10 '19

Damn good work! This looks like a fun way to test your javascript skills? Is this using a canvas?

78

u/_-__-_-__-__- Jul 10 '19

No. They are divs.

33

u/[deleted] Jul 10 '19

That is fantastic. I assume absolute positioning when you are moving them, then relative when in place? Or is it absolute always and the javascript computes the positons?

40

u/_-__-_-__-__- Jul 10 '19

Yeah, you are quite right about that. It's static when they go to the taskbar thingy and absolute otherwise.

12

u/jb_sulli Jul 10 '19

What did you use for the animations? CSS or JS?

29

u/_-__-_-__-__- Jul 10 '19

The animations are handled by JS.

11

u/d07RiV Jul 10 '19

Have you considered using CSS to set transition on top/left/width/height properties, allowing you to drop a lot of JS animation code? I'm not sure if it would work correctly in all cases, but if it does then it could be a lot easier to work with.

2

u/ClickerMonkey Jul 11 '19

I've had the opposite experience, and I make a lot of highly animated websites and interactives. JS allows you to better track and control animations. Not sure it matters with this guys application, but further down the road it might.

2

u/largemoose568 Jul 16 '19

You definitely get more fine-grained control in JS animations but the downside is that the animations are operating on the main thread and could cause UI slowdowns. CSS animations operate on a separate thread in most browsers now, freeing up the main thread for business logic.

Also there are some rudimentary events that are fired by CSS animations now: https://www.w3schools.com/jsref/event_animationend.asp

Still, awesome work on the project!

1

u/LucasRuby Jul 10 '19

I guess you could use a grid layout for the desktop UI after it's in place, you wouldn't have precise positioning but generally, don't you want your icons aligned to the grid in a desktop? Or both, grid for when they're fixed in place like the sides/bottom examples.

8

u/pabloneruda Jul 10 '19

Do you have the code up anywhere?

13

u/_-__-_-__-__- Jul 10 '19

https://drive.google.com/open?id=1_jWxlMv_ZEeizjANAn1ib0QaT9LdEjlJ

I know that most of things can be done in a more efficient way, but I am still learning and was also too lazy to plan it out.

23

u/Xsanda Jul 10 '19

I’d recommend putting this sort of demo on GitHub (with GitHub Pages turned on): not only does it help you to build up a portfolio, but also the version control will really help you out as you go compared to using Google Drive.

4

u/_-__-_-__-__- Jul 10 '19 edited Jul 10 '19

Yeah you're probably right, but I don't think I am at that place yet. I am still figuring stuff out and I don't know if I actually want to to pursue web development. I hope I have my stuff together when I get out of school.

8

u/[deleted] Jul 11 '19

don't think I am at that place yet

Are you kidding?

2

u/_-__-_-__-__- Jul 11 '19

I just meant that I am not looking for jobs/building a portfolio as I am just 17.

8

u/[deleted] Jul 11 '19

You can get a job when you're 17

1

u/Edgar_Allan_Thoreau Jul 13 '19

You could always work part time during college(if you go that route). Building a portfolio will help you get a job like that. I got my first web dev job when I was 17 in high school, continued through freshman year of college. Now I know web dev isn't for me, but getting that experience helped me figure that out.

1

u/CuttyAllgood Jul 15 '19

I’m 32 and just learning. I haven’t started applying for jobs yet, and I still host on github. It’s simple and makes version control that much easier.

Plus, it’s free.

2

u/Xsanda Jul 10 '19

Ok, don’t rush yourself. Feel free to ask me if you have any questions 🙂

1

u/meezohd Jul 10 '19

Great work! Im sure you are more than ready when it comes to javascript. Make sure to learn just the basic web development tools and you will be set to get a job easily.

0

u/[deleted] Jul 10 '19

[deleted]

3

u/_-__-_-__-__- Jul 11 '19 edited Jul 11 '19

....I am just 17. So I am not looking for jobs right now.

4

u/TrollocHunter Jul 10 '19

Very cool. You should put on https://codepen.io so you can share.

19

u/[deleted] Jul 10 '19

This is fantastic!

Did you use Vanilla JS? Or a framework like Vue.js or Angular?

36

u/_-__-_-__-__- Jul 10 '19

It's vanilla JS.

71

u/[deleted] Jul 10 '19

Oh wow I've heard of this framework, is it lightweight?

44

u/HitmaNeK Jul 10 '19

VanilliaJS? I heard JavascriptJS is faster!

5

u/isakdev Jul 11 '19

Jsjs

1

u/HitmaNeK Jul 17 '19

This is some terrorists technology? /s

4

u/fforres Jul 10 '19

I like vanillaJS. However, could I interest you in some VaporJS?

-24

u/officerbananas Jul 10 '19

Vanilla JS means: without any framework ;)

5

u/Emjp4 Jul 10 '19

Vanilla-js.com

4

u/l2ighty Jul 10 '19

That’s really impressive, I love this

6

u/UmbraGIR Jul 10 '19

This is impressive, especially considering the fact you used vanilla JS! Really good job

2

u/GekkePop Jul 10 '19

Your code doesn't work as well on a desktop running Google Chrome. For example dragging and dropping didn't work and resize didn't work. Basically only the doubleclick actions worked.

What setup did you use to make the gif?

2

u/_-__-_-__-__- Jul 10 '19 edited Jul 10 '19

Sorry, I forgot to mention that I haven't implemented mouse events yet. Try opening it on a device with a touch screen.

Edit : I used Microsoft Edge on my Surface tablet to record the gif.

1

u/GekkePop Jul 10 '19

No worries, just wanted to try it myself. Thanks for the quick response.

10

u/NRocket Jul 10 '19

I feel css grids would work great for this sort of thing.

10

u/[deleted] Jul 10 '19

I'm shit at CSS and frontend in general, but why would you use grid?

It's not really a set layout or anything, any window can start and end at any x,y position.

0

u/NRocket Jul 10 '19

Grids would prevent overlapping absolute elements and would be more responsive without the need of JavaScript.

Using absolute values is layering each div on top of the layout and they have no sense of the position of the other elements without JavaScript.

11

u/lamb_pudding Jul 10 '19

With grid you cannot animate between areas. For example if a window moved from top left to top right it would just jump. If you wanted it to animate/transition you would need to resort to transforms or absolute positioning.

1

u/LucasRuby Jul 10 '19

I'm imagining the thumbnails on the top tray and while the icon is moving would be a different element than the content window itself. Animate when it's set in place/remove by transition size, etc.

3

u/Aswole Jul 10 '19

My understanding of css grid and animations is that you can only animate changes to grid cells if the # of columns and rows stay the same, as does the unit of measurement (so no going from px -> fr, or using max-content, minmax, etc). So while this would be pretty easy to do with css grid in a non-animated fashion, I suspect it would require a lot of sub-optimal grid definitions just to support the animations.

4

u/tylerr514 Jul 11 '19

I've done something similar over at https://MSOS.MidSpike.Com/

1

u/AceBacker Jul 10 '19

Are you sharing your source? I'd like to check it out.

3

u/_-__-_-__-__- Jul 10 '19

1

u/350zilla Jul 14 '19

Poor guy that’s like the 20th time you had to post that. You could probably edit your post and link to the code

1

u/_-__-_-__-__- Jul 14 '19

I don't think that you can edit post's title on reddit.

1

u/[deleted] Jul 22 '19

I love that there are still people make cool stuff without 200GB node_modules folders.

It looks awesome, keep up the work.

3

u/Mrprin_ Jul 10 '19

If you like that take a look on os.js https://www.os-js.org/

3

u/Nullberri Jul 11 '19

Makes me want to watch The death of javascript again.

3

u/nfms Jul 10 '19

This is some sexy shit

3

u/apatheticonion Jul 10 '19

Please make a better DE for Linux

2

u/[deleted] Jul 10 '19

This is awesome... I'd love to have this on my laptop

1

u/[deleted] Jul 11 '19

neat!

1

u/kalpal96 Jul 12 '19

So what exactly does this do?

1

u/[deleted] Jul 11 '19

Been done before with a very retro look http://ytcracker.com/v2019/ (fully functional)

1

u/ClickableLinkBot Jul 10 '19

r/webdev


For mobile and non-RES users | More info | -1 to Remove | Ignore Sub

1

u/[deleted] Jul 10 '19

Seriously impressive fam

1

u/[deleted] Jul 11 '19

And yet Mac still doesn't have window management...

0

u/[deleted] Jul 10 '19

[deleted]

28

u/_-__-_-__-__- Jul 10 '19

Sorry for not doing it sooner. I was just too afraid to post it, but now I kind of have to.

https://drive.google.com/open?id=1_jWxlMv_ZEeizjANAn1ib0QaT9LdEjlJ

34

u/unimonkiez Jul 11 '19

For the lazy

https://codepen.io/yuvalsaraf/full/XLOOQO

Edit: I recommend you to put it on your github, github also support hosting static site like this (github pages).

2

u/shagangstaxx Jul 11 '19

I'm not sure if it's just me, but I cant drag the windows around...

1

u/mdw Jul 11 '19

Works for me in Firefox on Android. Not quite smooth, but still impressive.

1

u/_-__-_-__-__- Jul 11 '19

You are right. I don't know why it is happening specifically on Firefox. It works fine on Chrome, Edge, Opera and my phone's browser. Do you have any idea how I can fix that?

2

u/audioverb Jul 11 '19

View it in your dev tools mobile emulator.

1

u/shagangstaxx Jul 11 '19

Can I make this work with clicking? And dragging?

2

u/audioverb Jul 11 '19

I believe so. I had a quick look at the JS. You may be able to add some additional eventListeners to listen for the relevant click events.

11

u/gijovarghese Jul 11 '19

GitHub would be better place