Closed markterrill closed 5 years ago
Hi @markterrill, thanks for the feedback.
Are you using the directive inside a page module in ionic 3?
Haha!
Yes, that's the simple solution. Lazy loaded pages with their own pagename.module.ts means I need to import the module there as well.
guide.module.ts
import {NgModule} from '@angular/core';
import {IonicPageModule} from 'ionic-angular';
import {PipesModule} from "../../pipes/pipes.module";
import {GuidePage} from './guide';
import { IonHeaderScrollOpacityModule } from 'ion-header-scroll-opacity';
import {ExpandableComponentModule} from '../../components/expandable/expandable.module';
@NgModule({
declarations: [GuidePage],
imports: [
IonicPageModule.forChild(GuidePage),
PipesModule,
ExpandableComponentModule,
IonHeaderScrollOpacityModule
],
entryComponents: [
GuidePage
]
})
export class GuidePageModule {}
Incidentally, in your ngAfterContentInit, it seems there is a more efficient way to handle the scroll events that plays nicely with the dom update cycle.
// listen for ion-content scroll event
this.scrollArea.ionScroll.subscribe((ev) => {
if (ev){
ev.domWrite(() => {
_this.changeOpacity();
});
}
});
By wrapping it with that domWrite function it throttles the number of events and means its aligns with a dom cycle. https://www.joshmorony.com/increasing-performance-with-efficient-dom-writes-in-ionic-2/
I'd submit a push request if it was more complex.
Hi @markterrill PR are welcome :)
Hi, thanks for doing this directive, its exactly what I was looking for!
I did bump into something weird that an hour of Google didn't solve.
My html:
So it seems to be objecting to having added [scrollArea] as a property, which makes sense..
There was another article (https://medium.com/@gregor.srdic/ionic3-hidding-header-on-footer-on-content-scroll-15ab95b05dc5) that in the comments had similar issues.
ps, in your docu you say to use it in the app.module.ts declarations, though that errors, and logically should be as an import...