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

single-screen-utils

v1.0.1

Published

single screen utils

Downloads

9

Readme

single-screen-utils

NPM version NPM downloads

单屏页面布局常用工具方法

dynamicRem: 单屏页面时,既需要根据屏幕宽度也需要根据屏幕高度进行rem设置 (常规rem方案,仅使用屏幕宽度进行等比例划分)

forceLandscape: 强制元素横屏方案

Install

npm install single-screen-utils

yarn add single-screen-utils

Quickstart

dynamicRem

普通方法

import { dynamicRem } from 'single-screen-utils';

// 返回一个销毁函数
const destroy = dynamicRem();

hooks方法

import { useDynamicRem } from 'single-screen-utils';

const App = () => {
  // 自动销毁
  useDynamicRem();

  return (
    <div id="app">App</div>
  )
};

forceLandscape

普通方法

import { forceLandscape } from 'single-screen-utils';

// 返回一个销毁函数
const destroy = forceLandscape();

hooks方法

import { useForceLandscape } from 'single-screen-utils';

const App = () => {
  // 自动销毁
  useForceLandscape();

  return (
    <div id="app">App</div>
  )
};

API

dynamicRem: 根据页面宽高比动态设置html的rem大小

参数:

| 属性 | 说明 | 类型 | 默认值 | | :-------------- | ----------------------- | --------------------------------------- | ---------------------- | | pageWidth | 设计稿的宽度 (px) | number | 750 | | pageHeight | 设计稿的高度 (px) | number | 1334 | | pageFontSize | 页面html元素的字体 (px) | number | 100 | | pageAspectRatio | 页面宽高比 | number | pageWidth / pageHeight | | mode | 横屏模式/竖屏模式 | ModeType.portrait | ModeType.landscape | ModeType.portrait 竖屏 |

返回值:

返回一个函数,调用此函数取消事件监听

| 类型 | 说明 | | -------- | ------------------------------- | | (resetFontSize?: string | number) => void | 取消rem动态设置,还原默认的字体 |

静态常量:

dynamicRem.ModeType.portrait 竖屏模式 (0)

dynamicRem.ModeType.landscape 横屏模式 (1)


forceLandscape: 强制元素横屏

参数:

| 属性 | 说明 | 类型 | 默认值 | | ---------- | ------------------------------------------------------------ | ---------------------------------------------- | --------------- | | Id | 需要强制横屏的元素id | string | #app | | detectType | 判断是否横屏的依据 DetectType.size 宽度比高度大,认为是横屏 DetectType.orientation 设备方向是90或者-90,认为是横屏 | DetectType.size | DetectType.orientation | DetectType.size | | delay | 防抖时间(ms) | number | 800 |

返回值:

返回一个函数,调用此函数取消事件监听

| 类型 | 说明 | | -------- | ------------------------------- | | () => void | 取消事件监听,不再强制横屏 |

静态常量:

forceLandscape.DetectType.size 宽度比高度大,认为是横屏 (0)

forceLandscape.DetectType.orientation 设备方向是90或者-90,认为是横屏 (1)

Develop

yarn install

npm run dev

npm run build