We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with it.

Resize not as expected

Home Forums Programming Resize not as expected

Tagged: 

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #55716
    michael64
    Participant

    Hi guys,

    I’m trying to resize the canvas element and then want to have the current scene centered automatically.
    Using app.onResize() it’s working if the browser window is resized manually.

    But if I resize just the parent container(div) of the canvas then the event is always one step behind.

    • reduce size of parent container nothing happens
    • enlarge size of parent container canvas shrinks
    • reduce size of parent container canvas enlarges

    Expected behaviour:

    • reduce size of parent container canvas shrinks
    • enlarge size of parent container canvas enlarges
    • reduce size of parent container canvas shrinks

    I tried several things, but not successfully. So now I’m out of ideas. :scratch:
    What I tried:

    • trigger resize event on window or on parent element
    • tried to call onResize() several times
    • tried to resize container in steps
    • change also the size of the canvas.
      This squeezed the scene. And calling app.onResize() revert the resize of the canvas. Probably because it is taken the size from the window.
    • setting the current camera again

    Version of my verge3d is 3.9.1. I tried also js file from the current 4.1. but that didn’t change anything.

    Maybe one of you guys have another tipp, approach, whatever.

    Kind regards,
    Michael :bye:

    • This topic was modified 2 months, 3 weeks ago by michael64.
    • This topic was modified 2 months, 3 weeks ago by michael64.
    • This topic was modified 2 months, 3 weeks ago by michael64.
    • This topic was modified 2 months, 3 weeks ago by michael64.
    #55738
    kdv77kdv
    Participant

    Works as expected

    https://v3d.net/9cj

    #55747
    michael64
    Participant

    I’m using only Javascript to build the app. No puzzle.
    Could now solve my issue by calling app.onResize() after 200ms using timeout.

                setTimeout(function(){
                    app.onResize();
                }, 200);

    For some reasons the app wasn’t able to get the correct width without using the timeout.

    The solution is a little bit ugly but ok for now. :wacko:

    But thanks for the hint. :good:

    #55748
    kdv77kdv
    Participant

    I’m using only Javascript to build the app. No puzzle.

    In fact, it doesn’t matter. Show your code that reacts on the container resizing.

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.