From f10a5d7ec3531c99ca91a0c2d0d16b57fbbddbe1 Mon Sep 17 00:00:00 2001 From: calzoneman Date: Wed, 26 Jun 2013 10:50:08 -0400 Subject: [PATCH] Add a wait condition to prevent playlist highlight being messed up --- www/assets/js/callbacks.js | 7 +++++++ www/assets/js/data.js | 1 + www/assets/js/util.js | 2 ++ 3 files changed, 10 insertions(+) diff --git a/www/assets/js/callbacks.js b/www/assets/js/callbacks.js index 5174de7a..777242f9 100644 --- a/www/assets/js/callbacks.js +++ b/www/assets/js/callbacks.js @@ -708,6 +708,13 @@ Callbacks = { }, setPosition: function(position) { + // Wait until any pending movement is finished + if(MOVING) { + setTimeout(function() { + Callbacks.move(position); + }, 100); + return; + } $("#queue li").each(function() { $(this).removeClass("queue_active"); }); diff --git a/www/assets/js/data.js b/www/assets/js/data.js index 4043086e..3b5070c9 100644 --- a/www/assets/js/data.js +++ b/www/assets/js/data.js @@ -40,6 +40,7 @@ if($("#ytapiplayer").length > 0) { var VHEIGHT = ""+parseInt(parseInt(VWIDTH) * 9 / 16); } var POSITION = -1; +var MOVING = false; var REBUILDING = false; var socket = { emit: function() { diff --git a/www/assets/js/util.js b/www/assets/js/util.js index b6131162..defcccc7 100644 --- a/www/assets/js/util.js +++ b/www/assets/js/util.js @@ -952,6 +952,7 @@ function playlistMove(from, to) { if(from >= q.children().length) return false; + MOVING = true; var old = $(q.children()[from]); old.hide("blind", function() { old.detach(); @@ -960,6 +961,7 @@ function playlistMove(from, to) { else old.insertBefore(q.children()[to]); old.show("blind"); + MOVING = false; }); }