Jump to content
Search Community

SakalaWeb

Members
  • Posts

    3
  • Joined

  • Last visited

Posts posted by SakalaWeb

  1.  

    Hi SakalaWeb  :)

     

    You wouldn't need to use CSS calc() in your JavaScript. I think innerHeight and innerWidth would help with your calculations. So something like this:

    var h = window.innerHeight;
    var w = window.innerWidth;

    That will give you the window dimensions. From there you can calculate the center by dividing each by two and then position your box in the center. (or as close to center as you want it).

     

    More info:

    https://developer.mozilla.org/en-US/docs/Web/API/Window/innerHeight

    https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth

     

    Hopefully that helps.

     

    Happy tweening.

    :)

     

     

    Ok it's working but what when I need to do that calculations in some responsive container. Do I need to refer to parent element.rect -> do calcs -> pass vars to tween? Is css calc() function problematic?

×
×
  • Create New...