@advanced-rest-client/arc-fit-mixin

中文文档
1.2.3发布于 2021/10/17Apache-2.0ESM + CJS近 30 天下载 4722

arc-fit-mixin is a port of iron-fit-behavior that works with web components

原始使用文档
文档目录6 节
  1. Deprecation notice
  2. Installation
  3. Usage
  4. Testing
  5. Testing with Sauce Labs
  6. Demo

DEPRECATED

Use the @anypoint-web-components/awc module instead.


Published on NPM

Tests and publishing

This mixin is a port of iron-fit-behavior that works with LitElement.

ArcFitMixin fits an element in another element using max-height and max-width, and optionally centers it in the window or another element. The element will only be sized and/or positioned if it has not already been sized and/or positioned by CSS.

CSS propertiesAction
position setElement is not centered horizontally or vertically
top or bottom setElement is not vertically centered
left or right setElement is not horizontally centered
max-height setElement respects max-height
max-width setElement respects max-width

ArcFitMixin can position an element into another element using verticalAlign and horizontalAlign. This will override the element's css position.

<div class="container">
  <arc-fit-impl verticalalign="top" horizontalalign="auto">
    Positioned into the container
  </arc-fit-impl>
</div>

Use noOverlap to position the element around another element without overlapping it.

<div class="container">
  <arc-fit-impl nooverlap verticalalign="auto" horizontalalign="auto">
    Positioned around the container
  </arc-fit-impl>
</div>

Use horizontalOffset, verticalOffset to offset the element from its positionTarget; ArcFitMixin will collapse these in order to keep the element within fitInto boundaries, while preserving the element's CSS margin values.

<div class="container">
  <arc-fit-impl verticalalign="top" verticaloffset="20">
    With vertical offset
  </arc-fit-impl>
</div>

Deprecation notice

The following attributes are supported for compatibility with older and Polymer elements but eventually will be removed and replaced wit the corresponding new attribute.

  • sizing-target > sizingtarget
  • fit-into > fitinto
  • no-overlap > nooverlap
  • position-target > positiontarget
  • horizontal-align > horizontalalign
  • vertical-align > verticalalign
  • dynamic-align > dynamicalign
  • horizontal-offset > horizontaloffset
  • vertical-offset > verticaloffset
  • auto-fit-on-attach > autofitonattach

Installation

npm i @advanced-rest-client/arc-fit-mixin

Usage

import { LitElement } from 'lit-element';
import { ArcFitMixin } from '@advanced-rest-client/arc-fit-mixin';

class ArcFitImpl extends ArcFitMixin(LitElement) {
  static get properties() {
    return {
      myProp: { type: Object, attribute: 'my-prop' },
    };
  }
}

Testing

npm run test

Testing with Sauce Labs

npm run test:sl

Demo

npm start

版本与发布记录

@advanced-rest-client/arc-fit-mixin 共发布 9 个版本,首次发布于 2019/06/07;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.2.3latest2021/10/175 年前
1.2.22021/03/135 年前
1.2.12020/10/036 年前
1.2.02020/07/026 年前
1.1.02020/06/096 年前
1.0.32019/12/106 年前

关于 @advanced-rest-client/arc-fit-mixin 的常见问题

@advanced-rest-client/arc-fit-mixin 是什么?

arc-fit-mixin is a port of iron-fit-behavior that works with web components

如何安装 @advanced-rest-client/arc-fit-mixin?

在项目目录运行 npm install @advanced-rest-client/arc-fit-mixin,或使用 pnpm add / yarn add / bun add。

@advanced-rest-client/arc-fit-mixin 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/advanced-rest-client__arc-fit-mixin 是否存在。

@advanced-rest-client/arc-fit-mixin 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@advanced-rest-client/arc-fit-mixin 可以商用吗?

@advanced-rest-client/arc-fit-mixin 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@advanced-rest-client/arc-fit-mixin 的下载量有多少?

根据 npm 官方下载统计,@advanced-rest-client/arc-fit-mixin 在 2026/10/05 – 2026/11/03 这 30 天内被下载 4,722 次,日均约 157 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@advanced-rest-client/arc-fit-mixin 还在维护吗?

最新版本 1.2.3 发布于 2021/10/17(5 年前);至今共发布 9 个版本,其中过去 12 个月发布了 0 个;首次发布于 2019/06/07。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。