Prefer Date.now() when possible
This commit is contained in:
@@ -43,7 +43,7 @@ function addRandomFeature() {
|
|||||||
|
|
||||||
const duration = 3000;
|
const duration = 3000;
|
||||||
function flash(feature) {
|
function flash(feature) {
|
||||||
const start = new Date().getTime();
|
const start = Date.now();
|
||||||
const flashGeom = feature.getGeometry().clone();
|
const flashGeom = feature.getGeometry().clone();
|
||||||
const listenerKey = tileLayer.on('postrender', animate);
|
const listenerKey = tileLayer.on('postrender', animate);
|
||||||
|
|
||||||
|
|||||||
@@ -142,7 +142,7 @@ fetch('data/polyline/route.json').then(function (response) {
|
|||||||
stopAnimation(false);
|
stopAnimation(false);
|
||||||
} else {
|
} else {
|
||||||
animating = true;
|
animating = true;
|
||||||
startTime = new Date().getTime();
|
startTime = Date.now();
|
||||||
speed = speedInput.value;
|
speed = speedInput.value;
|
||||||
startButton.textContent = 'Cancel Animation';
|
startButton.textContent = 'Cancel Animation';
|
||||||
// hide geoMarker
|
// hide geoMarker
|
||||||
|
|||||||
@@ -120,7 +120,7 @@ function animateFlights(event) {
|
|||||||
|
|
||||||
function addLater(feature, timeout) {
|
function addLater(feature, timeout) {
|
||||||
window.setTimeout(function () {
|
window.setTimeout(function () {
|
||||||
feature.set('start', new Date().getTime());
|
feature.set('start', Date.now());
|
||||||
flightsSource.addFeature(feature);
|
flightsSource.addFeature(feature);
|
||||||
}, timeout);
|
}, timeout);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ function updateInfo() {
|
|||||||
|
|
||||||
function setTime() {
|
function setTime() {
|
||||||
startDate.setMinutes(startDate.getMinutes() + 15);
|
startDate.setMinutes(startDate.getMinutes() + 15);
|
||||||
if (startDate > new Date()) {
|
if (startDate > Date.now()) {
|
||||||
startDate = threeHoursAgo();
|
startDate = threeHoursAgo();
|
||||||
}
|
}
|
||||||
layers[1].getSource().updateParams({'TIME': startDate.toISOString()});
|
layers[1].getSource().updateParams({'TIME': startDate.toISOString()});
|
||||||
|
|||||||
Reference in New Issue
Block a user