Javascript library on p5 (location on the screen while scrolling)

How does it “not do the job”? Can you say more about what you are trying to do? What specifically isn’t working, and what do you want to happen instead?

Also consider sharing code if you can, even if it is incomplete or broken.

Here is a labeled version of what is happening in the mouseWheel demo sketch:

let pos = 175;

function setup() {
  createCanvas(400, 400);
}

function draw() {
  background(237, 34, 93);
  fill(0);
  rect(175, pos, 50, 50);
  fill(255)
  text(pos, 190, pos+25);
}

function mouseWheel(event) {
  print(event.delta);
  pos += event.delta;
}

If you want scrolling content rather than a scrolling object, here is a related approach in Processing (not p5.js) that could be adapted:

2 Likes