ng-cw-v12
Version:
Angular UI component library
121 lines (112 loc) • 7.17 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('rxjs'), require('rxjs/operators')) :
typeof define === 'function' && define.amd ? define('ng-cw-v12/infinite-scroll', ['exports', '@angular/core', 'rxjs', 'rxjs/operators'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global["ng-cw-v12"] = global["ng-cw-v12"] || {}, global["ng-cw-v12"]["infinite-scroll"] = {}), global.ng.core, global.rxjs, global.rxjs.operators));
})(this, (function (exports, i0, rxjs, operators) { 'use strict';
function _interopNamespace(e) {
if (e && e.__esModule) return e;
var n = Object.create(null);
if (e) {
Object.keys(e).forEach(function (k) {
if (k !== 'default') {
var d = Object.getOwnPropertyDescriptor(e, k);
Object.defineProperty(n, k, d.get ? d : {
enumerable: true,
get: function () { return e[k]; }
});
}
});
}
n["default"] = e;
return Object.freeze(n);
}
var i0__namespace = /*#__PURE__*/_interopNamespace(i0);
var InfiniteScrollComponent = /** @class */ (function () {
function InfiniteScrollComponent() {
this.ncReachedBottom = new i0.EventEmitter();
this.ncDistance = 0;
this.ncDelay = 200;
this.scrollSubject = new rxjs.Subject();
this.isNearBottom = false;
this.disableDetectionMode = false;
}
Object.defineProperty(InfiniteScrollComponent.prototype, "ncDisableDetection", {
set: function (value) {
this.disableDetectionMode = value !== null && value !== undefined && value !== false && value !== 'false';
},
enumerable: false,
configurable: true
});
InfiniteScrollComponent.prototype.ngAfterViewInit = function () {
this.initScrollListener();
};
InfiniteScrollComponent.prototype.initScrollListener = function () {
var _this = this;
var scrollElement = this.scrollContainer.nativeElement;
rxjs.fromEvent(scrollElement, 'scroll').subscribe(function () {
_this.handleScroll(scrollElement);
});
this.scrollSubject.pipe(operators.debounceTime(this.ncDelay), operators.filter(function () { return !_this.disableDetectionMode; })).subscribe(function () {
if (_this.isNearBottom) {
_this.ncReachedBottom.emit();
}
});
};
InfiniteScrollComponent.prototype.handleScroll = function (element) {
var scrollTop = element.scrollTop, clientHeight = element.clientHeight, scrollHeight = element.scrollHeight;
this.isNearBottom = scrollTop + clientHeight >= scrollHeight - this.ncDistance;
if (this.isNearBottom) {
this.scrollSubject.next();
}
};
return InfiniteScrollComponent;
}());
InfiniteScrollComponent.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: InfiniteScrollComponent, deps: [], target: i0__namespace.ɵɵFactoryTarget.Component });
InfiniteScrollComponent.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.1.5", type: InfiniteScrollComponent, selector: "nc-infinite-scroll", inputs: { ncDisableDetection: "ncDisableDetection", ncDistance: "ncDistance", ncDelay: "ncDelay" }, outputs: { ncReachedBottom: "ncReachedBottom" }, viewQueries: [{ propertyName: "scrollContainer", first: true, predicate: ["scrollContainer"], descendants: true }], ngImport: i0__namespace, template: "<div #scrollContainer class=\"nc-infinite-scroll\">\r\n <ng-content></ng-content>\r\n</div>", styles: [".nc-infinite-scroll{width:100%;height:100%;overflow:auto}.nc-infinite-scroll::-webkit-scrollbar{width:6px;height:6px}.nc-infinite-scroll::-webkit-scrollbar-thumb{background-color:#cdc9cf;border-radius:10px;-webkit-transition:background-color .3s ease;transition:background-color .3s ease}.nc-infinite-scroll::-webkit-scrollbar-thumb:hover{background-color:#766d7b}.nc-infinite-scroll::-webkit-scrollbar-track{background:#0000;cursor:pointer}\n"] });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: InfiniteScrollComponent, decorators: [{
type: i0.Component,
args: [{
selector: 'nc-infinite-scroll',
templateUrl: './infinite-scroll.component.html',
styleUrls: ['./infinite-scroll.component.less']
}]
}], ctorParameters: function () { return []; }, propDecorators: { ncReachedBottom: [{
type: i0.Output
}], ncDisableDetection: [{
type: i0.Input
}], ncDistance: [{
type: i0.Input
}], ncDelay: [{
type: i0.Input
}], scrollContainer: [{
type: i0.ViewChild,
args: ['scrollContainer']
}] } });
var NcInfiniteScrollModule = /** @class */ (function () {
function NcInfiniteScrollModule() {
}
return NcInfiniteScrollModule;
}());
NcInfiniteScrollModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: NcInfiniteScrollModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
NcInfiniteScrollModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: NcInfiniteScrollModule, declarations: [InfiniteScrollComponent], exports: [InfiniteScrollComponent] });
NcInfiniteScrollModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: NcInfiniteScrollModule, imports: [[]] });
i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.1.5", ngImport: i0__namespace, type: NcInfiniteScrollModule, decorators: [{
type: i0.NgModule,
args: [{
declarations: [
InfiniteScrollComponent
],
imports: [],
exports: [
InfiniteScrollComponent
]
}]
}] });
/**
* Generated bundle index. Do not edit.
*/
exports.InfiniteScrollComponent = InfiniteScrollComponent;
exports.NcInfiniteScrollModule = NcInfiniteScrollModule;
Object.defineProperty(exports, '__esModule', { value: true });
}));
//# sourceMappingURL=ng-cw-v12-infinite-scroll.umd.js.map