# @kovalenko/scroll-here

> Scrolls specified container to the element with this directive when it's condition becomes truthy.

Latest version **1.0.0** (published 2023-05-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install @kovalenko/scroll-here
pnpm add @kovalenko/scroll-here
yarn add @kovalenko/scroll-here
bun add @kovalenko/scroll-here
```

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2023-05-17 |
| First published | 2021-04-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 38.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Kovalenko |
| Maintainers | kovalenko |
| Keywords | angular, scroll |

## Links

- npm: https://www.npmjs.com/package/@kovalenko/scroll-here
- Repository: https://github.com/menelai/scroll-here
- Homepage: https://github.com/menelai/scroll-here#readme
- Issues: https://github.com/menelai/scroll-here/issues
- npm.io page: https://npm.io/package/@kovalenko/scroll-here

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.0.0

## Recent versions

- 1.0.0 (latest) — 2023-05-17
- 0.0.7 — 2022-03-06
- 0.0.6 — 2021-04-29
- 0.0.5 — 2021-04-29
- 0.0.4 — 2021-04-29

## README

# ScrollHere

Scrolls specified container to the element with this directive when it's condition becomes truthy.

## Installation

```
npm install @kovalenko/scroll-here
```

## Supported API

### Properties

| @Input() | Type | Required | Default | Description |
| --- | --- | --- | --- | --- |
| ngcScrollHere | boolean | required | | Sets condition when to start scrolling
| ngcScrollContainer | string / HTMLElement	| optional | 'html' | Place this attribute BEFORE [ngcScrollHere] in template. Should get a html element or css selector for a scrollable element; window will be used if this attribute is empty
| ngcScrollDuration | number | optional | 200 | Sets the scroll duration


### Events

| @Output() | Type | Event Type | Required | Description |
| --- | --- | --- | --- | --- |
| ngcScrollTriggered | EventEmitter | void | optional | this will callback if start scrolling condition has been met
| ngcScrollFinished | EventEmitter | void | optional | this will callback if scrolling has been finished

## Usage

First, import the ScrollHereModule to your module:

```typescript
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { ScrollHereModule } from '@kovalenko/scroll-here';
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppComponent } from './app';

@NgModule({
  imports: [BrowserModule, ScrollHereModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent],
})
export class AppModule {}

platformBrowserDynamic().bootstrapModule(AppModule);
```

In this example, window will be scrolled to inner div and when **ngcScrollFinished** callback will be invoked the window will be scrolled to outer div 

```typescript
import { Component } from '@angular/core';

@Component({
  selector: 'app',
  template: `
    <div style="padding-top: 3000px" [ngcScrollHere]="toTop" [ngcScrollDuration]="4000">
      <div [ngcScrollHere]="!triggered && s" [ngcScrollDuration]="2000" (ngcScrollTriggered)="triggered = true" (ngcScrollFinished)="toTop = true">Bottom</div>
    </div>
  `,
})
export class AppComponent {
  s = true;
  triggered = false;
  toTop = false;
}
```

## License

MIT

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