Skip to content

Commit

Permalink
add map aspect ratio WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkeller committed May 23, 2020
1 parent d7e3273 commit dfe35d9
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/LayerCake.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -229,10 +229,13 @@
const zRange_d = derived([zScale_d], getRange);
const rRange_d = derived([rScale_d], getRange);
const aspectRatio_d = derived([width_d, height_d], ([$width, $height]) => $width / $height);
$: context = {
activeGetters: activeGetters_d,
width: width_d,
height: height_d,
aspectRatio: aspectRatio_d,
containerWidth: _containerWidth,
containerHeight: _containerHeight,
x: _x,
Expand Down Expand Up @@ -286,7 +289,11 @@
bind:clientWidth={containerWidth}
bind:clientHeight={containerHeight}
>
<slot></slot>
<slot
width={$width_d}
height={$height_d}
aspectRatio={$aspectRatio_d}
></slot>
</div>
{/if}

Expand Down
3 changes: 2 additions & 1 deletion src/Layouts/SvgSsr.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import { getContext } from 'svelte';
export let zIndex = undefined;
export let viewBox = '0 0 100 100';
let zIndexStyle = '';
$: zIndexStyle = typeof zIndex !== 'undefined' ? `z-index:${zIndex};` : '';
Expand All @@ -10,7 +11,7 @@
</script>

<svg
viewBox="0 0 100 100"
{viewBox}
preserveAspectRatio="none"
style="top: {$padding.top}px; right:0px; bottom:0px; left:{$padding.left}px;width:calc(100% - {($padding.left + $padding.right)}px);height:calc(100% - {($padding.top + $padding.bottom)}px);{zIndexStyle}"
>
Expand Down

0 comments on commit dfe35d9

Please sign in to comment.