toolbar and zoom control fixes

This commit is contained in:
Lachlan Kermode
2020-06-08 19:17:10 +02:00
parent a8d04f39a7
commit f6fb40d4be
4 changed files with 26 additions and 7 deletions

View File

@@ -1,5 +1,14 @@
import React from 'react'
const DEFAULT_ZOOM_LEVELS = [
{ label: '20 years', duration: 10512000 },
{ label: '2 years', duration: 1051200 },
{ label: '3 months', duration: 129600 },
{ label: '3 days', duration: 4320 },
{ label: '12 hours', duration: 720 },
{ label: '1 hour', duration: 60 }
]
function zoomIsActive (duration, extent, max) {
if (duration >= max && extent >= max) {
return true
@@ -23,6 +32,9 @@ const TimelineZoomControls = ({ extent, zoomLevels, dims, onApplyZoom }) => {
)
}
if (zoomLevels.length === 0) {
zoomLevels = DEFAULT_ZOOM_LEVELS
}
return (
<g transform={`translate(${dims.width - dims.width_controls}, 0)`}>
{zoomLevels.map((z, idx) => renderZoom(z, idx))}