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 browser
  • Utils.isChrome() — Chrome browser
  • Utils.isSafari() — Safari browser
  • Utils.isTouch() — Touch-enabled browser
  • Utils.isDesktop() — Desktop browser
  • Utils.isPhone() — Phone device
  • Utils.isTablet() — Tablet device
  • Utils.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.

Platform detection example
Framer is ‘WebKit’ and ‘Desktop’
Download Framer project