comparison interfaces/horizontal-sliders.js @ 3132:38d2150045f5

#286 reformatted the horizontal sliders to use grids
author Nicholas Jillings <nicholas.jillings@mail.bcu.ac.uk>
date Thu, 21 Feb 2019 12:55:05 +0000
parents 91d923c51e90
children
comparison
equal deleted inserted replaced
3131:735d96d343f6 3132:38d2150045f5
255 var playing = false; 255 var playing = false;
256 this.parent = audioObject; 256 this.parent = audioObject;
257 257
258 this.holder = document.createElement('div'); 258 this.holder = document.createElement('div');
259 this.title = document.createElement('div'); 259 this.title = document.createElement('div');
260 this.titleH4 = document.createElement('h4');
260 this.slider = document.createElement('input'); 261 this.slider = document.createElement('input');
261 this.play = document.createElement('button'); 262 this.play = document.createElement('button');
262 263
263 this.holder.className = 'track-slider'; 264 this.holder.className = 'track-slider';
264 this.holder.style.width = window.innerWidth - 200 + 'px'; 265 this.holder.style.width = window.innerWidth - 200 + 'px';
266 this.title.appendChild(this.titleH4);
265 this.holder.appendChild(this.title); 267 this.holder.appendChild(this.title);
266 this.holder.appendChild(this.slider); 268 this.holder.appendChild(this.slider);
267 this.holder.appendChild(this.play); 269 this.holder.appendChild(this.play);
268 this.holder.setAttribute('trackIndex', audioObject.id); 270 this.holder.setAttribute('trackIndex', audioObject.id);
269 this.title.textContent = label; 271 this.titleH4.textContent = label;
270 this.title.className = 'track-slider-title'; 272 this.title.className = 'track-slider-title';
271 273
272 this.slider.type = "range"; 274 this.slider.type = "range";
273 this.slider.className = "track-slider-range track-slider-not-moved"; 275 this.slider.className = "track-slider-range track-slider-not-moved";
274 this.slider.min = "0"; 276 this.slider.min = "0";
275 this.slider.max = "1"; 277 this.slider.max = "1";
276 this.slider.step = "0.01"; 278 this.slider.step = "0.01";
277 this.slider.style.width = window.innerWidth - 420 + 'px';
278 this.slider.onchange = function () { 279 this.slider.onchange = function () {
279 var time = audioEngineContext.timer.getTestTime(); 280 var time = audioEngineContext.timer.getTestTime();
280 var id = Number(this.parentNode.getAttribute('trackIndex')); 281 var id = Number(this.parentNode.getAttribute('trackIndex'));
281 audioEngineContext.audioObjects[id].metric.moved(time, this.value); 282 audioEngineContext.audioObjects[id].metric.moved(time, this.value);
282 console.log('slider ' + id + ' moved to ' + this.value + ' (' + time + ')'); 283 console.log('slider ' + id + ' moved to ' + this.value + ' (' + time + ')');
297 audioEngineContext.stop(); 298 audioEngineContext.stop();
298 } 299 }
299 }; 300 };
300 this.resize = function (event) { 301 this.resize = function (event) {
301 this.holder.style.width = window.innerWidth - 200 + 'px'; 302 this.holder.style.width = window.innerWidth - 200 + 'px';
302 this.slider.style.width = window.innerWidth - 420 + 'px';
303 }; 303 };
304 this.enable = function () { 304 this.enable = function () {
305 // This is used to tell the interface object that playback of this node is ready 305 // This is used to tell the interface object that playback of this node is ready
306 this.play.disabled = false; 306 this.play.disabled = false;
307 this.play.textContent = "Play"; 307 this.play.textContent = "Play";
374 function resizeWindow(event) { 374 function resizeWindow(event) {
375 // Called on every window resize event, use this to scale your page properly 375 // Called on every window resize event, use this to scale your page properly
376 376
377 var numObj = document.getElementsByClassName('track-slider').length; 377 var numObj = document.getElementsByClassName('track-slider').length;
378 var totalHeight = (numObj * 125) - 25; 378 var totalHeight = (numObj * 125) - 25;
379 document.getElementById('scale-holder').style.width = window.innerWidth - 220 + 'px';
380 // Cheers edge for making me delete a canvas every resize. 379 // Cheers edge for making me delete a canvas every resize.
381 var canvas = document.getElementById('scale-canvas'); 380 var canvas = document.getElementById('scale-canvas');
382 var new_canvas = document.createElement("canvas"); 381 var new_canvas = document.createElement("canvas");
383 new_canvas.id = 'scale-canvas'; 382 new_canvas.id = 'scale-canvas';
384 new_canvas.style.marginLeft = "100px"; 383 new_canvas.style.marginLeft = "100px";