index.js 9.3 KB

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