@nativescript-community/ui-pager-indicator
Version:
A NativeScript Indicator for Pager / Carousel /CollectionView
82 lines • 2.33 kB
JavaScript
import { CSSType, Property, View } from '@nativescript/core';
export var Indicator;
(function (Indicator) {
Indicator["Disabled"] = "disable";
Indicator["None"] = "none";
Indicator["Worm"] = "worm";
Indicator["Fill"] = "fill";
Indicator["Swap"] = "swap";
Indicator["Thin_worm"] = "thin_worm";
Indicator["Flat"] = "flat";
})(Indicator || (Indicator = {}));
export const colorProperty = new Property({
name: 'color'
});
export const selectedColorProperty = new Property({
name: 'selectedColor'
});
export const itemsProperty = new Property({
name: 'items'
});
export const typeProperty = new Property({
name: 'type',
defaultValue: Indicator.None
});
export const pagerViewIdProperty = new Property({
name: 'pagerViewId'
});
let PagerIndicatorBase = class PagerIndicatorBase extends View {
getPage() {
if (this.page) {
return this.page;
}
else {
return this.getTopmost(this);
}
}
getTopmost(arg) {
if (arg.parent) {
return this.getTopmost(arg.parent);
}
else {
return arg;
}
}
disposeNativeView() {
this.pagerView = null;
super.disposeNativeView();
}
onLoaded() {
super.onLoaded();
if (this.pagerViewId) {
this.setPagerView(this.getPage().getViewById(this.pagerViewId));
}
}
setPagerView(view) {
if (this.pagerView !== view) {
if (this.pagerView) {
this.pagerView.setIndicator(null);
this.pagerView = null;
}
if (view?.['setIndicator']) {
this.pagerView = view;
this.pagerView.setIndicator(this);
}
}
}
[pagerViewIdProperty.setNative](value) {
if (this.page) {
this.setPagerView(this.page?.getViewById(value));
}
}
};
PagerIndicatorBase = __decorate([
CSSType('PagerIndicator')
], PagerIndicatorBase);
export { PagerIndicatorBase };
colorProperty.register(PagerIndicatorBase);
selectedColorProperty.register(PagerIndicatorBase);
itemsProperty.register(PagerIndicatorBase);
typeProperty.register(PagerIndicatorBase);
pagerViewIdProperty.register(PagerIndicatorBase);
//# sourceMappingURL=index.common.js.map