From 9eebf989b2c6b01b6915ac1f896ac7a995d55db6 Mon Sep 17 00:00:00 2001 From: guy Date: Mon, 24 Oct 2022 15:12:34 +0800 Subject: [PATCH] update --- examples/useContext.html | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/examples/useContext.html b/examples/useContext.html index 723152250..4f91239bd 100644 --- a/examples/useContext.html +++ b/examples/useContext.html @@ -56,7 +56,20 @@ return "calc(var(--css-scale) * " + pix + "px)"; }; - BI.toPix = BI.pixFormat; + var oldPix = BI.toPix; + BI.toPix = function (pix, border) { + var context = BI.useContext("cssScale"); + if (!context) { + return oldPix.apply(this, arguments); + } + if (!BI.isNumber(pix)) { + return pix; + } + if (border > 0) { + return "calc(var(--css-scale) * " + pix + "px" + " - " + border + "px"+")"; + } + return "calc(var(--css-scale) * " + pix + "px)"; + }; var Child = BI.inherit(BI.Widget, { render: function () {