# Issue with windowWidth under windowResize for mobile

**URL:** <https://discourse.processing.org/t/issue-with-windowwidth-under-windowresize-for-mobile/24621>\
**Category:** Beginners\
**Created:** [October 15, 2020, 3:55pm UTC](https://discourse.processing.org/t/issue-with-windowwidth-under-windowresize-for-mobile/24621 "2020-10-15T15:55:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![minirachel](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@minirachel](https://discourse.processing.org/u/minirachel)\
**Post date:** [October 15, 2020, 3:55pm UTC](https://discourse.processing.org/t/issue-with-windowwidth-under-windowresize-for-mobile/24621/1 "2020-10-15T15:55:01Z")

</div>

Hi, I’m having difficulty resizing a canvas while using instance mode on mobile view. It looks like the final width it lands on is 3x’s the starting width. I’ve included relevant code below ([view full published code here](https://www.haveyoutried.xyz/))

```auto
var sketch1 = function(o) {
o.setup = function(){
  let cnv = o.createCanvas(o.windowWidth,150);
  cnv.parent('output');
  cnv.style('z-index','2');
  cnv.style('display','block');
  cnv.background(224, 174, 224, .0);
      
  o.textFont("Righteous",36);
  o.textStyle(o.BOLD);
  o.textAlign (o.RIGHT, o.CENTER);
  o.fill('#DAF7A6');
  o.noLoop();
   
    }

o.windowResized = function(){
    o.resizeCanvas(o.windowWidth,150);
}
    
o.draw = function (){  
  o.background('#E0AEE0'); 
  let randomwords = o.random(words);
  o.text(randomwords,(o.windowWidth/2),75); 
    }

}

```

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [October 15, 2020, 4:16pm UTC](https://discourse.processing.org/t/issue-with-windowwidth-under-windowresize-for-mobile/24621/2 "2020-10-15T16:16:03Z")

</div>

> [@minirachel](#):
>
> `o.text(randomwords,(o.windowWidth/2),75);`

Why do you use _windowWidth_ there? Shouldn’t it be just _width_? 🤔  
`o.text(randomwords, o.width >> 1, 75);`

---

<div class="post-metadata">

**Author:** ![minirachel](https://avatars.discourse-cdn.com/v4/letter/m/e56c9b/32.png) [@minirachel](https://discourse.processing.org/u/minirachel)\
**Post date:** [October 16, 2020, 5:01pm UTC](https://discourse.processing.org/t/issue-with-windowwidth-under-windowresize-for-mobile/24621/3 "2020-10-16T17:01:42Z")

</div>

Sorry what does “\>\> 1” mean? I’m having trouble finding an explanation through a google search. When I replicated that line, it didn’t change anything in the width output.

I ended up resolving my issue by referencing a CSS container as the measurement, using **o.sketchWidth** in place of **o.windowWidth**

```auto
o.sketchWidth = document.getElementById("output").offsetWidth;

```
