Skip to content

Commit 3751326

Browse files
committed
Do not fire callback on change
1 parent 1d38a24 commit 3751326

File tree

8 files changed

+20
-28
lines changed

8 files changed

+20
-28
lines changed

example/plot.js renamed to example/example.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,35 +2,31 @@ const logValueInput = document.getElementById('log-value-input');
22
const logScaleInput = document.getElementById('log-scale-input');
33
const linearValueInput = document.getElementById('linear-scale-input');
44

5-
const handleDemoLogUpdate = (log, value) => {
6-
logValueInput.value = log.toFixed(3);
7-
logScaleInput.value = value;
8-
};
9-
105
const demoLog = new LogSlider({
116
id: 'log-scale',
12-
callback: handleDemoLogUpdate,
13-
});
14-
15-
const handleDemoLinearUpdate = (value) => {
16-
linearValueInput.value = value;
17-
};
18-
19-
const demoLinear = new LogSlider({
20-
id: 'linear-scale',
21-
callback: handleDemoLinearUpdate,
7+
callback: (log, value) => {
8+
logValueInput.value = log.toFixed(2);
9+
logScaleInput.value = value;
10+
},
2211
});
2312

2413
logScaleInput.value = demoLog.inputValue;
2514
logScaleInput.addEventListener('change', function() {
2615
demoLog.inputValue = Number(this.value);
2716
});
2817

29-
logValueInput.value = demoLog.value.toFixed(3);
18+
logValueInput.value = demoLog.value.toFixed(2);
3019
logValueInput.addEventListener('change', function() {
3120
demoLog.value = Number(this.value);
3221
});
3322

23+
const demoLinear = new LogSlider({
24+
id: 'linear-scale',
25+
callback: (value, inputValue) => {
26+
linearValueInput.value = value;
27+
},
28+
});
29+
3430
linearValueInput.value = demoLinear.inputValue;
3531
linearValueInput.addEventListener('change', function() {
3632
demoLinear.inputValue = Number(this.value);

example/index.html

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030
</div>
3131
<div class="form-field">
3232
<label for="log-value-input">Log Value</label>
33-
<input type="number" id="log-value-input" min="100" max="10000"/>
33+
<input type="number" id="log-value-input" min="0.01" max="100" step="0.01"/>
3434
</div>
3535
</div>
3636
<div class="col-6 column">
@@ -48,12 +48,9 @@
4848
</div>
4949
<div class="form-field">
5050
<label for="linear-scale-input">Value</label>
51-
<input type="number" id="linear-scale-input" step="1" min="1" max="1000"/>
51+
<input type="number" id="linear-scale-input" step="0.1" min="0.1" max="10"/>
5252
</div>
5353
</div>
54-
<div class="col-12 column">
55-
<div id="plot"></div>
56-
</div>
5754
</div>
5855
</div>
5956
</div>
@@ -64,6 +61,6 @@
6461
</div>
6562
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
6663
<script src="log-slider.js"></script>
67-
<script src="plot.js"></script>
64+
<script src="example.js"></script>
6865
</body>
6966
</html>

example/log-slider.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

example/log-slider.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/log-slider.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/log-slider.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@orderandchaos/log-slider",
3-
"version": "3.0.4",
3+
"version": "3.0.5",
44
"description": "Wrapper class for initialising range slider with optional log scaling. ",
55
"main": "lib/log-slider.js",
66
"source": "src/slider.js",

src/log-slider.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,6 @@ class LogSlider {
191191
_handleChangeEvent() {
192192
this._snapToStep();
193193
this._updateTab();
194-
this._callback(this._result, this._input.value);
195194
}
196195

197196
_snapToStep() {

0 commit comments

Comments
 (0)