Skip to content

Commit

Permalink
ICL-25770 Start using better way to generate unique Id
Browse files Browse the repository at this point in the history
  • Loading branch information
Vatsov committed Dec 8, 2021
1 parent 6e6bf63 commit 7f5e01a
Showing 1 changed file with 28 additions and 2 deletions.
30 changes: 28 additions & 2 deletions src/packery.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,40 @@
};
};

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;

self.packeryInstantiated = false;
self.packeryDraggable = false;
self.dragHandle = undefined;
self.uniqueId = new Date().getTime();
self.uniqueId = uuidv4();
self.packery = {};

this.bindDragEvents = function (el) {
Expand Down Expand Up @@ -305,4 +331,4 @@
angular
.module('packeryTemplates', []).run(['$templateCache', packeryTemplates]);

})();
})();

0 comments on commit 7f5e01a

Please sign in to comment.