-
-
Notifications
You must be signed in to change notification settings - Fork 983
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
Vue #513
Comments
Never used Vue, so not sure what is going on. If you put a simple test case online somewhere I'll take a quick look. |
Did you find a solution @SmarterPhoneLabs ? I am trying to do implement iframeResizer with my vue app as well. |
I did, but I ended up having to do some witchcraft on my asp.net
application to make it work
…On Fri, Nov 10, 2017 at 8:07 AM, itafras ***@***.***> wrote:
Did you find a solution @SmarterPhoneLabs
<https://github.com/smarterphonelabs> ? I am trying to do implement
iframeResizer with my vue app as well.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#513 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABIq5ScfHNYsfgAwjMrS3Hv0d2zomrHqks5s1FipgaJpZM4O9m4I>
.
|
Care to share? |
It was highly specific to our app, so I doubt it would be useful to you.
…On Fri, Nov 10, 2017 at 11:41 AM, David J. Bradshaw < ***@***.***> wrote:
Care to share?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#513 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABIq5bIaj2lLPzR0sztX7hqOR0zE4hHYks5s1IrGgaJpZM4O9m4I>
.
|
Hi! |
Hey there, We got a fix in vuejs. You have to create a directive :
JS :
Hope it helps. |
While the directive approach works, I didn't want to have to include the iframeResizer JS in my entire application since I lazy load the components and only one component shows an iFrame. You actually don't have to use a directive to use this in vue. Here's how I did it: Template:
Script:
That works fine for me and is a bit cleaner for my application! If you're doing this in multiple places then I'd still recommend @Dreimus solution above! |
Hey, Here is a different approach based on @Dreimus 's code:
This way:
|
That looks nice and simple, would be great to be able to pass `options` to
iframe-resizer via the directive
|
Good idea, import Vue from 'vue'
import iFrameResize from 'iframe-resizer/js/iframeResizer'
Vue.directive('resize', {
bind: function (el, {value = {}}) {
el.addEventListener('load', () => iFrameResize(value, el))
},
}) Now we can pass options like this: <iframe v-resize="{ log: true }" width="100%" src="myiframe.html" frameborder="0"></iframe> |
Why does my use in vue not work? |
Thanks for sharing your experience with this! The So, the following directive works with Vuetify: <iframe v-resize.quiet="{ log: true }" width="100%" src="myiframe.html" frameborder="0"></iframe> |
You don't need to register a directive globally you can declare it just like any other component: component.vue <template>
...
<iframe v-iframe-resize="{log:true}"></iframe>
...
</template>
<script>
import iframeResize from './v-iframe-resize.js';
export default {
directive: {
'iframe-resize': iframeResize,
},
// component impl.
}
</script> Directive: import iFrameResize from 'iframe-resizer/js/iframeResizer'
export default {
bind(el, binding) {
iFrameResize(binding.value, el);
},
}; its also good idea to handle properties changing, and unbinding. |
The above code is wrong. "directives" instead of "directive". Name without "v-" <template>
...
<iframe v-iframe-resize="{log:true}"></iframe>
...
</template>
<script>
export default {
directives: {
'iframe-resize': {
bind(el, binding) {
iFrameResize(binding.value, el)
}
}
}
}
</script> |
Creating plugin in Nuxt, it doesnt work!:( |
thanks! I'll check it |
I have the same error message as @SmarterPhoneLabs, I think it might be an issue installing the script on the child page. Does anyone have an example of installing the contentWindow script on a VueJS child page? |
Added this into my child page, and it seems to be working:
However I'm using Vuetify and have an issue specific to that framework which forces pages to be full-screen height, even if there are only a few lines of text: vuetifyjs/vuetify#11452, so the iFrame resizes to fit the whole screen height everytime. |
Anyone succeeded to use this with Vue3? I've tried doing this but my frame isn't resized...
|
OK, solved it:
|
A Vue 3 example using <script lang="ts" setup>
import iframeResize from 'iframe-resizer/js/iframeResizer';
const vResize = {
mounted: (el, { value = {} }) => {
el.addEventListener('load', () => iframeResize(value, el));
},
unmounted: (el) => {
el.iFrameResizer.removeListeners();
},
}; |
如果你用的是vue+vuetify,指令不要用v-resize,vuetify自身有这个指令 |
can I also see your template region of the iframe? @drewm |
For anyone struggling with this who is using Vuetify, I finally solved it. Vuetify already has it's own v-resize directive which causes a conflict. So you need to choose a different name.
|
Hi @catskull the solution (#513 (comment)) returns the following warning.
|
@drewm, @picks44, @JCFerrerG, @MeStrak, @victornpb I'm currently working on a large v5 update (#1212) to iframe-resizer and I would like to includes an I have just published an alpha build of version 5 on NPM and have create a draft documentation site This includes an upgrade guide and a guide for creating Framework components Would any of you be able to help create a small Vue wrapper component? |
As a starting point, this is roughly how I think the Vue3 example would need to be updated, Vue Directiveimport { Directive, DirectiveBinding } from "vue";
import connectResizer from "@iframe-resizer/core";
interface ResizableHTMLElement extends HTMLElement {
iframeResizer?: {
close: () => void;
disconnect: () => void;
moveToAnchor: (string) => void;
resize: () => void;
sendMessage: () => void;
};
}
const iframeResizer: Directive = {
mounted(el: HTMLElement, binding: DirectiveBinding) {
const options = binding.value || {};
const connectWithOptions = connectResizer(options);
el.addEventListener("load", () => connectWithOptions(el));
},
unmounted(el: HTMLElement) {
const resizableEl = el as ResizableHTMLElement;
resizableEl?.iframeResizer.disconnect();
},
};
export default resize; Register the directiveconst app = createApp(App)
...
app.directive('iframeResizer', connectResizer)
...
app.mount('#app') Page<iframe
v-iframeResizer
width="100%"
src="myiframe.html"
frameborder="0"
></iframe> |
We now have a Vue package |
Hi there,
I am trying to get your component to work inside of Vue 2
I was able to get the npm installed and my host page running.
I have the client script installed in the child iframe as well, but am getting this warning/error:
[iFrameSizer][Host page: oauth2relay737909339] IFrame has not responded within 10 seconds. Check iFrameResizer.contentWindow.js has been loaded in iFrame. This message can be ingored if everything is working, or you can set the warningTimeout option to a higher value or zero to suppress this warning.
I also setup the callbacks, but the messages that come back on resize and message are 'undefined'.
The text was updated successfully, but these errors were encountered: