DingRui12138 / vue-pdf-viewer

MIT License
18 stars 11 forks source link

:settings="{ defaultZoom: 200 }" não funciona #14

Open leandrogabrielcunha opened 1 year ago

leandrogabrielcunha commented 1 year ago

:settings="{ defaultZoom: 200 }" não funciona

leandrogabrielcunha commented 1 year ago

?

leandrogabrielcunha commented 1 year ago

Se alguém conseguiu resolver este bug e conseguir me dar um help serei muito grato.

khalidzaibi commented 10 months ago

Hello Dear, I have Fixed this issue.

const pdfViewer = ref('');

watch(() => pdfViewer.value, () => { pdfViewer.value.zoom = 175; }, { deep: true });

Here, i'm using the watch function to watch changes to the pdfViewer ref's value. Whenever the value changes, the second function is triggered. In this case, it sets the zoom property of the pdfViewer component to 175.

The deep: true option means that it's a deep watcher, which will trigger the callback even if the properties within the pdfViewer object change.

jjakob666 commented 3 months ago

@khalidzaibi your fix did not work, it locks it at 175. Here is a fix that works for first load and subsequent changes:


<pdf-viewer 
        ref="pdfViewer"
 </pdf-viewer>

async mounted() {
    //wait for DOM to finish rendering
    await this.$nextTick();

    //workaround to fix default zoom setting not working
    const pdfViewer = this.$refs.pdfViewer;
    this.$watch(() => pdfViewer.zoom, () => {
      const zoom = pdfViewer.zoom;
      pdfViewer.zoom = zoom;
    }, { deep: true });

    //now change the setting
    pdfViewer.zoom = 175;
  },