Skip to content
Kerri Shotts edited this page Apr 5, 2014 · 1 revision

(part of device)

Parameters:

  • None

Returns: tablet or phone

Returns the device's form factor. The following form factors are returned: tablet and phone. This is based on navigator.platform and navigator.userAgent. If no form factor can be determined, the width of the screen is used -- phone is for any screen width less than 1024px, and 'tablet' is used otherwise.

Note: if formFactorOverride is any value other than false, that value is returned instead.

Usage

if (_y.device.formFactor() === "tablet") {
  // do tablet-specific code
} else
{ // phone screen-size code
}
Clone this wiki locally