ionic-gallery-modal icon indicating copy to clipboard operation
ionic-gallery-modal copied to clipboard

ion-content scroller stopped working on device

Open kajalbh99 opened this issue 6 years ago • 4 comments

Package is working fine in browser. But when i run Apk in device, I found content scroll stopped working...

kajalbh99 avatar Jun 08 '18 10:06 kajalbh99

Same problem here with me @kajalbh99. Any news on that? I'll take a closer look at this later, but I feel like that's a problem with HAMMER_GESTURE_CONFIG, which we need to import in order to get the gallery working. I've found this https://github.com/hammerjs/hammer.js/issues/1014 and this https://stackoverflow.com/questions/41017202/vertical-scroll-is-not-working-with-hammerjs-and-angular2/41522140. Kinda sketchy, but I'm taking anything at this point. The home screen of my app is not scrolling. I'll try this or be forced to remove the gallery all together.

hudsonsilvaoliveira avatar Aug 23 '18 11:08 hudsonsilvaoliveira

GOT IT!

Based on https://github.com/hammerjs/hammer.js/issues/1014#issuecomment-298724577, I've managed to got everything working now.

Going throught the files I've saw that the ionicGalleryModal.GalleryModalHammerConfig is nothing more than a extend of the standard HammerGestureConfig from @angular/platform-browser. So, I just combined the GalleryModalHammerConfig with the HammerGestureConfig in my own class. The code turned out like this:

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

declare var Hammer: any;

export class HammerConfig extends HammerGestureConfig {
    overrides: {
        pan: {
            direction: number;
        };
        press: {
            time: number;
        };
    };

    buildHammer(element: HTMLElement) {
      let mc: any = new Hammer(element, {
        touchAction: "pan-y"
      });
      return mc;
    }
}

@NgModule({
    declarations: [],
    imports: [
        ionicGalleryModal.GalleryModalModule
    ],
    providers: [
        { provide: HAMMER_GESTURE_CONFIG, useClass: HammerConfig }
    ]
})

It's working now, I hope it'll help. I don't really know why that happened tho, would be very helpful if someone could point that out.

hudsonsilvaoliveira avatar Aug 23 '18 19:08 hudsonsilvaoliveira

@hudsonsilvaoliveira Where did you found that file? did you created id? And how would I import it?

jayzyaj avatar Sep 07 '18 07:09 jayzyaj

@jayzyaj our custom class code goes into your /ionicapp/src/app/app.module.ts, right before the @NgModule({}) declarations.

We are actually just rewriting the GalleryModalHammerConfig (https://github.com/nikini/ionic-gallery-modal#installation), used in the providers section, that didn't work as expected for some reason.

So, instead of using the useClass: ionicGalleryModal.GalleryModalHammerConfig as the documentation pointed out, we use our new class useClass: HammerConfig, which we just created right before.

hudsonsilvaoliveira avatar Sep 10 '18 13:09 hudsonsilvaoliveira