diff --git a/src/packery.js b/src/packery.js index 8491410..72aae40 100644 --- a/src/packery.js +++ b/src/packery.js @@ -64,6 +64,32 @@ }; }; + var uuidv4 = function() { + var uuid = ''; + var index; + + for (index = 0; index < 32; index += 1) { + switch (index) { + case 8: + case 20: + uuid += '-'; + uuid += ((Math.random() * 16) | 0).toString(16); // eslint-disable-line no-bitwise + break; + case 12: + uuid += '-'; + uuid += '4'; + break; + case 16: + uuid += '-'; + uuid += ((Math.random() * 4) | 8).toString(16); // eslint-disable-line no-bitwise + break; + default: + uuid += ((Math.random() * 16) | 0).toString(16); // eslint-disable-line no-bitwise + } + } + return uuid; + }; + var packeryController = function ($rootScope, config, service) { var self = this; @@ -71,7 +97,7 @@ self.packeryInstantiated = false; self.packeryDraggable = false; self.dragHandle = undefined; - self.uniqueId = new Date().getTime(); + self.uniqueId = uuidv4(); self.packery = {}; this.bindDragEvents = function (el) { @@ -305,4 +331,4 @@ angular .module('packeryTemplates', []).run(['$templateCache', packeryTemplates]); -})(); \ No newline at end of file +})();