Detecting the start of a scroll

Is there any way to detect the start of a scroll in p5? I want just the start of the scroll. The mouseWheel event doesn’t seem to help.

I don’t understand exactly what you want; maybe you can detail it a bit more.
As a start:

let pos = 25;
let start_time = 0; 


function setup() {
  createCanvas(100, 500) 
}

function draw() {
  var bg = 0;
  if (millis() - start_time > 200) bg = 200;
  background(bg);
  if (pos < 25) pos = 25;
  if (pos > 450) pos = 425;
  rect(25, pos, 50, 50);
}

function mouseWheel(event) {
  pos += event.delta;
  start_time = millis();
}
1 Like