-
Notifications
You must be signed in to change notification settings - Fork 0
/
page.js
27 lines (25 loc) · 823 Bytes
/
page.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
var app;
app = angular.module('test_angular_animation', ['ngAnimate']);
app.controller('mycontroller', function($scope, $timeout) {
var tick;
$scope.things = [];
$scope.target_list_size = 12;
$scope.cycles_per_second = 3;
tick = function() {
var i, n, newthing, probability_of_adding, r;
n = $scope.things.length;
probability_of_adding = 1 - n / ($scope.target_list_size * 2);
r = Math.random();
if (r < probability_of_adding) {
newthing = new Array(Math.floor(r * 100)).join("-");
newthing += String(r).substr(2, 5);
$scope.things.push(newthing);
} else {
i = Math.floor(Math.random() * $scope.things.length);
$scope.things.splice(i, 1);
}
$scope.things.sort();
return $timeout(tick, 1000 / $scope.cycles_per_second);
};
return tick();
});