gallery.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = Object.setPrototypeOf ||
  4. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  5. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  6. return function (d, b) {
  7. extendStatics(d, b);
  8. function __() { this.constructor = d; }
  9. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  10. };
  11. })();
  12. /*!
  13. * devextreme-angular
  14. * Version: 19.1.16
  15. * Build date: Tue Oct 18 2022
  16. *
  17. * Copyright (c) 2012 - 2022 Developer Express Inc. ALL RIGHTS RESERVED
  18. *
  19. * This software may be modified and distributed under the terms
  20. * of the MIT license. See the LICENSE file in the root of the project for details.
  21. *
  22. * https://github.com/DevExpress/devextreme-angular
  23. */
  24. Object.defineProperty(exports, "__esModule", { value: true });
  25. var platform_browser_1 = require("@angular/platform-browser");
  26. var platform_browser_2 = require("@angular/platform-browser");
  27. var core_1 = require("@angular/core");
  28. var gallery_1 = require("devextreme/ui/gallery");
  29. var component_1 = require("../core/component");
  30. var template_host_1 = require("../core/template-host");
  31. var integration_1 = require("../core/integration");
  32. var template_1 = require("../core/template");
  33. var nested_option_1 = require("../core/nested-option");
  34. var watcher_helper_1 = require("../core/watcher-helper");
  35. var iterable_differ_helper_1 = require("../core/iterable-differ-helper");
  36. var item_dxi_1 = require("./nested/item-dxi");
  37. var item_dxi_2 = require("./nested/item-dxi");
  38. /**
  39. * The Gallery is a widget that displays a collection of images in a carousel. The widget is supplied with various navigation controls that allow a user to switch between images.
  40. */
  41. var DxGalleryComponent = (function (_super) {
  42. __extends(DxGalleryComponent, _super);
  43. function DxGalleryComponent(elementRef, ngZone, templateHost, _watcherHelper, _idh, optionHost, transferState, platformId) {
  44. var _this = _super.call(this, elementRef, ngZone, templateHost, _watcherHelper, transferState, platformId) || this;
  45. _this._watcherHelper = _watcherHelper;
  46. _this._idh = _idh;
  47. _this._createEventEmitters([
  48. { subscribe: 'contentReady', emit: 'onContentReady' },
  49. { subscribe: 'disposing', emit: 'onDisposing' },
  50. { subscribe: 'initialized', emit: 'onInitialized' },
  51. { subscribe: 'itemClick', emit: 'onItemClick' },
  52. { subscribe: 'itemContextMenu', emit: 'onItemContextMenu' },
  53. { subscribe: 'itemHold', emit: 'onItemHold' },
  54. { subscribe: 'itemRendered', emit: 'onItemRendered' },
  55. { subscribe: 'optionChanged', emit: 'onOptionChanged' },
  56. { subscribe: 'selectionChanged', emit: 'onSelectionChanged' },
  57. { emit: 'accessKeyChange' },
  58. { emit: 'animationDurationChange' },
  59. { emit: 'animationEnabledChange' },
  60. { emit: 'dataSourceChange' },
  61. { emit: 'disabledChange' },
  62. { emit: 'elementAttrChange' },
  63. { emit: 'focusStateEnabledChange' },
  64. { emit: 'heightChange' },
  65. { emit: 'hintChange' },
  66. { emit: 'hoverStateEnabledChange' },
  67. { emit: 'indicatorEnabledChange' },
  68. { emit: 'initialItemWidthChange' },
  69. { emit: 'itemHoldTimeoutChange' },
  70. { emit: 'itemsChange' },
  71. { emit: 'itemTemplateChange' },
  72. { emit: 'loopChange' },
  73. { emit: 'rtlEnabledChange' },
  74. { emit: 'selectedIndexChange' },
  75. { emit: 'selectedItemChange' },
  76. { emit: 'showIndicatorChange' },
  77. { emit: 'showNavButtonsChange' },
  78. { emit: 'slideshowDelayChange' },
  79. { emit: 'stretchImagesChange' },
  80. { emit: 'swipeEnabledChange' },
  81. { emit: 'tabIndexChange' },
  82. { emit: 'visibleChange' },
  83. { emit: 'widthChange' },
  84. { emit: 'wrapAroundChange' }
  85. ]);
  86. _this._idh.setHost(_this);
  87. optionHost.setHost(_this);
  88. return _this;
  89. }
  90. Object.defineProperty(DxGalleryComponent.prototype, "accessKey", {
  91. get: /**
  92. * Specifies the shortcut key that sets focus on the widget.
  93. */
  94. function () {
  95. return this._getOption('accessKey');
  96. },
  97. set: function (value) {
  98. this._setOption('accessKey', value);
  99. },
  100. enumerable: true,
  101. configurable: true
  102. });
  103. Object.defineProperty(DxGalleryComponent.prototype, "animationDuration", {
  104. get: /**
  105. * The time, in milliseconds, spent on slide animation.
  106. */
  107. function () {
  108. return this._getOption('animationDuration');
  109. },
  110. set: function (value) {
  111. this._setOption('animationDuration', value);
  112. },
  113. enumerable: true,
  114. configurable: true
  115. });
  116. Object.defineProperty(DxGalleryComponent.prototype, "animationEnabled", {
  117. get: /**
  118. * Specifies whether or not to animate the displayed item change.
  119. */
  120. function () {
  121. return this._getOption('animationEnabled');
  122. },
  123. set: function (value) {
  124. this._setOption('animationEnabled', value);
  125. },
  126. enumerable: true,
  127. configurable: true
  128. });
  129. Object.defineProperty(DxGalleryComponent.prototype, "dataSource", {
  130. get: /**
  131. * Binds the widget to data.
  132. */
  133. function () {
  134. return this._getOption('dataSource');
  135. },
  136. set: function (value) {
  137. this._setOption('dataSource', value);
  138. },
  139. enumerable: true,
  140. configurable: true
  141. });
  142. Object.defineProperty(DxGalleryComponent.prototype, "disabled", {
  143. get: /**
  144. * Specifies whether the widget responds to user interaction.
  145. */
  146. function () {
  147. return this._getOption('disabled');
  148. },
  149. set: function (value) {
  150. this._setOption('disabled', value);
  151. },
  152. enumerable: true,
  153. configurable: true
  154. });
  155. Object.defineProperty(DxGalleryComponent.prototype, "elementAttr", {
  156. get: /**
  157. * Specifies the attributes to be attached to the widget's root element.
  158. */
  159. function () {
  160. return this._getOption('elementAttr');
  161. },
  162. set: function (value) {
  163. this._setOption('elementAttr', value);
  164. },
  165. enumerable: true,
  166. configurable: true
  167. });
  168. Object.defineProperty(DxGalleryComponent.prototype, "focusStateEnabled", {
  169. get: /**
  170. * Specifies whether the widget can be focused using keyboard navigation.
  171. */
  172. function () {
  173. return this._getOption('focusStateEnabled');
  174. },
  175. set: function (value) {
  176. this._setOption('focusStateEnabled', value);
  177. },
  178. enumerable: true,
  179. configurable: true
  180. });
  181. Object.defineProperty(DxGalleryComponent.prototype, "height", {
  182. get: /**
  183. * Specifies the widget's height.
  184. */
  185. function () {
  186. return this._getOption('height');
  187. },
  188. set: function (value) {
  189. this._setOption('height', value);
  190. },
  191. enumerable: true,
  192. configurable: true
  193. });
  194. Object.defineProperty(DxGalleryComponent.prototype, "hint", {
  195. get: /**
  196. * Specifies text for a hint that appears when a user pauses on the widget.
  197. */
  198. function () {
  199. return this._getOption('hint');
  200. },
  201. set: function (value) {
  202. this._setOption('hint', value);
  203. },
  204. enumerable: true,
  205. configurable: true
  206. });
  207. Object.defineProperty(DxGalleryComponent.prototype, "hoverStateEnabled", {
  208. get: /**
  209. * Specifies whether the widget changes its state when a user pauses on it.
  210. */
  211. function () {
  212. return this._getOption('hoverStateEnabled');
  213. },
  214. set: function (value) {
  215. this._setOption('hoverStateEnabled', value);
  216. },
  217. enumerable: true,
  218. configurable: true
  219. });
  220. Object.defineProperty(DxGalleryComponent.prototype, "indicatorEnabled", {
  221. get: /**
  222. * A Boolean value specifying whether or not to allow users to switch between items by clicking an indicator.
  223. */
  224. function () {
  225. return this._getOption('indicatorEnabled');
  226. },
  227. set: function (value) {
  228. this._setOption('indicatorEnabled', value);
  229. },
  230. enumerable: true,
  231. configurable: true
  232. });
  233. Object.defineProperty(DxGalleryComponent.prototype, "initialItemWidth", {
  234. get: /**
  235. * Specifies the width of an area used to display a single image.
  236. */
  237. function () {
  238. return this._getOption('initialItemWidth');
  239. },
  240. set: function (value) {
  241. this._setOption('initialItemWidth', value);
  242. },
  243. enumerable: true,
  244. configurable: true
  245. });
  246. Object.defineProperty(DxGalleryComponent.prototype, "itemHoldTimeout", {
  247. get: /**
  248. * The time period in milliseconds before the onItemHold event is raised.
  249. */
  250. function () {
  251. return this._getOption('itemHoldTimeout');
  252. },
  253. set: function (value) {
  254. this._setOption('itemHoldTimeout', value);
  255. },
  256. enumerable: true,
  257. configurable: true
  258. });
  259. Object.defineProperty(DxGalleryComponent.prototype, "items", {
  260. get: /**
  261. * An array of items displayed by the widget.
  262. */
  263. function () {
  264. return this._getOption('items');
  265. },
  266. set: function (value) {
  267. this._setOption('items', value);
  268. },
  269. enumerable: true,
  270. configurable: true
  271. });
  272. Object.defineProperty(DxGalleryComponent.prototype, "itemTemplate", {
  273. get: /**
  274. * Specifies a custom template for items.
  275. */
  276. function () {
  277. return this._getOption('itemTemplate');
  278. },
  279. set: function (value) {
  280. this._setOption('itemTemplate', value);
  281. },
  282. enumerable: true,
  283. configurable: true
  284. });
  285. Object.defineProperty(DxGalleryComponent.prototype, "loop", {
  286. get: /**
  287. * A Boolean value specifying whether or not to scroll back to the first item after the last item is swiped.
  288. */
  289. function () {
  290. return this._getOption('loop');
  291. },
  292. set: function (value) {
  293. this._setOption('loop', value);
  294. },
  295. enumerable: true,
  296. configurable: true
  297. });
  298. Object.defineProperty(DxGalleryComponent.prototype, "rtlEnabled", {
  299. get: /**
  300. * Switches the widget to a right-to-left representation.
  301. */
  302. function () {
  303. return this._getOption('rtlEnabled');
  304. },
  305. set: function (value) {
  306. this._setOption('rtlEnabled', value);
  307. },
  308. enumerable: true,
  309. configurable: true
  310. });
  311. Object.defineProperty(DxGalleryComponent.prototype, "selectedIndex", {
  312. get: /**
  313. * The index of the currently active gallery item.
  314. */
  315. function () {
  316. return this._getOption('selectedIndex');
  317. },
  318. set: function (value) {
  319. this._setOption('selectedIndex', value);
  320. },
  321. enumerable: true,
  322. configurable: true
  323. });
  324. Object.defineProperty(DxGalleryComponent.prototype, "selectedItem", {
  325. get: /**
  326. * The selected item object.
  327. */
  328. function () {
  329. return this._getOption('selectedItem');
  330. },
  331. set: function (value) {
  332. this._setOption('selectedItem', value);
  333. },
  334. enumerable: true,
  335. configurable: true
  336. });
  337. Object.defineProperty(DxGalleryComponent.prototype, "showIndicator", {
  338. get: /**
  339. * A Boolean value specifying whether or not to display an indicator that points to the selected gallery item.
  340. */
  341. function () {
  342. return this._getOption('showIndicator');
  343. },
  344. set: function (value) {
  345. this._setOption('showIndicator', value);
  346. },
  347. enumerable: true,
  348. configurable: true
  349. });
  350. Object.defineProperty(DxGalleryComponent.prototype, "showNavButtons", {
  351. get: /**
  352. * A Boolean value that specifies the availability of the "Forward" and "Back" navigation buttons.
  353. */
  354. function () {
  355. return this._getOption('showNavButtons');
  356. },
  357. set: function (value) {
  358. this._setOption('showNavButtons', value);
  359. },
  360. enumerable: true,
  361. configurable: true
  362. });
  363. Object.defineProperty(DxGalleryComponent.prototype, "slideshowDelay", {
  364. get: /**
  365. * The time interval in milliseconds, after which the gallery switches to the next item.
  366. */
  367. function () {
  368. return this._getOption('slideshowDelay');
  369. },
  370. set: function (value) {
  371. this._setOption('slideshowDelay', value);
  372. },
  373. enumerable: true,
  374. configurable: true
  375. });
  376. Object.defineProperty(DxGalleryComponent.prototype, "stretchImages", {
  377. get: /**
  378. * Specifies if the widget stretches images to fit the total gallery width.
  379. */
  380. function () {
  381. return this._getOption('stretchImages');
  382. },
  383. set: function (value) {
  384. this._setOption('stretchImages', value);
  385. },
  386. enumerable: true,
  387. configurable: true
  388. });
  389. Object.defineProperty(DxGalleryComponent.prototype, "swipeEnabled", {
  390. get: /**
  391. * A Boolean value specifying whether or not to allow users to switch between items by swiping.
  392. */
  393. function () {
  394. return this._getOption('swipeEnabled');
  395. },
  396. set: function (value) {
  397. this._setOption('swipeEnabled', value);
  398. },
  399. enumerable: true,
  400. configurable: true
  401. });
  402. Object.defineProperty(DxGalleryComponent.prototype, "tabIndex", {
  403. get: /**
  404. * Specifies the number of the element when the Tab key is used for navigating.
  405. */
  406. function () {
  407. return this._getOption('tabIndex');
  408. },
  409. set: function (value) {
  410. this._setOption('tabIndex', value);
  411. },
  412. enumerable: true,
  413. configurable: true
  414. });
  415. Object.defineProperty(DxGalleryComponent.prototype, "visible", {
  416. get: /**
  417. * Specifies whether the widget is visible.
  418. */
  419. function () {
  420. return this._getOption('visible');
  421. },
  422. set: function (value) {
  423. this._setOption('visible', value);
  424. },
  425. enumerable: true,
  426. configurable: true
  427. });
  428. Object.defineProperty(DxGalleryComponent.prototype, "width", {
  429. get: /**
  430. * Specifies the widget's width.
  431. */
  432. function () {
  433. return this._getOption('width');
  434. },
  435. set: function (value) {
  436. this._setOption('width', value);
  437. },
  438. enumerable: true,
  439. configurable: true
  440. });
  441. Object.defineProperty(DxGalleryComponent.prototype, "wrapAround", {
  442. get: /**
  443. * Specifies whether or not to display parts of previous and next images along the sides of the current image.
  444. */
  445. function () {
  446. return this._getOption('wrapAround');
  447. },
  448. set: function (value) {
  449. this._setOption('wrapAround', value);
  450. },
  451. enumerable: true,
  452. configurable: true
  453. });
  454. Object.defineProperty(DxGalleryComponent.prototype, "itemsChildren", {
  455. get: function () {
  456. return this._getOption('items');
  457. },
  458. set: function (value) {
  459. this.setChildren('items', value);
  460. },
  461. enumerable: true,
  462. configurable: true
  463. });
  464. DxGalleryComponent.prototype._createInstance = function (element, options) {
  465. return new gallery_1.default(element, options);
  466. };
  467. DxGalleryComponent.prototype.ngOnDestroy = function () {
  468. this._destroyWidget();
  469. };
  470. DxGalleryComponent.prototype.ngOnChanges = function (changes) {
  471. _super.prototype.ngOnChanges.call(this, changes);
  472. this.setupChanges('dataSource', changes);
  473. this.setupChanges('items', changes);
  474. };
  475. DxGalleryComponent.prototype.setupChanges = function (prop, changes) {
  476. if (!(prop in this._optionsToUpdate)) {
  477. this._idh.setup(prop, changes);
  478. }
  479. };
  480. DxGalleryComponent.prototype.ngDoCheck = function () {
  481. this._idh.doCheck('dataSource');
  482. this._idh.doCheck('items');
  483. this._watcherHelper.checkWatchers();
  484. _super.prototype.ngDoCheck.call(this);
  485. _super.prototype.clearChangedOptions.call(this);
  486. };
  487. DxGalleryComponent.prototype._setOption = function (name, value) {
  488. var isSetup = this._idh.setupSingle(name, value);
  489. var isChanged = this._idh.getChanges(name, value) !== null;
  490. if (isSetup || isChanged) {
  491. _super.prototype._setOption.call(this, name, value);
  492. }
  493. };
  494. DxGalleryComponent.decorators = [
  495. { type: core_1.Component, args: [{
  496. selector: 'dx-gallery',
  497. template: '',
  498. providers: [
  499. template_host_1.DxTemplateHost,
  500. watcher_helper_1.WatcherHelper,
  501. nested_option_1.NestedOptionHost,
  502. iterable_differ_helper_1.IterableDifferHelper
  503. ]
  504. },] },
  505. ];
  506. /** @nocollapse */
  507. DxGalleryComponent.ctorParameters = function () { return [
  508. { type: core_1.ElementRef, },
  509. { type: core_1.NgZone, },
  510. { type: template_host_1.DxTemplateHost, },
  511. { type: watcher_helper_1.WatcherHelper, },
  512. { type: iterable_differ_helper_1.IterableDifferHelper, },
  513. { type: nested_option_1.NestedOptionHost, },
  514. { type: platform_browser_2.TransferState, },
  515. { type: undefined, decorators: [{ type: core_1.Inject, args: [core_1.PLATFORM_ID,] },] },
  516. ]; };
  517. DxGalleryComponent.propDecorators = {
  518. "accessKey": [{ type: core_1.Input },],
  519. "animationDuration": [{ type: core_1.Input },],
  520. "animationEnabled": [{ type: core_1.Input },],
  521. "dataSource": [{ type: core_1.Input },],
  522. "disabled": [{ type: core_1.Input },],
  523. "elementAttr": [{ type: core_1.Input },],
  524. "focusStateEnabled": [{ type: core_1.Input },],
  525. "height": [{ type: core_1.Input },],
  526. "hint": [{ type: core_1.Input },],
  527. "hoverStateEnabled": [{ type: core_1.Input },],
  528. "indicatorEnabled": [{ type: core_1.Input },],
  529. "initialItemWidth": [{ type: core_1.Input },],
  530. "itemHoldTimeout": [{ type: core_1.Input },],
  531. "items": [{ type: core_1.Input },],
  532. "itemTemplate": [{ type: core_1.Input },],
  533. "loop": [{ type: core_1.Input },],
  534. "rtlEnabled": [{ type: core_1.Input },],
  535. "selectedIndex": [{ type: core_1.Input },],
  536. "selectedItem": [{ type: core_1.Input },],
  537. "showIndicator": [{ type: core_1.Input },],
  538. "showNavButtons": [{ type: core_1.Input },],
  539. "slideshowDelay": [{ type: core_1.Input },],
  540. "stretchImages": [{ type: core_1.Input },],
  541. "swipeEnabled": [{ type: core_1.Input },],
  542. "tabIndex": [{ type: core_1.Input },],
  543. "visible": [{ type: core_1.Input },],
  544. "width": [{ type: core_1.Input },],
  545. "wrapAround": [{ type: core_1.Input },],
  546. "onContentReady": [{ type: core_1.Output },],
  547. "onDisposing": [{ type: core_1.Output },],
  548. "onInitialized": [{ type: core_1.Output },],
  549. "onItemClick": [{ type: core_1.Output },],
  550. "onItemContextMenu": [{ type: core_1.Output },],
  551. "onItemHold": [{ type: core_1.Output },],
  552. "onItemRendered": [{ type: core_1.Output },],
  553. "onOptionChanged": [{ type: core_1.Output },],
  554. "onSelectionChanged": [{ type: core_1.Output },],
  555. "accessKeyChange": [{ type: core_1.Output },],
  556. "animationDurationChange": [{ type: core_1.Output },],
  557. "animationEnabledChange": [{ type: core_1.Output },],
  558. "dataSourceChange": [{ type: core_1.Output },],
  559. "disabledChange": [{ type: core_1.Output },],
  560. "elementAttrChange": [{ type: core_1.Output },],
  561. "focusStateEnabledChange": [{ type: core_1.Output },],
  562. "heightChange": [{ type: core_1.Output },],
  563. "hintChange": [{ type: core_1.Output },],
  564. "hoverStateEnabledChange": [{ type: core_1.Output },],
  565. "indicatorEnabledChange": [{ type: core_1.Output },],
  566. "initialItemWidthChange": [{ type: core_1.Output },],
  567. "itemHoldTimeoutChange": [{ type: core_1.Output },],
  568. "itemsChange": [{ type: core_1.Output },],
  569. "itemTemplateChange": [{ type: core_1.Output },],
  570. "loopChange": [{ type: core_1.Output },],
  571. "rtlEnabledChange": [{ type: core_1.Output },],
  572. "selectedIndexChange": [{ type: core_1.Output },],
  573. "selectedItemChange": [{ type: core_1.Output },],
  574. "showIndicatorChange": [{ type: core_1.Output },],
  575. "showNavButtonsChange": [{ type: core_1.Output },],
  576. "slideshowDelayChange": [{ type: core_1.Output },],
  577. "stretchImagesChange": [{ type: core_1.Output },],
  578. "swipeEnabledChange": [{ type: core_1.Output },],
  579. "tabIndexChange": [{ type: core_1.Output },],
  580. "visibleChange": [{ type: core_1.Output },],
  581. "widthChange": [{ type: core_1.Output },],
  582. "wrapAroundChange": [{ type: core_1.Output },],
  583. "itemsChildren": [{ type: core_1.ContentChildren, args: [item_dxi_2.DxiItemComponent,] },],
  584. };
  585. return DxGalleryComponent;
  586. }(component_1.DxComponent));
  587. exports.DxGalleryComponent = DxGalleryComponent;
  588. var DxGalleryModule = (function () {
  589. function DxGalleryModule() {
  590. }
  591. DxGalleryModule.decorators = [
  592. { type: core_1.NgModule, args: [{
  593. imports: [
  594. item_dxi_1.DxiItemModule,
  595. integration_1.DxIntegrationModule,
  596. template_1.DxTemplateModule,
  597. platform_browser_1.BrowserTransferStateModule
  598. ],
  599. declarations: [
  600. DxGalleryComponent
  601. ],
  602. exports: [
  603. DxGalleryComponent,
  604. item_dxi_1.DxiItemModule,
  605. template_1.DxTemplateModule
  606. ]
  607. },] },
  608. ];
  609. return DxGalleryModule;
  610. }());
  611. exports.DxGalleryModule = DxGalleryModule;
  612. //# sourceMappingURL=gallery.js.map