kit-hammer

API

[class] KitHammerProvider

@Injectable

Provided in:'root'

Provides Hammer.JS instance if available.

Also you can manually inject HammerJS instance in the root module:

import * as Hammer from 'hammerjs';
import { kitHammerInstance } from '@ngx-kit/core';
...
@NgModule({
  ...
  providers: [
    {
      provide: kitHammerInstance,
      useValue: Hammer,
    },

But be aware, Hammer.JS does not support server-side rendering.

That's why it is better just to add it via angular.json scripts section:

...
"scripts": [
  "node_modules/hammerjs/hammer.js",
],

Members

SignatureDescription
get hammer()

Get Hammer.JS. Returns null if not available.

calcRelatedPosition(el: HTMLElement, center: {x: number, y: number}): {x: number, y: number}

Get event position relative to passed element, not the viewport.