# @ctrl/ngx-headroom 中文文档

规范地址：https://npmcn.com/package/%40ctrl/ngx-headroom/

版本：5\.0\.0
npm 元数据更新时间：2022-04-05T02:04:31.253Z
中文译文更新时间：2026-11-16T05:42:40.957Z
软件包许可：MIT

本文由上游 README 翻译，可能存在偏差，请结合原文核对 API、命令与配置。版权与许可归原作者所有。

原始 npm 页面：https://www.npmjs.com/package/%40ctrl/ngx-headroom
原文对照：https://npmcn.com/package/%40ctrl/ngx-headroom/?lang=original
项目主页：https://github.com/typectrl/ngx-headroom
源码仓库：https://github.com/typectrl/ngx-headroom

## 关键信息（来自 npm 元数据）

- 包体积（解压后）：119 kB，17 个文件
- 模块格式：ES Module
- TypeScript 类型：包内自带
- 运行依赖：1 个
- peer 依赖：@angular/animations \>=12\.0\.0，@angular/core \>=12\.0\.0
- 首次发布：2017-12-17T05:52:19.755Z
- 最新版本发布：2021-11-28T22:10:41.366Z
- 近 30 天下载量：1956（2026-10-11 至 2026-11-09，npm 官方下载统计）
- 已发布版本数：24（近 12 个月 0 个）

## 中文简介

在Angular的执行

## 安装

```sh
npm install @ctrl/ngx-headroom
```

也可以使用：`pnpm add @ctrl/ngx-headroom`、`yarn add @ctrl/ngx-headroom`、`bun add @ctrl/ngx-headroom`

## README

# ngx-前厅

  
 [![npm](https://badge.fury.io/js/%40ctrl%2Fngx-headroom.svg)](https://www.npmjs.com/package/@ctrl/ngx-headroom)[![circleci](https://circleci.com/gh/TypeCtrl/ngx-headroom.svg?style=svg) ](https://circleci.com/gh/TypeCtrl/ngx-headroom)[![codecov](https://img.shields.io/codecov/c/github/typectrl/ngx-headroom.svg)](https://codecov.io/github/typectrl/ngx-headroom)  
  

戴莫: [https://ngx-headroom.netlify.com/ 互联网档案馆的存檔,存档日期2013-12-22](https://ngx-headroom.netlify.com/)

角组件来隐藏/显示滚动上的标题 。 港口 [反应室](https://github.com/KyleAMathews/react-headroom) 由Kyleamathews 制作, 围绕 [会议室.js](https://github.com/WickyNilliams/headroom.js)

固定头对持续导航是不错的,但也可以通过占用宝贵的垂直屏幕空间来阻拦. 使用此组件, 您可以在不需要导航时保留屏幕空间的同时, 保留您的持续导航 .

## 依赖关系

每个版本的最新版本

| ngx-前厅 | 角质 |
| --- | --- |
| 2.3.2 | 6.x 7.x (中文(简体) ) |
| 3.0.3 信息技术 | 8.x 9.x (中文(简体) ) |
| 4.0.0 (单位:千美元) | 10.x 11.x (英语) |
| 当前 | \>= 12.x |

## 安装

```sh
npm install @ctrl/ngx-headroom
```

## 使用角头室

导入模块 。 要求数 `@angular/animations`

```ts
// requires BrowserAnimationsModule
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
// import HeadroomModule
import { HeadroomModule } from '@ctrl/ngx-headroom';
```

使用模块

```html
<ngx-headroom>
  <h1>You can put anything you'd like inside the Headroom Component</h1>
</ngx-headroom>
```

### 覆盖动画

组件是用来插上"n play"的 意思是 它有合理的默认 用于动画头的进出。 如果你想推翻默认的动画.

通过传递自己的数值来覆盖动画默认值

```html
<ngx-headroom duration="500" easing="ease-in-out">
  <h1>You can put anything you'd like inside the Headroom Component</h1>
</ngx-headroom>
```

### 投入

-   `duration` - 动画持续时间以毫秒计
-   `easing` - 简化动画
-   `upTolerance` ——在组件被粘住前滚动时用px滚动可容忍性
-   `downTolerance` ——当组件被固定前向下滚动时,在px中滚动容积
-   `disable` ——禁用接线和取消接线
-   `wrapperStyle` ——通过包装div的样式(这保持了页面上方的组件垂直空间).
-   `parent` ——为滚动事件提供自定义的"家长"元素. `parent` 职能应是解决所需因素.
-   `pinStart` 高度在px中,其中头部应该开始并停止打针. 当您在主室组件上方有另一个元素时有用 .

### 产出

-   `pin` - 封住头部时发射
-   `unpin` - 当信头被钉住时发射
-   `unfix` - 当信头位置不再固定时发射

* * *

> GitHub 图像 [@scttcper (英语)](https://github.com/scttcper)  • 妇女  微博 [@scttcper (英语)](https://twitter.com/scttcper)

## 常见问题

### @ctrl/ngx-headroom 是什么？

在Angular的执行

### 如何安装 @ctrl/ngx-headroom？

在项目目录运行 npm install @ctrl/ngx-headroom，或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖：@angular/animations（\>=12\.0\.0）、@angular/core（\>=12\.0\.0）。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖，Yarn 需要手动安装。

### @ctrl/ngx-headroom 支持 TypeScript 吗？

支持。包内自带 TypeScript 类型声明（package\.json 声明了 types 入口），安装后即可获得类型提示，无需再安装 @types 包。

### @ctrl/ngx-headroom 支持 ESM 还是 CommonJS？

以 ES Module 形式发布，推荐使用 import 引入。在 CommonJS 项目中，Node\.js 20\.19\+ / 22\.12\+ 可以直接 require\(\) 不含顶层 await 的 ES Module，更早的版本需要改用动态 import\(\)。

### @ctrl/ngx-headroom 可以商用吗？

@ctrl/ngx-headroom 使用 MIT 许可。宽松许可：允许商业使用、修改和再分发，通常只需在分发时保留原版权与许可声明。以上为概括，不构成法律意见，请以许可原文为准。

### @ctrl/ngx-headroom 的下载量有多少？

根据 npm 官方下载统计，@ctrl/ngx-headroom 在 2026/10/11 – 2026/11/09 这 30 天内被下载 1,956 次，日均约 65 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入，适合横向比较热度，不能直接等同于使用人数。

### @ctrl/ngx-headroom 还在维护吗？

最新版本 5\.0\.0 发布于 2021/11/29（4 年前）；至今共发布 24 个版本，其中过去 12 个月发布了 0 个；首次发布于 2017/12/17。发布频率只是参考信号：功能稳定的工具可能很少需要更新，建议结合源码仓库的 issue 和提交记录判断。

