Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for unscaled iframes #1920

Open
tschaub opened this issue Oct 29, 2024 · 0 comments
Open

Support for unscaled iframes #1920

tschaub opened this issue Oct 29, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@tschaub
Copy link

tschaub commented Oct 29, 2024

Is your feature request related to a problem? Please describe.
The built-in iframe layout accepts a scale prop. I assumed that I could set this to 1 to embed an iframe without scaling. However, resizing the page shows that the iframe content is still scaled.

Describe the solution you'd like
I'd like to be able to embed an iframe without scaling.

Describe alternatives you've considered
I've created a custom iframe-unscaled.vue layout to reverse the scaling that is applied to slide content:

<script setup lang="ts">
const props = defineProps<{
  url: string
}>();

const unscaledSize = 'calc(100% * var(--slidev-slide-scale))';
const unscaledTransform = 'scale(calc(1 / var(--slidev-slide-scale)))';
</script>

<template>
  <div class="h-full w-full">
    <div relative :style="{ width: unscaledSize, height: unscaledSize }">
      <iframe
        id="frame" class="w-full h-full"
        :src="url"
        :style="{ transform: unscaledTransform, transformOrigin: 'top left' }"
      />
    </div>
  </div>
</template>

I'm uncertain if making use of the --slidev-slide-scale CSS variable should be avoided. Ideally, I could pass a prop to the existing iframe layout to avoid scaling.

Here is an example that demonstrates the scaling of the current iframe layout: https://stackblitz.com/edit/slidev-iframe-unscaled?file=slides.md,layouts%2Fiframe-unscaled.vue (the preview needs to be opened in a dedicated tab for the iframes to load).

@tschaub tschaub added the enhancement New feature or request label Oct 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant