Run p5js Sketches Fullscreen on a Mobile Device

- Posted in P5JS by

Agar layar browser otomatis fullscreen ketika mengakses P5JS, maka lakukanlah setingan berikut:
1. Tambahkan perintah berikut pada index.html

<meta name="viewport" content="width=device-width, user-scalable=yes, initial-scale=1, maximum-scale=1"/> 

2. Tambahkan perintah berikut pada sketch.js

function touchStarted () { 
  var fs = fullscreen(); 
  if (!fs) { 
    fullscreen(true); 
  } 
} 

/* full screening will change the size of the canvas */ 
function windowResized() { 
  resizeCanvas(windowWidth, windowHeight); 
} 

/* prevents the mobile browser from processing some default 
 * touch events, like swiping left for "back" or scrolling the page. 
 */ 
document.ontouchmove = function(event) { 
    event.preventDefault();
};