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

@fekit/mc-ratio

v1.0.6

Published

一个移动端大小屏自适应方案支持插件,可以横向自适应和横竖双向自适应,包括根字号全局适配和标签区域内局部自适应。并且可以开启DPR让网页UI达到原生APP的细腻程度

Downloads

3

Readme

#MC-RATIO

一个移动端大小屏自适应方案支持插件,可以横向自适应和横竖双向自适应,包括根字号全局适配和标签区域内局部自适应。并且可以开启DPR让网页UI达到原生APP的细腻程度

索引

演示

https://fekit.asnowsoft.com/plugins/mc-ratio/

开始

下载项目:

git clone https://gitlab.com/fekits/mc-ratio.git
npm i mc-ratio

参数

    {
        el   : 'id',               {DomObject}   DOM对象,如果不填则默认为HTML根标签
        size : [750, 1334],        {Number}      设计稿的尺寸
        full : true | false,       {Boolean}     是否开启全屏模式?如果开启开屏模式则对宽度和高度双向自适应 *
        dpr:   true | false        {Boolean}     开启DPR功能,开启DPR后网页尺寸将设置为设备物理分辨率,网页1px可以达到原生APP细腻程度
        fixed: 2                   {Number}      设置字号精度为小数点后2,一般建议为2位
        then : function () {}      {Function}    自适应字号改变时的回调
        max  : 750                 {Number}      最大尺寸,超过这个尺寸不再放大
        min  : 320                 {Number}      最小尺寸,超过这个尺寸不再缩小
    }

示例

基础自适应:

ratio({
  size:  [750, 1334],                  // 设计稿的尺寸
});

双向自适应:

ratio({
  size:  [750, 1334],                  // 设计稿的尺寸
  full:  true,                         // 开启全屏模式,将对宽度和高度双向自适应缩放,这种模式一般用于无滚动条的全屏页面。
  fixed: 2                             // 设置字号精度为小数点后2位
});

DPR高清方案:

ratio({
  size:  [750, 1334],                  // 设计稿的尺寸
  full:  true,                         // 开启全屏模式,将对宽度和高度双向自适应缩放,这种模式一般用于无滚动条的全屏页面。
  dpr:   true,                         // 开启DPR功能,物理像素细腻度
});

限制最大尺寸:

ratio({
  size:  [750, 1334],                  // 设计稿的尺寸
  full:  true,                         // 开启全屏模式,将对宽度和高度双向自适应缩放,这种模式一般用于无滚动条的全屏页面。
  max:   750,                          // 超过750的尺寸不再放大
});

局部自适应

// 以下示例仅对指定ID为area的元素做自适应,需要注意的是,如果你仅对网页中的部分区域做自适应,请勿开启dpr功能,该功能将影响全局网页
ratio({
  el:    document.getElementId('area'),    // 为ID为area的标签设置自适应字号,当字号不是设置在HTML根标签时,只能在区域内用em方案自适应
  size:  [750, 1334],                      // 设计稿的尺寸
  fixed: 2
});

版本

v1.0.5 [Latest version]
1、整理文档与DEMO
v1.0.3 [Latest version]
1、新增了max和min设置最大和最小缩放尺寸
v1.0.2
1、新增了dpr功能,开启了DPR功能后,可以自动设置设备尺寸为物理分辨率使网页达到原生APP精细效果。就是解决经典的1px太粗问题
2、新增了fixed参数可以设置字号缩放时的小数字精度。
v1.0.0
1、实现了横向自适应和横竖双向自适应,并且竖向自适应可自由设定阀值。
2、可以设置根字号全局适配和标签区域内局部自适应。