diff js/core.js @ 2669:a513533565cf

Fix for #194
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Tue, 28 Mar 2017 12:59:27 +0100
parents 2f2aaef246af
children b9efbbe0d829 2395223deef2
line wrap: on
line diff
--- a/js/core.js	Mon Mar 20 16:21:44 2017 +0000
+++ b/js/core.js	Tue Mar 28 12:59:27 2017 +0100
@@ -2946,13 +2946,22 @@
         this.slider.max = 12;
         this.slider.value = 0;
         this.slider.step = 1;
-        this.slider.onmousemove = function (event) {
-            interfaceContext.volume.valueDB = event.currentTarget.value;
-            interfaceContext.volume.valueLin = decibelToLinear(interfaceContext.volume.valueDB);
-            interfaceContext.volume.valueText.textContent = interfaceContext.volume.valueDB + 'dB';
-            audioEngineContext.outputGain.gain.value = interfaceContext.volume.valueLin;
+        this.handleEvent = function (event) {
+            if (event.type == "mousemove") {
+                this.valueDB = Number(this.slider.value);
+                this.valueLin = decibelToLinear(this.valueDB);
+                this.valueText.textContent = this.valueDB + 'dB';
+                audioEngineContext.outputGain.gain.value = this.valueLin;
+            } else if (event.type == "mouseup") {
+                this.onmouseup();
+            }
+            this.slider.value = this.valueDB;
+
+            if (event.stopPropagation) {
+                event.stopPropagation();
+            }
         }
-        this.slider.onmouseup = function (event) {
+        this.onmouseup = function () {
             var storePoint = testState.currentStore.XMLDOM.getElementsByTagName('metric')[0].getAllElementsByName('volumeTracker');
             if (storePoint.length == 0) {
                 storePoint = storage.document.createElement('metricresult');
@@ -2963,10 +2972,12 @@
             }
             var node = storage.document.createElement('movement');
             node.setAttribute('test-time', audioEngineContext.timer.getTestTime());
-            node.setAttribute('volume', interfaceContext.volume.valueDB);
+            node.setAttribute('volume', this.valueDB);
             node.setAttribute('format', 'dBFS');
             storePoint.appendChild(node);
         }
+        this.slider.addEventListener("mousemove", this);
+        this.root.addEventListener("mouseup", this);
 
         var title = document.createElement('div');
         title.innerHTML = '<span>Master Volume Control</span>';