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 🙏

© 2024 – Pkg Stats / Ryan Hefner

adaptorjs

v1.0.1

Published

adaptorjs 是一款自适应的大屏工具,适用于 react/vue 等框架

Downloads

20

Readme

主要解决的问题

大屏适配主要是解决屏幕尺寸比和设计稿尺寸比不一致的问题,采用的方法是:scale

虽然这种方案并不完美,但也是目前比较好的解决方案

比如在 pc 上就不是特别完美,特别是老型号 windows 机器,分辨率各种各样

但在大屏上看就会很完美,因为大屏的分辨率一般都是 16:9 的,而设计稿一般都是 1920*1080

然后在使用 scale 缩放时,主要有 3 个问题

  1. 地图上的点位会出现偏移/点击位置不准
  2. 使用到 overflow: scroll 的地方,文本可能会出现模糊
  3. 在使用第三方组件时,比如下拉框等不会缩放

开发这个组件就是为了解决这 3 个问题

使用

  1. 安装
npm i adaptorjs
# 或
yarn add adaptorjs
# 或
pnpm i adaptorjs
  1. 引入
import Adaptor from "adaptorjs";
  1. 快速使用
const adaptor = new Adaptor({
  designHeight: 1080,
  designWidth: 1920,
  querySelector: "#app",
  extraSelectors: [".xxx"],
});

注意事项

要在 dom 加载完成后再初始化

  1. react 中使用
useEffect(() => {
  const adaptor = new Adaptor({
    designHeight: 1080,
    designWidth: 1920,
    querySelector: "#app",
    extraSelectors: [".xxx"],
  });
  return () => {
    adaptor.destroy();
  };
}, []);
  1. vue 中使用
let adaptor;
onMounted(() => {
  adaptor = new Adaptor({
    designHeight: 1080,
    designWidth: 1920,
    querySelector: "#app",
    extraSelectors: [".xxx"],
  });
});

onUnmounted(() => {
  adaptor.destroy();
});
  1. 参数说明
querySelector: string // 大屏根选择器,必选
extraQuerySelectors?: string[]; // 需要额外缩放的 dom 选择器,可选
designWidth?: number; // 设计稿宽度,可选,默认 1920
designHeight?: number; // 设计稿高度,可选,默认 1080
type?: ScaleType; // 缩放类型,可选,默认 scale

最终实现效果

Jietu20230530-200728-HD.gif

demo

git clone https://github.com/astak16/adaptorjs.git

cd adaptorjs

pnpm i

pnpm dev