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

@cniot/canvas2flex

v0.0.12

Published

canvas绝对定位转flex布局

Downloads

26

Readme

canvas画布中的绝对位置转换成flex布局,适应动态缩放能力

TODO:

  1. 抽离核心代码
  2. fixed布局支持(重要)在canvasConfig里增加一个position参数
  3. 绝对定位支持
  4. 使用rollup打包
  5. 最小最大高度解析
  6. 自适应规则(宽度按照百分比来算,高度改成min-height)
  7. 高度相等的时候,出现了丢元素的情况

使用方式

import {transformMethod} from '@cniot/canvas2flex'
let res = transformMethod(data);
let {finalTransData} = res; // finalTransData里就包含了转换过后的所有数据

转换后字段含义:

{
    "start":0, // 起始位置
    "end":36, // 终止位置
    "children":[], // 子元素列表
    "type":"horizontal", // 横切还是纵切
    "proportion":"0.05000", // 这个元素占这一层元素的比例(用来计算宽度百分比)
    "canvasConfig":{
      "y":0,
      "height":36
    },//起始位置和高度
    "level":1, // 层级
    "isFillComponent":true, // 是不是一个填充元素
    "flexLayout":{
    "display":"flex",
      "flexDirection":"row",
      "flexGrow":0,
      "flexShrink":0,
      "minWidth":"0px",
      "height":"36px"
    }, // 这个元素的样式
    "tagName":"div" //只要是填充元素,tagName就是div
}

更新日志

###0.0.11:

  1. 增加zIndex布局支持

0.0.9:

  1. 修复图片不显示的问题
  2. 增加lockedWidth/lockedMarginRight/lockedMarginLeft 三个属性,用来锁定边距