Hello again. How can I make an object draggable only vertically?
You can add a bit of code to keep forcing x to a certain value, eg remix this project then look at the javascript interaction on the square.
You can use a similar approach to keep an element within a certain area, eg this.y = Math.max(this.y, 0);
would stop it going off the top of the page
1 Like