wagerfield / parallax

Parallax Engine that reacts to the orientation of a smart device
http://wagerfield.github.io/parallax/
Other
16.5k stars 2.14k forks source link

Anyway to disable parallax only for Mobile Devices. #324

Closed Reubzz closed 7 months ago

Reubzz commented 1 year ago

I wanna basically have the parallax feature on Desktop only and not have it on Mobile devices. How do I go about that?

SRIMANKS commented 1 year ago

before intializing the scene you can just check whether the user is on a mobile device or not and conditionally run the Parallax contructor.

Reubzz commented 1 year ago

Yeah I figured that out and implemented this

reneroth commented 7 months ago

Just for future reference (and in case you don't want to use screen width), this is as of writing the code the library uses to check for mobile devices:

this.desktop = !navigator.userAgent.match(/(iPhone|iPod|iPad|Android|BlackBerry|BB10|mobi|tablet|opera mini|nexus 7)/i)
this.motionSupport = !!window.DeviceMotionEvent && !this.desktop

I know, I know, regex useragent matching...