Giter Site home page Giter Site logo

Comments (2)

FossPrime avatar FossPrime commented on August 21, 2024 1

I think a default component level solution should be used... like vue-pdf used to do. Without it the advanced example looks broken.

Here's my solution:

// import debounce to prevent performance issues while resizing window
import { debounce } from 'lodash-es'

// in data or a ref
resizeObserver: null

// in `loaded` event handler
      this.resizeObserver.observe(this.$refs.pdfRef.$el.parentElement)


// in `created` vue lifecycle hook
      const rOSM = {
        prevWidth: '', // using width prevents blinking while rendering happens which can change the height
        pdfRef: this.$refs.pdfRef
      }
      this.resizeObserver = new ResizeObserver(
        debounce((entries) => {
          const entry = entries[0]
          const newWidth = entry.contentRect.width
          const prevWidth = rOSM.prevWidth
          rOSM.prevWidth = newWidth
          if (prevWidth !== '' && prevWidth !== newWidth) {
            console.log(prevWidth, newWidth)
            rOSM.pdfRef.render()
          }
        }, 300)

// on `beforeDestroy` vue lifecycle hook
this.resizeObserver.unobserve(this.$refs.pdfRef.$el)

from vue-pdf-embed.

hrynko avatar hrynko commented on August 21, 2024

Hi @gradox2020,

It isn't planned to make it responsive. It is recommended to use one of the following approaches:

  • Some of the resize tracking libs for Vue
  • Resize Observer API or resize event
  • CSS approach from #20 (if you don't need annotation and text layers)

Responsiveness out of the box is not added due to the fact that this is a rather case-specific topic. It is assumed that the developer will be able to choose the most appropriate approach, and not be limited to a hardwired solution. Thank you for your understanding, I hope this doesn't spoil your experience of using the library.

from vue-pdf-embed.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.