Coder Social home page Coder Social logo

Comments (7)

schickling avatar schickling commented on May 16, 2024

The default in this case is 800 x 600. We just thought 1440 x 900 is a more sensible default. Open for discussion!

from chromeless.

jpadilla avatar jpadilla commented on May 16, 2024

@schickling can auto sizing be done using window.innerHeight and window.innerWidth in headless instead of setting a default?

from chromeless.

schickling avatar schickling commented on May 16, 2024

You setting this inside of a .evaluate call? I don't see the advantage of this approach over setting the viewport in the constructor?

from chromeless.

jpadilla avatar jpadilla commented on May 16, 2024

@schickling I'm wondering if it possible to do full height, when it's an unknown.

from chromeless.

schickling avatar schickling commented on May 16, 2024

You probably first need to find out the height using an .evaluate call and then use the .viewport method.

from chromeless.

jpadilla avatar jpadilla commented on May 16, 2024

@schickling That's what I saw was being done here but not when isHeadless is true. Tried something like this, but renders a white image.

const screenshot = await chromeless
  .goto('https://www.graph.cool')
  .evaluate(async () => {
    const height = window.innerHeight;
    const width = window.innerWidth;
    await chromeless.viewport(width, height);
  })
  .screenshot()

from chromeless.

jroakes avatar jroakes commented on May 16, 2024

What you want here (at least for the mean time) is to:

I think evaluate doesn't pass anything but what is returned to it, so screenshot would get a blank image.

const evalstuff= await chromeless
  .goto('https://www.graph.cool')
  .evaluate(async () => {
    const height = document.body.scrollHeight; //This gets the whole scrolled window height.
    const width = window.innerWidth;  // You probably don't need this.
    return {width:width, height:height}
  })

then you call:

const data = await evalstuff
const screenshot = await chromeless
  .setViewport({deviceScaleFactor: 0, scale: 1, fitWindow: true, width: data.width , height: data.height})
  .screenshot()

This worked for me, at least, putting here for others in the same boat.

from chromeless.

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.