index.js 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  1. "use strict";
  2. // import { CustomElement, DisplayObjectConfig, Group } from '../../shapes';
  3. // import { deepMix, isNull } from '@antv/util';
  4. // import { maybeAppend, normalPadding, select } from '../../util';
  5. // import { Button } from './button';
  6. // import { SliderAxis } from './sliderAxis';
  7. // import { CellAxis } from './cellAxis';
  8. // import { SpeedControl } from './speedcontrol';
  9. // import { Checkbox } from './checkbox';
  10. // import { DEFAULT_TIMELINE_STYLE } from './constants';
  11. // import type { TimelineStyleProps, PlayAxisStyleProps } from './types';
  12. // import { normalSelection } from './playAxis';
  13. Object.defineProperty(exports, "__esModule", { value: true });
  14. exports.Timeline = void 0;
  15. var Timeline = /** @class */ (function () {
  16. function Timeline() {
  17. }
  18. return Timeline;
  19. }());
  20. exports.Timeline = Timeline;
  21. // export class Timeline extends CustomElement<TimelineStyleProps> {
  22. // private speed = 1;
  23. // private singleMode = false;
  24. // private playing = false;
  25. // private selection: [number, number] = [0, 0];
  26. // constructor(options: DisplayObjectConfig<TimelineStyleProps>) {
  27. // super(deepMix({}, { style: DEFAULT_TIMELINE_STYLE }, options));
  28. // this.singleMode = this.style.singleMode || false;
  29. // this.selection = normalSelection(this.style.selection, this.singleMode);
  30. // }
  31. // public update(cfg: Partial<TimelineStyleProps> = {}) {
  32. // this.attr(deepMix({}, this.attributes, cfg));
  33. // if (cfg.singleMode !== undefined) {
  34. // this.singleMode = cfg.singleMode;
  35. // }
  36. // if (cfg.selection) {
  37. // this.selection = normalSelection(cfg.selection, this.singleMode);
  38. // }
  39. // this.render();
  40. // }
  41. // private get styles(): Required<TimelineStyleProps> {
  42. // return deepMix({}, DEFAULT_TIMELINE_STYLE, this.attributes);
  43. // }
  44. // private render() {
  45. // const { width, height, controlPosition, speedControl, singleModeControl } = this.styles;
  46. // const [pt = 0, pr = 0, pb, pl = pr] = normalPadding(this.styles.padding);
  47. // const container = maybeAppend(this, '.container', 'g')
  48. // .attr('className', 'container')
  49. // .style('x', pl)
  50. // .style('y', pt)
  51. // .node();
  52. // const length = this.style.orientation! === 'vertical' ? height - (pt + pb) : width - (pl + pr);
  53. // const layout = layoutControl(controlPosition, length, this.styles);
  54. // this.renderAxis(container, layout);
  55. // this.renderControlButton(container, layout);
  56. // maybeAppend(container, '.timeline-speed-control', () => new SpeedControl({}))
  57. // .attr('className', 'timeline-speed-control')
  58. // .call((selection) => {
  59. // if (speedControl === null) {
  60. // selection.remove();
  61. // return;
  62. // }
  63. // (selection.node() as SpeedControl).update({
  64. // x: layout.speedControl.x,
  65. // y: layout.speedControl.y,
  66. // ...speedControl,
  67. // initialSpeed: this.speed,
  68. // });
  69. // });
  70. // maybeAppend(container, '.timeline-single-control', () => new Checkbox({}))
  71. // .attr('className', 'timeline-single-control')
  72. // .call((selection) => {
  73. // if (singleModeControl === null) {
  74. // selection.remove();
  75. // return;
  76. // }
  77. // (selection.node() as Checkbox).update({
  78. // x: layout.singleModeControl.x,
  79. // y: layout.singleModeControl.y,
  80. // ...singleModeControl,
  81. // active: this.singleMode,
  82. // });
  83. // });
  84. // }
  85. // private renderAxis(container: Group, layout: Layout) {
  86. // const { data: timeData } = this.styles;
  87. // const type = this.styles.type || 'slider';
  88. // let axis = select(container).select('.timeline-axis').node() as PlayAxis | undefined;
  89. // const Ctor = type === 'cell' ? CellAxis : SliderAxis;
  90. // if (axis && axis.style.tag !== `${type}-axis`) {
  91. // axis.remove();
  92. // this.removeChild(axis);
  93. // }
  94. // axis = maybeAppend(container, '.timeline-axis', () => new Ctor({}))
  95. // .attr('className', 'timeline-axis')
  96. // .call((selection) => {
  97. // (selection.node() as PlayAxis).update({
  98. // x: layout.axis.x,
  99. // y: layout.axis.y,
  100. // length: layout.axis.length,
  101. // data: timeData,
  102. // selection: this.selection,
  103. // orientation: this.style.orientation!,
  104. // playInterval: this.style.playInterval! / this.speed,
  105. // singleMode: this.singleMode,
  106. // ...(this.style.playAxis || {}),
  107. // });
  108. // (selection.node() as PlayAxis).update({
  109. // handleStyle: {
  110. // cursor: this.style.orientation === 'vertical' ? 'ns-resize' : 'ew-resize',
  111. // },
  112. // });
  113. // })
  114. // .node() as PlayAxis;
  115. // }
  116. // private renderControlButton(container: Group, layout: Layout) {
  117. // const playButtonSize = layout.playBtn.size || 0;
  118. // const prevButtonSize = layout.prevBtn.size || 0;
  119. // const nextButtonSize = layout.nextBtn?.size || 0;
  120. // maybeAppend(container, '.timeline-prev-btn', () => new Button({}))
  121. // .attr('className', 'timeline-prev-btn')
  122. // .call((selection) => {
  123. // if (!prevButtonSize) {
  124. // selection.remove();
  125. // return;
  126. // }
  127. // (selection.node() as Button).update({
  128. // ...(this.style.controlButton?.prevBtn || {}),
  129. // x: layout.prevBtn.x,
  130. // y: layout.prevBtn.y,
  131. // size: prevButtonSize,
  132. // symbol: 'timeline-prev-button',
  133. // });
  134. // (selection.node() as Button).update({
  135. // markerStyle: {
  136. // transformOrigin: 'center',
  137. // transform: this.style.orientation === 'vertical' ? 'rotate(90deg)' : '',
  138. // },
  139. // });
  140. // });
  141. // maybeAppend(container, '.timeline-play-btn', () => new Button({}))
  142. // .attr('className', 'timeline-play-btn')
  143. // .call((selection) => {
  144. // if (!playButtonSize) {
  145. // selection.remove();
  146. // return;
  147. // }
  148. // (selection.node() as Button).update({
  149. // backgroundStyle: { radius: (layout.playBtn.size || 0) / 2 },
  150. // });
  151. // (selection.node() as Button).update({
  152. // ...(this.style.controlButton?.playBtn || {}),
  153. // x: layout.playBtn.x,
  154. // y: layout.playBtn.y,
  155. // size: playButtonSize,
  156. // symbol: !this.playing ? 'timeline-stop-button' : 'timeline-play-button',
  157. // });
  158. // });
  159. // maybeAppend(container, '.timeline-next-btn', () => new Button({}))
  160. // .attr('className', 'timeline-next-btn')
  161. // .call((selection) => {
  162. // if (!nextButtonSize) {
  163. // selection.remove();
  164. // return;
  165. // }
  166. // (selection.node() as Button).update({
  167. // ...(this.style.controlButton?.nextBtn || {}),
  168. // x: layout.nextBtn.x,
  169. // y: layout.nextBtn.y,
  170. // size: nextButtonSize,
  171. // symbol: 'timeline-next-button',
  172. // });
  173. // (selection.node() as Button).update({
  174. // markerStyle: {
  175. // transformOrigin: 'center',
  176. // transform: this.style.orientation === 'vertical' ? 'rotate(90deg)' : '',
  177. // },
  178. // });
  179. // });
  180. // if (this.style.autoPlay && !this.playing) {
  181. // this.playing = true;
  182. // select(this)
  183. // .select('.timeline-axis')
  184. // .call((selection) => (selection.node() as PlayAxis)?.play());
  185. // select(this)
  186. // .select('.timeline-play-btn')
  187. // .call((selection) => (selection.node() as Button)?.update({ symbol: 'timeline-play-button' }));
  188. // }
  189. // if (!this.style.autoPlay && this.playing) {
  190. // this.playing = false;
  191. // select(this)
  192. // .select('.timeline-axis')
  193. // .call((selection) => (selection.node() as PlayAxis)?.stop());
  194. // select(this)
  195. // .select('.timeline-play-btn')
  196. // .call((selection) => (selection.node() as Button)?.update({ symbol: 'timeline-stop-button' }));
  197. // }
  198. // }
  199. // private bindEvents() {
  200. // const axis = select(this).select('.timeline-axis').node() as SliderAxis;
  201. // const playStopBtn = select(this).select('.timeline-play-btn').node() as Button;
  202. // if (playStopBtn) {
  203. // select(playStopBtn).on('pointerdown', (evt: any) => {
  204. // if (this.playing) {
  205. // this.playing = false;
  206. // axis.stop();
  207. // playStopBtn.update({ symbol: 'timeline-stop-button' });
  208. // } else {
  209. // this.playing = true;
  210. // axis.play();
  211. // playStopBtn.update({ symbol: 'timeline-play-button' });
  212. // }
  213. // });
  214. // }
  215. // select(this).on('timelineStopped', () => {
  216. // this.playing = false;
  217. // playStopBtn?.update({ symbol: 'timeline-stop-button' });
  218. // });
  219. // select(this).on('speedChanged', (evt: any) => {
  220. // this.speed = evt.detail.speed;
  221. // axis.update({ playInterval: this.style.playInterval! / this.speed });
  222. // });
  223. // select(this)
  224. // .select('.timeline-prev-btn')
  225. // .on('pointerdown', () => axis.prev());
  226. // select(this)
  227. // .select('.timeline-next-btn')
  228. // .on('pointerdown', () => axis.next());
  229. // select(this).on('singleModeChanged', (evt: any) => {
  230. // this.singleMode = evt.detail.active;
  231. // this.selection = normalSelection(this.selection, this.singleMode);
  232. // this.render();
  233. // });
  234. // select(this).on('selectionChanged', (evt: any) => {
  235. // this.selection = evt.detail.selection;
  236. // });
  237. // }
  238. // }
  239. //# sourceMappingURL=index.js.map