An open API service indexing awesome lists of open source software.

https://github.com/akshykhade/ngx-foresight

foresightjs implementation for Angular
https://github.com/akshykhade/ngx-foresight

angular keyboard-tracking mouse-tracking performance prefetching speed

Last synced: 4 months ago
JSON representation

foresightjs implementation for Angular

Awesome Lists containing this project

README

          








npm version


npm downloads


last-update


license


bundle size

# ngx-foresight - [🚀 Demo](https://akshykhade.github.io/ngx-foresight/)

[foresightjs](https://foresightjs.com/) implementation for Angular. It provides router preloading strategy which automatically downloads the lazy-loaded module based on foresightjs prediction of user intent from mouse and keyboard.

[🚀 Demo](https://akshykhade.github.io/ngx-foresight/)

## Usage

![Screenshot](public/example.gif)

## installation

```bash
npm install js.foresight js.foresight-devtools ngx-foresight
# or
pnpm install js.foresight js.foresight-devtools ngx-foresight
```

After that import the `ForesightjsDirective` to the components with `href` and `routerLink`, and use the `ForesightjsStrategy` as `preloadingStrategy` in the router's configuration. For example:

```ts
import { ForesightManager } from 'js.foresight';
import { ForesightDebugger } from 'js.foresight-devtools';
import { ForesightjsDirective } from 'ngx-foresight';

ForesightManager.initialize({
enableMousePrediction: true,
positionHistorySize: 8,
trajectoryPredictionTime: 80,
defaultHitSlop: 10,
enableTabPrediction: true,
tabOffset: 3,
enableScrollPrediction: true,
scrollMargin: 150,
});

ForesightDebugger.initialize(ForesightManager.instance, {
showDebugger: true,
isControlPanelDefaultMinimized: true, // optional setting which allows you to minimize the control panel on default
showNameTags: true, // optional setting which shows the name of the element
sortElementList: 'visibility', // optional setting for how the elements in the control panel are sorted
});
```

```html


```

```ts
// configure preloading strategy as per routes
provideRouter(routes, withPreloading(ForesightjsStrategy)),
```

Inspired by ngx-quicklink - [ngx-quicklink](https://github.com/mgechev/ngx-quicklink)