From f4842b609f65bb858a4e7528df2f826f1775a0d2 Mon Sep 17 00:00:00 2001 From: Luke Murray Date: Fri, 18 Nov 2016 13:20:25 +1100 Subject: [PATCH 1/3] expose current frame and playing state --- src/jquery.imgplay.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/jquery.imgplay.js b/src/jquery.imgplay.js index a9a25e4..c045622 100644 --- a/src/jquery.imgplay.js +++ b/src/jquery.imgplay.js @@ -21,7 +21,7 @@ var playTimer = null; plugin.settings = {}; - + plugin.controls = { play: null, pause: null, @@ -63,6 +63,14 @@ resize(); }; + plugin.isPlaying = function() { + return playing; + }; + + plugin.currentFrame = function() { + return index; + }; + plugin.play = function() { playing = true; direction = 'forward'; From 33b5ea5f93ee4eb775943dd8ee725233dc22d124 Mon Sep 17 00:00:00 2001 From: Luke Murray Date: Fri, 18 Nov 2016 13:24:15 +1100 Subject: [PATCH 2/3] rename currentFrame --- src/jquery.imgplay.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/jquery.imgplay.js b/src/jquery.imgplay.js index c045622..2f76b62 100644 --- a/src/jquery.imgplay.js +++ b/src/jquery.imgplay.js @@ -67,7 +67,7 @@ return playing; }; - plugin.currentFrame = function() { + plugin.getCurrentFrame = function() { return index; }; From c1ea9b90e459b959cc99cae7fe9ba557e1a018b4 Mon Sep 17 00:00:00 2001 From: Luke Murray Date: Fri, 18 Nov 2016 13:34:18 +1100 Subject: [PATCH 3/3] do not show controls if asked not to --- src/jquery.imgplay.js | 71 +++++++++++++++++++++++++++---------------- 1 file changed, 44 insertions(+), 27 deletions(-) diff --git a/src/jquery.imgplay.js b/src/jquery.imgplay.js index 2f76b62..8eecd6b 100644 --- a/src/jquery.imgplay.js +++ b/src/jquery.imgplay.js @@ -76,11 +76,13 @@ direction = 'forward'; drawFrame(); - plugin.controls.play.addClass('active'); - plugin.controls.stop.removeClass('active'); - plugin.controls.pause.removeClass('active'); - plugin.controls.rewind.removeClass('active'); - plugin.controls.forward.removeClass('active'); + if (plugin.settings.controls) { + plugin.controls.play.addClass('active'); + plugin.controls.stop.removeClass('active'); + plugin.controls.pause.removeClass('active'); + plugin.controls.rewind.removeClass('active'); + plugin.controls.forward.removeClass('active'); + } }; plugin.pause = function() { @@ -89,22 +91,26 @@ clearTimeout(playTimer); } - plugin.controls.pause.addClass('active'); - plugin.controls.play.removeClass('active'); - plugin.controls.stop.removeClass('active'); - plugin.controls.rewind.removeClass('active'); - plugin.controls.forward.removeClass('active'); + if (plugin.settings.controls) { + plugin.controls.pause.addClass('active'); + plugin.controls.play.removeClass('active'); + plugin.controls.stop.removeClass('active'); + plugin.controls.rewind.removeClass('active'); + plugin.controls.forward.removeClass('active'); + } }; plugin.stop = function() { playing = false; index = 0; - plugin.controls.stop.addClass('active'); - plugin.controls.play.removeClass('active'); - plugin.controls.pause.removeClass('active'); - plugin.controls.rewind.removeClass('active'); - plugin.controls.forward.removeClass('active'); + if (plugin.settings.controls) { + plugin.controls.stop.addClass('active'); + plugin.controls.play.removeClass('active'); + plugin.controls.pause.removeClass('active'); + plugin.controls.rewind.removeClass('active'); + plugin.controls.forward.removeClass('active'); + } }; plugin.rewind = function(frames) { @@ -115,11 +121,13 @@ drawFrame(); } - plugin.controls.rewind.addClass('active'); - plugin.controls.forward.removeClass('active'); - plugin.controls.stop.removeClass('active'); - plugin.controls.play.removeClass('active'); - plugin.controls.pause.removeClass('active'); + if (plugin.settings.controls) { + plugin.controls.rewind.addClass('active'); + plugin.controls.forward.removeClass('active'); + plugin.controls.stop.removeClass('active'); + plugin.controls.play.removeClass('active'); + plugin.controls.pause.removeClass('active'); + } }; plugin.forward = function(frames) { @@ -130,11 +138,13 @@ drawFrame(); } - plugin.controls.forward.addClass('active'); - plugin.controls.rewind.removeClass('active'); - plugin.controls.stop.removeClass('active'); - plugin.controls.play.removeClass('active'); - plugin.controls.pause.removeClass('active'); + if (plugin.settings.controls) { + plugin.controls.forward.addClass('active'); + plugin.controls.rewind.removeClass('active'); + plugin.controls.stop.removeClass('active'); + plugin.controls.play.removeClass('active'); + plugin.controls.pause.removeClass('active'); + } }; plugin.fastRewind = function(rate) { @@ -196,7 +206,9 @@ } else if (el.webkitRequestFullscreen) { el.webkitRequestFullscreen(Element.ALLOW_KEYBOARD_INPUT); } - plugin.controls.fullscreen.addClass('active'); + if (plugin.settings.controls) { + plugin.controls.fullscreen.addClass('active'); + } } else { if (document.exitFullscreen) { document.exitFullscreen(); @@ -207,7 +219,9 @@ } else if (document.webkitExitFullscreen) { document.webkitExitFullscreen(); } - plugin.controls.fullscreen.removeClass('active'); + if (plugin.settings.controls) { + plugin.controls.fullscreen.removeClass('active'); + } } setTimeout(function() { @@ -216,6 +230,9 @@ }; var initControls = function() { + if (!plugin.settings.controls) { + return; + } if($el.find('.imgplay-controls').length == 0) { var controls = $('
'); var progress = $('
');