зеркало из https://github.com/mozilla/lightbeam.git
fix for issue #180
This commit is contained in:
Родитель
5641a5f719
Коммит
c384d52b0b
|
@ -45,6 +45,7 @@ function onInit(connections){
|
||||||
connections.forEach(function(connection){
|
connections.forEach(function(connection){
|
||||||
onConnection(connection);
|
onConnection(connection);
|
||||||
});
|
});
|
||||||
|
fadeEarlierTrackers(timeToBucket(new Date()));
|
||||||
};
|
};
|
||||||
|
|
||||||
function onConnection(connection){
|
function onConnection(connection){
|
||||||
|
@ -220,12 +221,32 @@ function timeToBucket(timestamp){
|
||||||
return timestamp.getHours() * 4 + Math.floor(timestamp.getMinutes() / 15);
|
return timestamp.getHours() * 4 + Math.floor(timestamp.getMinutes() / 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
function fadeEarlierTrackers(currentAngle){
|
function fadeEarlierTrackers(currentBucketIdx){
|
||||||
console.log('implement fadeEarlierTrackers()');
|
// currentBucketIdx is the index of the bucket (0 - 95)
|
||||||
|
// clock.timeslots[currentBucketIdx] is the current bucket
|
||||||
|
// bucket.group is the SVG <g> container
|
||||||
|
// bucket.connections is the array of connections
|
||||||
|
//
|
||||||
|
// Set opacity for each bucket
|
||||||
|
// Clear items from the next bucket
|
||||||
|
var total = clock.timeslots.length;
|
||||||
|
clock.timeslots.forEach(function(bucket, idx){
|
||||||
|
if (bucket){
|
||||||
|
var distance = ((total + currentBucketIdx) - idx) % total; // how far behind currentBucketIdx?
|
||||||
|
bucket.group.style.opacity = (100 - distance) / 100;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
var nextBucket = clock.timeslots[(currentBucketIdx + 1) % total];
|
||||||
|
var group = nextBucket.group;
|
||||||
|
while(group.firstChild){
|
||||||
|
group.removeChild(group.firstChild);
|
||||||
|
}
|
||||||
|
nextBucket.connections.length = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
var handTimer = null;
|
var handTimer = null;
|
||||||
var lastAngle = null;
|
var lastBucket = null;
|
||||||
|
|
||||||
function drawTimerHand(time){
|
function drawTimerHand(time){
|
||||||
if (!time) time = new Date();
|
if (!time) time = new Date();
|
||||||
var hand = document.getElementById('timerhand');
|
var hand = document.getElementById('timerhand');
|
||||||
|
@ -236,12 +257,12 @@ function drawTimerHand(time){
|
||||||
vizcanvas.appendChild(hand);
|
vizcanvas.appendChild(hand);
|
||||||
}
|
}
|
||||||
vizcanvas.appendChild(hand);
|
vizcanvas.appendChild(hand);
|
||||||
if (!lastAngle){
|
if (!lastBucket){
|
||||||
lastAngle = timeToAngle(time);
|
lastBucket = timeToBucket(time);
|
||||||
}
|
}
|
||||||
if (lastAngle !== timeToAngle(time)){
|
if (lastBucket !== timeToBucket(time)){
|
||||||
lastAngle = timeToAngle(time);
|
lastBucket = timeToBucket(time);
|
||||||
fadeEarlierTrackers(lastAngle);
|
fadeEarlierTrackers(lastBucket);
|
||||||
}
|
}
|
||||||
hand.setAttribute('transform', 'rotate(' + (timeToAngle(time) - 180) + ' ' + CENTRE + ') ' + HAND_TRANS);
|
hand.setAttribute('transform', 'rotate(' + (timeToAngle(time) - 180) + ' ' + CENTRE + ') ' + HAND_TRANS);
|
||||||
handTimer = setTimeout(drawTimerHand, 1000);
|
handTimer = setTimeout(drawTimerHand, 1000);
|
||||||
|
|
Загрузка…
Ссылка в новой задаче