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

**URL:** https://discourse.processing.org/t/javascript-library-on-p5-location-on-the-screen-while-scrolling/13300
**Category:** Libraries
**Created:** [August 10, 2019, 11:04pm UTC](https://discourse.processing.org/t/javascript-library-on-p5-location-on-the-screen-while-scrolling/13300 "2019-08-10T23:04:17Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![jeremydouglass](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/jeremydouglass/32/20_2.png) [@jeremydouglass](https://discourse.processing.org/u/jeremydouglass)
#### Post date: [August 12, 2019, 7:35pm UTC](https://discourse.processing.org/t/javascript-library-on-p5-location-on-the-screen-while-scrolling/13300/2 "2019-08-12T19:35:10Z")

</div>

> [@calornorte](#):
>
> MouseWheel doesn’t really do the job and might cause problems when the wheel is configured inverted,

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:

```auto
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:

> [@\[Processing 3\] Moving through a map bigger than the screen](https://discourse.processing.org/t/processing-3-moving-through-a-map-bigger-than-the-screen/10393/4):
>
> Do you actually have a 1024x15669 image file, like a jpg, that you are loading and want to scroll? Or is it many tiles, or are you generating the background image dynamically inside your sketch…? Here is a very very simple example of a vertical scroller written in PDE (not Eclipse). It demonstrates using translate and the coordinate system to keep track of where you are, then check collision with the viewframe to decide what to render (e.g. only part of a very large graphic, or only certain ti…

---

_[View the full topic](https://discourse.processing.org/t/javascript-library-on-p5-location-on-the-screen-while-scrolling/13300)._
