kolkov / ngx-gallery

A simple responsive native gallery component for Angular 8+.
https://ngx-gallery.kolkov.ru/
MIT License
115 stars 56 forks source link

Swipe is not working at Angular 9 #34

Closed f3l1xss closed 4 years ago

f3l1xss commented 4 years ago

Hi, previously using ngx-gallery here. After I updated my apps to Angular 9, swiping doesn't seem to work anymore.

I have tried adding this class to my app module config:

export class CustomHammerConfig extends HammerGestureConfig { overrides = { pinch: { enable: false }, rotate: { enable: false }, }; }

but doesn't seem to work either

windcloak commented 4 years ago

I have this in my Angular 9 code and it's swiping:

import 'hammerjs';

import { HammerModule } from '@angular/platform-browser';

import {
  HammerGestureConfig,
  HAMMER_GESTURE_CONFIG
} from '@angular/platform-browser';

export class MyHammerConfig extends HammerGestureConfig {
  overrides = {
    pinch: { enable: false },
    rotate: { enable: false } as any
  };
}
f3l1xss commented 4 years ago

@windcloak I have already had that but still it wont swipe, by swiping I meant swiping with finger at touch screen:)

I have already put above configuration at my app.module.ts providers list: providers: [ { provide: HAMMER_GESTURE_CONFIG, useClass: CustomHammerConfig }, { provide: HTTP_INTERCEPTORS, useClass: AjaxHeaderInterceptor, multi: true } ],

Are you able to post your app.module config? and the gallery config too perhaps? Thank you

windcloak commented 4 years ago

app.module https://github.com/windcloak/firecloak-web/blob/master/src/app/shared/module.ts

gallery component https://github.com/windcloak/firecloak-web/blob/master/src/app/shared/components/cosplay-gallery/cosplay-gallery.component.ts

f3l1xss commented 4 years ago

Have spent half day to resolve this turns out its just one line fix to import HammerModule as described here:

https://github.com/angular/angular/pull/32203

By default Ivy (Angular 9) will NO longer include HammerSupport and thereby we have to import it manually at root.

@windcloak Thank you, had to went through your code to find out, I like your cosplay:)

And its no longer neccessary to create custom config like this: providers: [ { provide: HAMMER_GESTURE_CONFIG, useClass: CustomHammerConfig }, { provide: HTTP_INTERCEPTORS, useClass: AjaxHeaderInterceptor, multi: true } ],

as well as to include hammer.js script at angular.json, swiping will work just by importing HammerModule

windcloak commented 4 years ago

@f3l1xss Neat, I'll have to clean that up. Less code to mess with is definitely better.