Skip to content

Commit

Permalink
✨ slider support steps/precision
Browse files Browse the repository at this point in the history
  • Loading branch information
zhzLuke96 committed May 28, 2024
1 parent 2cf6baa commit 746f135
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@litegraph-ts/core",
"version": "0.2.22",
"version": "0.2.23",
"description": "A graph node editor similar to PD or UDK Blueprints. It works in an HTML5 Canvas and allows to export graphs to be included in applications.",
"source": "src/index.ts",
"types": "src/index.ts",
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/LGraphCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2070,6 +2070,7 @@ export default class LGraphCanvas
case "slider": {
const { max, min, step, precision } = w.options;
var range = max - min;
var old_value = w.value;

const calculateValue = (rawValue) => {
if (typeof step === "number" && step > 0) {
Expand All @@ -2085,7 +2086,7 @@ export default class LGraphCanvas
var raw_value = min + range * nvalue;
w.value = calculateValue(raw_value);

if (w.callback) {
if (old_value != w.value) {
setTimeout(function () {
inner_value_change(w, w.value);
}, 20);
Expand Down

0 comments on commit 746f135

Please sign in to comment.