Skip to content

Commit

Permalink
update fixedAspectRatio
Browse files Browse the repository at this point in the history
  • Loading branch information
mhkeller committed May 31, 2020
1 parent fd9e3e1 commit c46fae4
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 1 addition & 4 deletions src/LayerCake.svelte
Expand Up @@ -15,7 +15,6 @@
export let pointerEvents = true;
export let position = 'relative';
export let percentRange = false;
export let aspectRatio = undefined;
export let width = undefined;
export let height = undefined;
Expand Down Expand Up @@ -86,7 +85,6 @@
* Make store versions of each parameter
* Prefix these with `_` to keep things organized
*/
const _aspectRatio = writable();
const _percentRange = writable();
const _containerWidth = writable();
const _containerHeight = writable();
Expand Down Expand Up @@ -124,7 +122,6 @@
const _flatData = writable();
const _originalSettings = writable(originalSettings);
$: _aspectRatio.set(aspectRatio);
$: _percentRange.set(percentRange);
$: _containerWidth.set(containerWidth);
$: _containerHeight.set(containerHeight);
Expand Down Expand Up @@ -235,7 +232,7 @@
const zRange_d = derived([zScale_d], getRange);
const rRange_d = derived([rScale_d], getRange);
const aspectRatio_d = derived([_aspectRatio, width_d, height_d], ([$aspectRatio, $width, $height]) => {
const aspectRatio_d = derived([width_d, height_d], ([$aspectRatio, $width, $height]) => {
return $width / $height;
});
Expand Down
5 changes: 5 additions & 0 deletions src/Layouts/ScaledSvg.svelte
Expand Up @@ -4,6 +4,7 @@
export let viewBox = '0 0 100 100';
export let zIndex = undefined;
export let pointerEvents = undefined;
export let fixedAspectRatio = undefined;
let zIndexStyle = '';
$: zIndexStyle = typeof zIndex !== 'undefined' ? `z-index:${zIndex};` : '';
Expand All @@ -12,6 +13,10 @@
$: pointerEventsStyle = pointerEvents === false ? 'pointer-events:none;' : '';
const { padding } = getContext('LayerCake');
$: if (fixedAspectRatio) {
viewBox = `0 0 100 ${100 / fixedAspectRatio}`
}
</script>

<svg
Expand Down

0 comments on commit c46fae4

Please sign in to comment.