diff --git a/package-lock.json b/package-lock.json index 514be56..63b82d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,6 +9,7 @@ "version": "0.1.0", "dependencies": { "@tauri-apps/api": "1.5.x", + "core-js": "^3.34.0", "lodash-es": "4.x", "vue": "3.x" }, @@ -1281,6 +1282,16 @@ "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==", "dev": true }, + "node_modules/core-js": { + "version": "3.34.0", + "resolved": "https://registry.npmjs.org/core-js/-/core-js-3.34.0.tgz", + "integrity": "sha512-aDdvlDder8QmY91H88GzNi9EtQi2TjvQhpCX6B1v/dAZHU1AuLgHvRh54RiOerpEhEW46Tkf+vgAViB/CWC0ag==", + "hasInstallScript": true, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/core-js" + } + }, "node_modules/cross-spawn": { "version": "7.0.3", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", diff --git a/package.json b/package.json index 10526bc..d25d97c 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,7 @@ }, "dependencies": { "@tauri-apps/api": "1.5.x", + "core-js": "^3.34.0", "lodash-es": "4.x", "vue": "3.x" }, diff --git a/src/components/FeatureSlider.vue b/src/components/FeatureSlider.vue index 58dbdfd..5545b49 100644 --- a/src/components/FeatureSlider.vue +++ b/src/components/FeatureSlider.vue @@ -65,7 +65,7 @@ export default defineComponent({ monitorManager.updateFeature( this.monitorId, this.featureName, - Math.max(0, Math.min(this.maximum, Math.round(current + offset * 0.01))), + Math.clamp(Math.round(current + offset * 0.01), 0, this.maximum), ); } }, diff --git a/src/main.ts b/src/main.ts index 19924b4..5cd59d3 100644 --- a/src/main.ts +++ b/src/main.ts @@ -3,6 +3,7 @@ import { watchThrottled } from "./watchers"; import monitorManager from "./monitor"; import BrightnessPanel from "./components/BrightnessPanel.vue"; import panelState from "./wm"; +import "./polyfill"; import "./style"; import "./style.global.sass"; diff --git a/src/polyfill.d.ts b/src/polyfill.d.ts new file mode 100644 index 0000000..3911f40 --- /dev/null +++ b/src/polyfill.d.ts @@ -0,0 +1,3 @@ +interface Math { + clamp(x: number, lower: number, upper: number): number; +} diff --git a/src/polyfill.js b/src/polyfill.js new file mode 100644 index 0000000..1e8596a --- /dev/null +++ b/src/polyfill.js @@ -0,0 +1 @@ +import "core-js/full/math/clamp";