Loading...
(function(){<br />
let canvas = document.createElement('canvas'),<br />
ctx = canvas.getContext('2d'),<br />
w = canvas.width = innerWidth,<br />
h = canvas.height = innerHeight,<br />
particles = [],<br />
properties = {<br />
bgColor : 'rgba(17, 17, 19, 1)',<br />
particleColor : 'rgba(255, 40, 40, 1)',<br />
particleRadius : 3,<br />
particleCount : 60,<br />
particleMaxVelocity : 0.5,<br />
lineLength : 150,<br />
particleLife : 6,<br />
};<br />
<br />
document.querySelector('body').appendChild(canvas);<br />
<br />
window.onresize = function() {<br />
w = canvas.width = innerWidth;<br />
h = canvas.height = innerHeight;<br />
}<br />
<br />
class Particle {<br />
constructor() {<br />
this.x = Math.random()*w;<br />Loading...
To determine whether a user is accessing the site from a mobile device, you can use the following function:
1function mobileDetect() {2 if (/Android|webOS|iPhone|iPad|iPod|BlackBerry|BB|PlayBook|IEMobile|Windows Phone|Kindle|Silk|Opera Mini/i3 .test(window.navigator.userAgent)) {4 return true;5 } else return false;6}
If you specifically need to detect whether the user is using an iOS device (iPhone, iPad, or iPod), you can use:
1function iOS() {2 return (3 [4 'iPad Simulator',5 'iPhone Simulator',6 'iPod Simulator',7 'iPad',8 'iPhone',9 'iPod',10 ].includes(navigator.platform) ||11 // iPad on iOS 13 detection12 (navigator.userAgent.includes('Mac') && 'ontouchend' in document)13 );14}