MCPcopy Create free account
hub / github.com/UI5/webcomponents / detectTablet

Function detectTablet

packages/base/src/Device.ts:125–160  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

123};
124
125const detectTablet = () => {
126 if (isSSR) {
127 return false;
128 }
129
130 if (tablet !== undefined) {
131 return;
132 }
133
134 if (internals.ipad) {
135 tablet = true;
136 return;
137 }
138
139 if (internals.touch) {
140 if (isWindows8OrAbove()) {
141 tablet = true;
142 return;
143 }
144
145 if (internals.chrome && internals.android) {
146 tablet = !/Mobile Safari\/[.0-9]+/.test(internals.userAgent);
147 return;
148 }
149
150 let densityFactor = window.devicePixelRatio ? window.devicePixelRatio : 1; // may be undefined in Windows Phone devices
151 if (internals.android && isWebkit537OrAbove()) {
152 densityFactor = 1;
153 }
154
155 tablet = (Math.min(window.screen.width / densityFactor, window.screen.height / densityFactor) >= 600);
156 return;
157 }
158
159 tablet = internals.userAgent.indexOf("Touch") !== -1 || (internals.android && !internals.androidPhone);
160};
161
162const supportsTouch = (): boolean => internals.touch;
163const isSafari = (): boolean => internals.safari;

Callers 2

_isPhoneFunction · 0.85
isTabletFunction · 0.85

Calls 2

isWindows8OrAboveFunction · 0.85
isWebkit537OrAboveFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…