UNPKG

angular-owl-carousel

Version:

An angular (2 or 4) wrapper for jquery owl carousel library with dynamic carousel item change detection

94 lines 3.72 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var core_1 = require('@angular/core'); var owl_child_component_1 = require("./owl-child.component"); var OwlCarousel = (function () { function OwlCarousel(differs) { this.differs = differs; this.carouselClasses = ""; this.options = {}; this.show = true; } Object.defineProperty(OwlCarousel.prototype, "items", { set: function (coll) { this._items = coll; if (coll && !this.differ) { this.differ = this.differs.find(coll).create(null); } }, enumerable: true, configurable: true }); OwlCarousel.prototype.ngDoCheck = function () { if (this.differ) { var changes = this.differ.diff(this._items); if (changes) { var changed = false; var changedFn = function () { changed = true; }; changes.forEachAddedItem(changedFn); changes.forEachMovedItem(changedFn); changes.forEachRemovedItem(changedFn); if (changed) { this.refresh(); } } } }; OwlCarousel.prototype.refresh = function () { var _this = this; this.show = false; setTimeout(function () { _this.show = true; }, 0); }; OwlCarousel.prototype.next = function (options) { this.trigger('next.owl.carousel', options); }; OwlCarousel.prototype.previous = function (options) { this.trigger('prev.owl.carousel', options); }; OwlCarousel.prototype.to = function (options) { this.trigger('to.owl.carousel', options); }; OwlCarousel.prototype.trigger = function (action, options) { this.$owlChild.trigger(action, options); }; __decorate([ core_1.ViewChild('owl'), __metadata('design:type', owl_child_component_1.OwlChild) ], OwlCarousel.prototype, "$owlChild", void 0); __decorate([ core_1.Input(), __metadata('design:type', Object) ], OwlCarousel.prototype, "carouselClasses", void 0); __decorate([ core_1.Input(), __metadata('design:type', Object) ], OwlCarousel.prototype, "options", void 0); __decorate([ core_1.Input(), __metadata('design:type', Array), __metadata('design:paramtypes', [Array]) ], OwlCarousel.prototype, "items", null); OwlCarousel = __decorate([ core_1.Component({ selector: 'owl-carousel', template: '<owl-carousel-child *ngIf="show" #owl [ngClass]="carouselClasses" [options]="options">' + '<ng-content></ng-content></owl-carousel-child>', }), __metadata('design:paramtypes', [core_1.IterableDiffers]) ], OwlCarousel); return OwlCarousel; }()); exports.OwlCarousel = OwlCarousel; //# sourceMappingURL=owl-carousel.component.js.map