diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..4befed3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,2 @@
+.DS_Store
+.idea
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..4f86390
--- /dev/null
+++ b/package.json
@@ -0,0 +1,4 @@
+{
+ "name": "3D-Product-Viewer-JavaScript-Plugin",
+ "version": "1.0.1"
+}
diff --git a/pdt360DegViewer.js b/pdt360DegViewer.js
index c5a483c..df72a2a 100644
--- a/pdt360DegViewer.js
+++ b/pdt360DegViewer.js
@@ -1,22 +1,92 @@
+function init360Viewer(options) {
+ var o = options;
+ // Some options are required for the viewer to work.
+ if (!o.id || !o.count || !o.path || !o.imgType) {
+ if (!o.id)
+ initError('id', 'Must specify the id of the wrapping element.');
+ if (!o.count)
+ initError('count', 'Must specify amount of images to cycle.');
+ if (!o.path)
+ initError('path', 'Must specify path to images.');
+ if (!o.imgType)
+ initError('imgType', 'Must specify the extension of images.');
+ // If any of the options are not satisfied, return.
+ return;
+ }
+
+ // Consolidate aliases.
+ o.draggable = o.draggable || o.drag;
+ o.autoPlay = o.autoPlay || o.autoplay;
+ o.buttons = o.buttons || o.buttonNavigation;
+ o.keys = o.keys || o.keyNavigation;
+ o.scroll = o.scroll || o.scrollNavigation;
+
+ // Initialize viewer.
+ pdt360DegViewer(
+ o.id,
+ o.count,
+ o.path,
+ o.imgType,
+ o.playable,
+ o.autoPlay,
+ o.draggable,
+ o.mouseMove,
+ o.buttons,
+ o.keys,
+ o.scroll
+ );
+}
+
+function initError(prop, message) {
+ console.error('360Viewer encountered an error: Missing "' + prop + '" property. ' + message);
+}
+
var call = 0;
function pdt360DegViewer(id, n, p, t, playable, autoPlay, draggable, mouseMove, buttons, keys, scroll) {
- console.log(`${call}-${id}-${playable ? 'playable ' : ''}${autoPlay ? 'autoPlay ' : ''}${draggable ? 'draggable ' : ''}${mouseMove ? 'mouseMove ' : ''}${buttons ? 'buttons ' : ''}${keys ? 'keys' : ''}${scroll ? 'scroll ' : ''}`);
+ var state = [
+ call + ' ' + id,
+ (playable ? 'playable' : ''),
+ (autoPlay ? 'autoPlay' : ''),
+ (draggable ? 'draggable' : ''),
+ (mouseMove ? 'mouseMove' : ''),
+ (buttons ? 'buttons' : ''),
+ (keys ? 'keys' : ''),
+ (scroll ? 'scroll' : '')
+ ];
+ console.log(state.join(' ').replace(/\s+/g, ' '));
+
call++;
loaderNone(id);
var i = 1, j = 0, move = [],
- mainDiv = document.querySelector(`#${id}`);
+ mainDiv = document.querySelector('#' + id);
mainDiv.className = 'viewer';
- mainDiv.innerHTML += ``;
- mainDiv.innerHTML +=
- '