UNPKG

@tamagui/react-native-web-lite

Version:
101 lines (100 loc) 3.79 kB
"use strict"; var __create = Object.create; var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __getProtoOf = Object.getPrototypeOf, __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: !0 }); }, __copyProps = (to, from, except, desc) => { if (from && typeof from == "object" || typeof from == "function") for (let key of __getOwnPropNames(from)) !__hasOwnProp.call(to, key) && key !== except && __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); return to; }; var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps( // If the importer is in node compatibility mode or this is not an ESM // file that has been converted to a CommonJS file using a Babel- // compatible transform (i.e. "__esModule" has not been set), then set // "default" to the CommonJS "module.exports" for node compatibility. isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: !0 }) : target, mod )), __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: !0 }), mod); var PixelRatio_exports = {}; __export(PixelRatio_exports, { default: () => PixelRatio }); module.exports = __toCommonJS(PixelRatio_exports); var import_Dimensions = __toESM(require("../Dimensions/index")); function _class_call_check(instance, Constructor) { if (!(instance instanceof Constructor)) throw new TypeError("Cannot call a class as a function"); } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || !1, descriptor.configurable = !0, "value" in descriptor && (descriptor.writable = !0), Object.defineProperty(target, descriptor.key, descriptor); } } function _create_class(Constructor, protoProps, staticProps) { return protoProps && _defineProperties(Constructor.prototype, protoProps), staticProps && _defineProperties(Constructor, staticProps), Constructor; } var PixelRatio = /* @__PURE__ */ function() { "use strict"; function PixelRatio2() { _class_call_check(this, PixelRatio2); } return _create_class(PixelRatio2, null, [ { key: "get", value: ( /** * Returns the device pixel density. */ function() { return import_Dimensions.default.get("window").scale; } ) }, { key: "getFontScale", value: ( /** * No equivalent for Web */ function() { return import_Dimensions.default.get("window").fontScale || PixelRatio2.get(); } ) }, { key: "getPixelSizeForLayoutSize", value: ( /** * Converts a layout size (dp) to pixel size (px). * Guaranteed to return an integer number. */ function(layoutSize) { return Math.round(layoutSize * PixelRatio2.get()); } ) }, { key: "roundToNearestPixel", value: ( /** * Rounds a layout size (dp) to the nearest layout size that corresponds to * an integer number of pixels. For example, on a device with a PixelRatio * of 3, `PixelRatio.roundToNearestPixel(8.4) = 8.33`, which corresponds to * exactly (8.33 * 3) = 25 pixels. */ function(layoutSize) { var ratio = PixelRatio2.get(); return Math.round(layoutSize * ratio) / ratio; } ) } ]), PixelRatio2; }(); //# sourceMappingURL=index.js.map