diff --git a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/SliderRenderer.java b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/SliderRenderer.java index 8f8d02cadb..08347c5ca5 100644 --- a/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/SliderRenderer.java +++ b/bundles/org.openhab.ui.basic/src/main/java/org/openhab/ui/basic/internal/render/SliderRenderer.java @@ -83,6 +83,7 @@ public EList renderWidget(Widget w, StringBuilder sb, String sitemap) th snippet = preprocessSnippet(snippet, w); snippet = snippet.replace("%frequency%", frequency); + snippet = snippet.replace("%release_only%", s.isReleaseOnly() ? "true" : "flase"); snippet = snippet.replace("%switch%", s.isSwitchEnabled() ? "1" : "0"); snippet = snippet.replace("%unit%", unit == null ? "" : unit); snippet = snippet.replace("%minValue%", minValueOf(s)); diff --git a/bundles/org.openhab.ui.basic/src/main/resources/snippets/slider.html b/bundles/org.openhab.ui.basic/src/main/resources/snippets/slider.html index db25da5fe7..ef90d856e9 100644 --- a/bundles/org.openhab.ui.basic/src/main/resources/snippets/slider.html +++ b/bundles/org.openhab.ui.basic/src/main/resources/snippets/slider.html @@ -21,7 +21,8 @@ data-icon-color="%icon_color%" > do nothing"); + return; + } + + var command = value; if (_t.unit) { command = command + " " + _t.unit; } + window.console.log("emitEvent " + command); _t.parentNode.dispatchEvent(createEvent("control-change", { item: _t.item, value: command })); + _t.lastEmittedValue = value; } _t.debounceProxy = new DebounceProxy(function() { - emitEvent(); - }, 200); + if (_t.lastInputValue !== null) { + emitEvent(_t.lastInputValue); + } + }, _t.sendFrequency); _t.setValuePrivate = function(value, itemState) { + window.console.log("setValuePrivate " + value); if (_t.hasValue) { _t.valueNode.innerHTML = value; } @@ -2429,28 +2437,34 @@ unlockTimeout = null; function onChange() { + window.console.log("onChange " + _t.input.value); + _t.debounceProxy.finish(); + emitEvent(_t.input.value); + } + + function onInput() { + if (_t.releaseOnly) { + return; + } + window.console.log("onInput " + _t.input.value); + _t.lastInputValue = _t.input.value; _t.debounceProxy.call(); } function onChangeStart() { + window.console.log("onChangeStart releaseOnly " + _t.releaseOnly + " sendFrequency " + _t.sendFrequency); if (unlockTimeout !== null) { clearTimeout(unlockTimeout); } _t.locked = true; - smarthome.changeListener.pause(); + _t.lastEmittedValue = null; } function onChangeEnd() { - // mouseUp is fired earlier than the value is changed - // quite a dirty hack, but I don't see any other way - _t.debounceProxy.call(); - setTimeout(function() { - smarthome.changeListener.resume(); - }, 5); + window.console.log("onChangeEnd"); unlockTimeout = setTimeout(function() { _t.locked = false; }, 300); - _t.debounceProxy.finish(); } var @@ -2459,7 +2473,8 @@ [ _t.input, "mousedown", onChangeStart ], [ _t.input, "touchend", onChangeEnd ], [ _t.input, "mouseup", onChangeEnd ], - [ _t.input, "change", onChange ] + [ _t.input, "change", onChange ], + [ _t.input, "input", onInput ] ]; _t.destroy = function() {