Utilities » Platform detection
Platform detection
With the following eight utilities, you can detect which in browser your prototype is running and whether it’s on a desktop, tablet, or phone.
They all return true
when something is a fact, and false
when it’s not.
In Framer, for instance, you will have these results for isWebKit()
, isChrome()
, and isSafari()
:
print Utils.isWebKit()
» true
print Utils.isChrome()
» false
print Utils.isSafari()
» false
Because Framer’s Preview Window is a WebKit browser, but neither Chrome nor Safari.
Utils.isWebKit()
— WebKit browserUtils.isChrome()
— Chrome browserUtils.isSafari()
— Safari browserUtils.isTouch()
— Touch-enabled browserUtils.isDesktop()
— Desktop browserUtils.isPhone()
— Phone deviceUtils.isTablet()
— Tablet deviceUtils.isMobile()
— Mobile device (phone or tablet)
Platform detection example
In this example project there’s code like the lines below for each of these eight utilities:
if Utils.isWebKit()
blue_dots[0].animate "active"
…
So that when something is true
, the blue dot is made visible.