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

vfit

v1.0.6

Published

A tiny Vue 3 plugin to auto-fit UI scale based on container size, plus a FitContainer component for easy positioning.

Readme

vfit

官网:https://web-vfit.netlify.app

作者:一颗烂土豆

Vue 3 的轻量缩放与定位解决方案。通过插件提供全局缩放值,并内置 FitContainer 组件,让页面元素在不同分辨率下保持比例与位置一致。

安装与初始化

npm i vfit
// main.ts
import { createFitScale } from 'vfit'
import 'vfit/style.css'

app.use(createFitScale({ target: '#app', designHeight: 1080, designWidth: 1920, scaleMode: 'auto' }))

快速上手

  • 父容器需设置定位属性:position: relative(推荐)或 absolute
  • 两种坐标单位:
    • %:位置不随缩放变化,适合居中/相对位置
    • px:位置随缩放乘积变化,适合固定像素布局

居中(百分比)

<template>
  <div class="viewport">
    <FitContainer :top="50" :left="50" unit="%">
      <div class="card">内容</div>
    </FitContainer>
  </div>
</template>

<style scoped>
.viewport { position: relative; width: 100%; height: 100vh; }
.card { transform: translate(-50%, -50%); }
</style>

要点:top/left 为百分比时,位置不受缩放影响;仅内部内容按比例缩放。

像素定位(随缩放)

<template>
  <div class="viewport">
    <FitContainer :top="90" :left="90" unit="px">
      <div class="box">内容</div>
    </FitContainer>
  </div>
</template>

<style scoped>
.viewport { position: relative; width: 100%; height: 100vh; }
.box { width: 120px; height: 80px; }
</style>

要点:容器缩放后,像素坐标会乘以缩放值(如 left * scale)。

API 精简版

  • createFitScale({ target?, designHeight?, designWidth?, scaleMode? })
    • target:监听缩放的容器(默认 #app
    • designHeight:设计稿高度(默认 1080
    • designWidth:设计稿宽度(默认 1920
    • scaleMode'height' | 'width' | 'auto'(默认 auto
      • height:按高度缩放,比例为 容器高度 / 设计稿高度
      • width:按宽度缩放,比例为 容器宽度 / 设计稿宽度
      • auto:根据容器宽高比与设计比(设计稿宽度 / 设计稿高度)自动选择按宽或按高
  • useFitScale():在组件内获取当前缩放值 Ref<number>
  • FitContainer 组件属性:
    • top/bottom/left/right?: number
    • unit?: 'px' | '%'(默认 px
    • scale?: number(覆盖全局缩放)

小贴士

  • 使用 unit='px' 时,top/left 随缩放变化,right/bottom 保持实际像素距离不变
  • 使用 right 时,缩放原点为右上角;同时设置 bottomright 时为右下角
  • 首次接入时,务必引入样式:import 'vfit/style.css'

React 支持

该库的 React 版本请访问 vfit-react