@egjs/ngx-conveyer
Version:
Angular Conveyer adds Drag gestures to your Native Scroll.
100 lines (92 loc) • 5.48 kB
JavaScript
import * as i0 from '@angular/core';
import { Directive, EventEmitter, Input, NgModule } from '@angular/core';
import { REACTIVE_CONVEYER } from '@egjs/conveyer';
import { useReactive } from '@cfcs/angular';
// auto
// eslint-disable-next-line max-len
const ANGULAR_CONVEYER_EVENTS = ["ngxReachStart: reachStart", "ngxReachEnd: reachEnd", "ngxLeaveStart: leaveStart", "ngxLeaveEnd: leaveEnd", "ngxBeginScroll: beginScroll", "ngxFinishScroll: finishScroll"];
class NgxConveyerInterface {
}
NgxConveyerInterface.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: NgxConveyerInterface, deps: [], target: i0.ɵɵFactoryTarget.Directive });
NgxConveyerInterface.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.3", type: NgxConveyerInterface, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: NgxConveyerInterface, decorators: [{
type: Directive
}] });
class NgxConveyerDirective extends NgxConveyerInterface {
constructor(_host, _ngZone) {
super();
this._host = _host;
this._ngZone = _ngZone;
/** Event emitters below will be created by `@cfcs/angular`. */
// automatic methods, reactive state
this._reactiveConveyer = useReactive(this, Object.assign({ data: () => {
return {
container: { current: this._host.nativeElement },
props: this.ngxConveyer || {},
};
} }, REACTIVE_CONVEYER));
}
ngAfterViewInit() {
this._patchEventEmitters();
this._ngZone.runOutsideAngular(() => this._reactiveConveyer.mounted());
}
ngOnDestroy() {
this._reactiveConveyer.destroy();
}
_patchEventEmitters() {
// Pick `ngxReachStart`, ngxReachEnd` and other event emitters.
// They will be created by `@cfcs/angular`.
const eventEmitters = Object.values(this).filter((value) => value instanceof EventEmitter);
for (const eventEmitter of eventEmitters) {
const emit = eventEmitter.emit;
// We must patch event generators because we're not responsible for
// calling `emit` since this is done by `@cfcs/angular`. The `conveyer`
// is created outside of the Angular zone to reduce the number of change
// detections since it setups mouse listeners (as `mousemove`).
eventEmitter.emit = (value) => {
// `observed` is available only in newer RxJS version (7.2+).
if (eventEmitter.observed || eventEmitter.observers.length > 0) {
// Given event emitter is `ngxBeginScroll`; this will re-enter the Angular
// zone if there're any listeners added in template, for instance:
// `<div ngxConveyer (beginScroll)="onBeginScroll()"></div>`.ngxConveyer
return this._ngZone.run(() => emit.call(eventEmitter, value));
}
else {
return emit.call(eventEmitter, value);
}
};
}
}
}
NgxConveyerDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: NgxConveyerDirective, deps: [{ token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Directive });
NgxConveyerDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "12.0.0", version: "13.0.3", type: NgxConveyerDirective, selector: "[ngxConveyer]", inputs: { ngxConveyer: "ngxConveyer" }, outputs: { ngxReachStart: "reachStart", ngxReachEnd: "reachEnd", ngxLeaveStart: "leaveStart", ngxLeaveEnd: "leaveEnd", ngxBeginScroll: "beginScroll", ngxFinishScroll: "finishScroll" }, exportAs: ["ngxConveyer"], usesInheritance: true, ngImport: i0 });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: NgxConveyerDirective, decorators: [{
type: Directive,
args: [{
selector: '[ngxConveyer]',
exportAs: 'ngxConveyer',
outputs: ANGULAR_CONVEYER_EVENTS,
}]
}], ctorParameters: function () { return [{ type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { ngxConveyer: [{
type: Input
}] } });
class NgxConveyerModule {
}
NgxConveyerModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: NgxConveyerModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
NgxConveyerModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: NgxConveyerModule, declarations: [NgxConveyerDirective], exports: [NgxConveyerDirective] });
NgxConveyerModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: NgxConveyerModule });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "13.0.3", ngImport: i0, type: NgxConveyerModule, decorators: [{
type: NgModule,
args: [{
declarations: [NgxConveyerDirective],
exports: [NgxConveyerDirective],
}]
}] });
/*
* Public API Surface of ngx-conveyer
*/
/**
* Generated bundle index. Do not edit.
*/
export { NgxConveyerDirective, NgxConveyerInterface, NgxConveyerModule };
//# sourceMappingURL=egjs-ngx-conveyer.mjs.map