Skip to content

Commit

Permalink
fix Overzealous rounding #12
Browse files Browse the repository at this point in the history
  • Loading branch information
Onixarts committed Mar 8, 2023
1 parent 5213f21 commit 5b66035
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
22 changes: 16 additions & 6 deletions mapper.html
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@

]
},
snapToGrid: {value: false}
snapToGrid: {value: false},
displayRoundedInput: {value: true}
},
inputs: 1,
outputs: 1,
Expand Down Expand Up @@ -241,7 +242,8 @@
if(rounding === -1)
rounding = 8

$('#editor-position-tooltip').css({left: target.x + 64, top: target.y + 128, opacity: .9}).html(`IN <input type="number" id="editor-x" value="${x.toFixed(rounding)}" ${xBlocked ? 'readonly' : ''}> OUT&nbsp;<input type="number" id="editor-y" value="${y.toFixed(rounding)}">`)
let displayRoundedInput = $("#node-input-displayRoundedInput").is(':checked')
$('#editor-position-tooltip').css({left: target.x + 64, top: target.y + 128, opacity: .9}).html(`IN <input type="number" id="editor-x" value="${displayRoundedInput ? x.toFixed(rounding): x}" ${xBlocked ? 'readonly' : ''}> OUT&nbsp;<input type="number" id="editor-y" value="${y.toFixed(rounding)}">`)
$('#editor-position-tooltip #editor-x').on('input', onKeyframeEditorChange)
$('#editor-position-tooltip #editor-y').on('input', onKeyframeEditorChange)
editedKeyframe = keyframe
Expand Down Expand Up @@ -410,7 +412,8 @@
if(rounding === -1)
rounding = 8

$('#editor-position-tooltip').css({left: posX + 48, top: posY + 128, opacity: .9}).html(`${x.toFixed(rounding)}, ${y.toFixed(rounding)}`)
let displayRoundedInput = $("#node-input-displayRoundedInput").is(':checked')
$('#editor-position-tooltip').css({left: posX + 48, top: posY + 128, opacity: .9}).html(`${displayRoundedInput ? x.toFixed(rounding) : x}, ${y.toFixed(rounding)}`)
}

function onMouseMove(e)
Expand Down Expand Up @@ -649,9 +652,15 @@
<input type="text" id="node-input-property">
</div>

<div class="form-row">
<input style="width: auto; display: inline-block; vertical-align: top;" type="checkbox" id="node-input-snapToGrid">
<label style="width: auto;" for="node-input-snapToGrid"> Snap to grid</label>
<div class="form-row" style="display: flex;">
<div>
<input style="width: auto; display: inline-block; vertical-align: top;" type="checkbox" id="node-input-snapToGrid">
<label style="width: auto;" for="node-input-snapToGrid"> Snap to grid</label>
</div>
<div style="margin-left: 32px;">
<input style="width: auto; display: inline-block; vertical-align: top;" type="checkbox" id="node-input-displayRoundedInput">
<label style="width: auto;" for="node-input-displayRoundedInput"> Display rounded input</label>
</div>
</div>

<div class="form-row preset-container">
Expand Down Expand Up @@ -731,4 +740,5 @@ <h3>Overview</h3>
You can also disable rounding.</p>
<p>The editor can be divided to a custom number of grid lines (dark edit controls).</p>
<p><b>Snap to grid</b> option will do a snapping when keyframe is being dragged</p>
<p><b>Display rounded input</b> option will round input value in a tooltip and a keyframe editor window</p>
</script>
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "node-red-contrib-visualmapper",
"description": "Maps input to output value with multiple editable sections and graphical editor.",
"version": "0.4.0",
"version": "0.5.0",
"main": "mapper.js",
"keywords": [
"node-red",
Expand Down

0 comments on commit 5b66035

Please sign in to comment.