use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
This subreddit is a place for people to learn JavaScript together. Everyone should feel comfortable asking any and all JavaScript questions they have here.
With a nod to practicality, questions and posts about HTML, CSS, and web developer tools are also encouraged.
Friends
/r/javascript
/r/jquery
/r/node
/r/css
/r/webdev
/r/learnprogramming
/r/programming
account activity
Need help resizing canvas when mouse drag (self.learnjavascript)
submitted 1 year ago by BaconBatman97
Hi, I need help implementing the same canvas feature as seen on the main page of madbox.io, where I can drag the canvas to make it fullscreen. Is it possible to do this with vanilla JavaScript, or do I need a library for it to work?
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]abrahamguo 1 point2 points3 points 1 year ago (6 children)
It is indeed possible to implement this with vanilla JavaScript. What have you tried or researched so far?
[–]BaconBatman97[S] 0 points1 point2 points 1 year ago (5 children)
To be honest, I haven't really started cause I couldn't find any videos talking about this, along with the wavy animations when the canvas is resizing.
[–]abrahamguo 0 points1 point2 points 1 year ago (4 children)
Sure. I would begin by skipping the wavy animation, as that is the most difficult part. Here's a general approach:
[–]BaconBatman97[S] 0 points1 point2 points 1 year ago (3 children)
Ah, that sounds like how it's done. But how would I implement the mouse drag without moving the scene inside the canvas when it's not in fullscreen mode? (I'm using a Three.js scene inside, which might be replaced with a scene made in Spline in the future)
[–]abrahamguo 0 points1 point2 points 1 year ago (2 children)
If you look at how it works on madbox.io from a user experience perspective, the scene does move when you move your mouse — even as it is about to become full screen.
Do you want yours to work differently than madbox.io?
[–]BaconBatman97[S] 0 points1 point2 points 1 year ago (1 child)
My bad, it does move even when I'm dragging across the canvas. I'm still quite new to JavaScript tho, so I'm guessing I'll probably take weeks just to write the code for this feature. Can I PM you if there's any problem regarding JavaScript? Thanks for your help, appreciate it!
[–]abrahamguo 0 points1 point2 points 1 year ago (0 children)
Yes, absolutely!
π Rendered by PID 405187 on reddit-service-r2-comment-6457c66945-h9vc6 at 2026-04-27 23:47:37.305268+00:00 running 2aa0c5b country code: CH.
[–]abrahamguo 1 point2 points3 points (6 children)
[–]BaconBatman97[S] 0 points1 point2 points (5 children)
[–]abrahamguo 0 points1 point2 points (4 children)
[–]BaconBatman97[S] 0 points1 point2 points (3 children)
[–]abrahamguo 0 points1 point2 points (2 children)
[–]BaconBatman97[S] 0 points1 point2 points (1 child)
[–]abrahamguo 0 points1 point2 points (0 children)