# top-most

> respond to the top most visible DOM element changing

Latest version **0.1.3** (published 2013-12-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install top-most
pnpm add top-most
yarn add top-most
bun add top-most
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.3 |
| Published | 2013-12-12 |
| First published | 2013-08-17 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Jake Rosoman |
| Maintainers | jkroso |
| Keywords | top, resize, scroll |

## Links

- npm: https://www.npmjs.com/package/top-most
- Repository: https://github.com/jkroso/top-most
- Issues: https://github.com/jkroso/top-most/issues
- npm.io page: https://npm.io/package/top-most

## Dependencies (3)

- [emitter](https://npm.io/package/emitter.md) jkroso/emitter#0.9.0
- [viewport](https://npm.io/package/viewport.md) jkroso/viewport#0.1.5
- [setter-method](https://npm.io/package/setter-method.md) ~0.1.0

## Alternatives

- [exif-parser](https://npm.io/package/exif-parser.md) — 3.8M weekly downloads
- [vite-plugin-compression](https://npm.io/package/vite-plugin-compression.md) — 569.5K weekly downloads
- [pica](https://npm.io/package/pica.md) — 442.4K weekly downloads
- [@reportportal/client-javascript](https://npm.io/package/@reportportal/client-javascript.md) — 408.8K weekly downloads
- [@tldraw/state](https://npm.io/package/@tldraw/state.md) — 316.0K weekly downloads

## Recent versions

- 0.1.3 (latest) — 2013-12-12
- 0.1.2 — 2013-08-17
- 0.1.0 — 2013-08-17

## README

# top-most

  respond to the top most visible DOM element changing

## Installation

_With [component](//github.com/component/component), [packin](//github.com/jkroso/packin) or [npm](//github.com/isaacs/npm)_  

	$ {package mananger} install jkroso/top-most

then in your app:

```js
var topmost = require('top-most')
```

## API

### topmost(items, [fn])

  create a new TopCell. If you pass a function be invoked with the current top-most node and subscribed to future changes. At least ones which arise from the browser resizing or scrolling. Its up to you to notify it of other possible changes such as DOM mutation.

### TopCell.buffer(n)

  get/set the Cells buffer. Buffer meaning the number of pixels which must be shown before a node is considered "on-screen"

### TopCell.change()

  check if the top most node has changed. If it has a
  "change" event will be emitted. You might want to call this after doing some DOM mutation etc..

### TopCell.destroy()

  clean up

## Example

```js
topmost(document.getElementsByTagName('section'))
  .buffer(30)
  .on('change', function(el, index){
    console.log('the %dth item is the top-most', index)
  })
  .change()
```

## Running the Example

Just run `make` and navigate your browser to [example.html](example.html).

## Thanks

Inspired by and based on [timoxley/scroll-position](//github.com/timoxley/scroll-position)

---
_Source: https://npm.io/package/top-most · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
