12345678910111213141516171819202122232425262728293031 |
- function Point() {
- this.el = $('.item_game .points');
- this.classNames = ['point_1', 'point_2', 'point_3', 'point_4'];
- this.html = '';
- for(var i = 0; i < 20; i++) {
- this.html += this.create(i);
- }
- this.el.html(this.html);
- }
- Point.prototype = {
- getRandom: function(min, max) {
- return Math.round(Math.random() * (max - min) + min);
- },
- randomLeft: function() {
- return this.getRandom(260, 420);
- },
- randomIndex: function() {
- return this.getRandom(0, 3);
- },
- create: function(i) {
- var left = "left: " + this.randomLeft() + "px";
- var delay = "animation-delay:" + (i * 0.5).toFixed(2) + "s" ;
- var style = left + ";" + delay;
- var str = '<div class="' + this.classNames[this.randomIndex()] + '" style="' + style + '"></div>'
- return str;
- }
- }
|