Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] - auto scale browser based on "base resolution" and "current resolution" #81

Open
seiyria opened this issue Oct 11, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@seiyria
Copy link
Member

seiyria commented Oct 11, 2022

https://stackoverflow.com/a/9040712/926845

basically, track --desired-width and --desired-height, when the page loads get --current-width and --current-height and either zoom() or scale() to make it look ok. this should probably only apply if current width < desired width for smaller resolutions

@seiyria seiyria added the enhancement New feature or request label Oct 11, 2022
@seiyria
Copy link
Member Author

seiyria commented Oct 21, 2022

Some code:


:root {

  --desired-width: 1440;
  --desired-height: 1200;
  --current-width: 1440;
  --current-height: 1200;
}

body {
  transform: scaleX(calc(var(--current-width) / var(--desired-width))) scaleY(calc(var(--current-height) / var(--desired-height)));
}

  private watchResolutionChanges() {
    const checkSize = () => {
      const rootElement = document.documentElement;
      const { clientWidth, clientHeight } = document.body;

      const maxWidthNeeded = +getComputedStyle(rootElement).getPropertyValue('--desired-width');
      const maxHeightNeeded = +getComputedStyle(rootElement).getPropertyValue('--desired-height');

      rootElement.style.setProperty('--current-width', Math.min(maxWidthNeeded, clientWidth).toString());
      rootElement.style.setProperty('--current-height', Math.min(maxHeightNeeded, clientHeight).toString());
    };

    checkSize();

    window.addEventListener('resize', checkSize);
  }


This doesn't quite work, as the page itself :

image

This seems to apply whether you do it on body, or a child of body. Requires more work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant