npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

fitscreen.js

v0.1.0

Published

Scale-based large-screen adaptive solution

Downloads

14

Readme

fitscreen.js

A fundamental approach to scale-based large-screen adaptive solutions

Everything is based on the design draft's px size, and the adaptation is done by scale, everything is so simple

🦄 Useage

It is recommended that you use it without using the front-end framework. If you use the framework, please check FitScreen

<html lang="en">
<head>xxx</head>
<body>
  <!-- the content that will be displayed on the screen -->
  <div class="screen">
    <div class="test-left">xxx</div>
    <div class="test-center">xxx</div>
    <div class="test-right">xxx</div>
  </div>

  <!-- <script src="https://unpkg.com/fitscreen.js/dist/fitscreen.min.js"></script> -->
  <script src="https://unpkg.com/fitscreen.js/dist/fitscreen.js"></script>
  <script>
    const { calcRate, resize, unResize } = FitScreen({
      el: document.querySelector('.test'),
      width:1920,
      height:1080,
      mode:'fit',
      executeMode:'debounce',
      waitTime:300,
      beforeCalculate(scale) {},
      afterCalculate(scale) {},
    })
  </script>
</body>

</html>

Of course, you can also use package managers such as npm for engineering development

npm install fitscreen.js
# or
yarn add fitscreen.js
# or
pnpm install fitscreen.js

Options

declare function FitScreen(options: Options): FitScreenResult | undefined

interface FitscreenResult {
  /**
   * The function of calculating the ratio, you can decide the timing of execution by yourself
   */
  calcRate: () => void
  /**
   * Start listening to the resize event
   */
  resize: () => void
  /**
   * End listening to the resize event
   */
  unResize: () => void
}

interface Options {
  /**
   * Template element, this element is recommended to be set to the size, width and height of the design draft
   */
  el: HTMLElement
  /**
   * The design draft width
   * @default 1920
   */
  width?: number
  /**
   * The design draft height
   * @default 1080
   */
  height?: number
  /**
   * Calculation mode
   */
  mode?: 'fit' | 'scrollX' | 'scrollY' | 'full'
  /**
   * Represents the execution mode for calculating scaling ratio.
   * - throttle: Uses a throttling mechanism to limit the execution frequency.
   * - debounce: Uses a debouncing mechanism to delay execution until a certain period of inactivity.
   * - none: Executes the function without any throttling or debouncing.
   * @default 'debounce'
   */
  executeMode?: 'throttle' | 'debounce' | 'none'
  /**
   * Represents the execution rate for debounce and throttle (unit: ms).
   * @default 300
   */
  waitTime?: number
  /**
   * Triggered before calculating correction, which can be calculated by return false to cancel
   * Provide the current wide high percentage
   */
  beforeCalculate?: (scale: Scale) => boolean | void
  /**
   * After the calculation of correction
   * Provide the current wide high percentage
   */
  afterCalculate?: (scale: Scale) => void
}

🌰 Example

CodePen CodeSandbox Stackblitz Stackblitz

🚨 Note

I don't know if it can solve your problem. If not, you can discuss it in issues. If you have a problem and solve it, you are welcome to raise a PR to help others. If this project helps you, please give me a star thank you.😎

Click

License

MIT License © 2022 jp-liu