From 36418a3e3c62ff7d3935cc1494c5a8fa3448d128 Mon Sep 17 00:00:00 2001 From: evlist Date: Mon, 17 Oct 2022 17:48:30 +0200 Subject: [PATCH] Making TiledLayer more generic. --- src/components/map/TiledLayer.test.tsx | 8 ++++---- src/components/map/TiledLayer.tsx | 10 ++++++++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/components/map/TiledLayer.test.tsx b/src/components/map/TiledLayer.test.tsx index 68d6ef6..b302103 100644 --- a/src/components/map/TiledLayer.test.tsx +++ b/src/components/map/TiledLayer.test.tsx @@ -20,19 +20,19 @@ describe('The TiledLayer component ', () => { /> ); - screen.debug(); +// screen.debug(); expect(baseElement).toMatchInlineSnapshot(`
diff --git a/src/components/map/TiledLayer.tsx b/src/components/map/TiledLayer.tsx index 44f5497..4c34858 100644 --- a/src/components/map/TiledLayer.tsx +++ b/src/components/map/TiledLayer.tsx @@ -12,12 +12,16 @@ export interface TiledLayerProperties { } /** - * A lazily loaded square layer of tiles. + * A lazily loaded layer of tiles. * * This component is rather dumb and is mainly a sparse array of tiles. + * * New tiles are added to the array when the viewport is updated and they stay in the array until * the component is destroyed or its number of tiles is updated. * + * This component has no need to know the number nor the size of its tiles: tiles can be added when needed and + * its unit is the tile size (the parent component needs to transform its enclosing SVG group to adapt its units) + * */ export const TiledLayer: react.FC = ( props: TiledLayerProperties @@ -36,7 +40,9 @@ export const TiledLayer: react.FC = ( y: props.keyObject.x + col, }); if (!Object.hasOwn(tiles.current, key)) { - tiles.current[key] = ; + tiles.current[key] = ( + + ); } } );