-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
Copy pathindex.d.ts
6320 lines (5908 loc) · 250 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
//
// Translation from Objects in help to Typescript interface.
// http://js.cytoscape.org/#notation/functions
// TypeScript Version: 2.3
/**
* WARNING: This is a provisional specification of the Cytoscape.js
* API in TypeScript, based on improvements made on the Typescript
* specification for Cytoscape.js in DefinitelyTyped. This is a work
* in progress and may not be complete, and it may have errors. Please
* report any issues to the issue tracker:
*
* https://github.com/cytoscape/cytoscape.js/issues
*
* cy --> Cy.Core
* the core
*
* eles --> Cy.Collection
* a collection of one or more elements (nodes and edges)
*
* ele --> Cy.Singular
* a collection of a single element (node or edge)
*
* node --> Cy.NodeSingular
* a collection of a single node
*
* nodes -> Cy.NodeCollection
* a collection of one or more nodes
*
* edge --> Cy.EdgeSingular
* a collection of a single edge
*
* edges -> Cy.EdgeCollection
* a collection of one or more edges
*
* The library makes a distinction between input and output parameters
* due to the dynamic behaviour of the Cytoscape library.
*
* For a input parameter it will always expect:
* - Cy.Collection
* The input can be any element (node and edge) collection.
* - Cy.NodeCollection
* The input must be a node collection.
* - Cy.EdgeCollection
* The input must be a edge collection.
* - Cy.Singular
* The input must be a single element.
* - Cy.NodeSingular
* The inut must be a single node.
* - Cy.EdgeSingular
* The input must be a single edge.
*
* For a output of a function it will always give:
* - Cy.Elements
* The output is a collection of node and edge elements OR single element.
* - Cy.EdgeCollection
* The output is a collection of edge elements OR single edge.
* - Cy.NodeCollection
* The output is a collection of node elements OR single node.
*
* A number of interfaces contain nothing as they serve to collect interfaces.
*/
export = cytoscape;
export as namespace cytoscape;
/**
* WARNING: This is a provisional specification of the Cytoscape.js
* API in TypeScript, based on improvements made on the Typescript
* specification for Cytoscape.js in DefinitelyTyped. This is a work
* in progress and may not be complete, and it may have errors. Please
* report any issues to the issue tracker:
*
* https://github.com/cytoscape/cytoscape.js/issues
*/
declare function cytoscape(options?: cytoscape.CytoscapeOptions): cytoscape.Core;
declare function cytoscape(type: string, name: string): unknown;
declare function cytoscape(type: string, name: string, registrant: any): void;
declare namespace cytoscape {
interface Position {
x: number;
y: number;
}
type CssStyleDeclaration = any;
interface ElementDefinition {
group?: ElementGroup;
data: NodeDataDefinition | EdgeDataDefinition;
/**
* Scratchpad data (usually temp or nonserialisable data)
*/
scratch?: Scratchpad;
/**
* The model position of the node (optional on init, mandatory after)
*/
position?: Position;
/**
* can alternatively specify position in rendered on-screen pixels
*/
renderedPosition?: Position;
/**
* Whether the element is selected (default false)
*/
selected?: boolean;
/**
* Whether the selection state is mutable (default true)
*/
selectable?: boolean;
/**
* When locked a node's position is immutable (default false)
*/
locked?: boolean;
/**
* Wether the node can be grabbed and moved by the user
*/
grabbable?: boolean;
/**
* Whether the element has passthrough panning enabled.
*/
pannable?: boolean;
/**
* a space separated list of class names that the element has
*/
classes?: string[] | string;
/**
* CssStyleDeclaration;
*/
style?: CssStyleDeclaration;
/**
* you should only use `style`/`css` for very special cases; use classes instead
*/
css?: Css.Node | Css.Edge;
}
interface ElementDataDefinition {
/**
* elided id => autogenerated id
*/
id?: string;
position?: Position;
}
interface EdgeDefinition extends ElementDefinition {
data: EdgeDataDefinition;
}
interface EdgeDataDefinition extends ElementDataDefinition {
id?: string;
/**
* the source node id (edge comes from this node)
*/
source: string;
/**
* the target node id (edge goes to this node)
*/
target: string;
[key: string]: any;
}
interface NodeDefinition extends ElementDefinition {
data: NodeDataDefinition;
}
interface NodeDataDefinition extends ElementDataDefinition {
id?: string;
parent?: string;
[key: string]: any;
}
interface CytoscapeOptions {
///////////////////////////////////////
// very commonly used options:
/**
* A HTML DOM element in which the graph should be rendered.
* This is optional if Cytoscape.js is run headlessly or if you initialise using jQuery (in which case your jQuery object already has an associated DOM element).
*
* The default is undefined.
*/
container?: HTMLElement | null;
/**
* An array of [[Elements]] specified as plain objects. For convenience, this option can alternatively be specified as a promise that resolves to the elements JSON.
*/
elements?:
| ElementsDefinition
| ElementDefinition[]
| Promise<ElementsDefinition>
| Promise<ElementDefinition[]>
;
/**
* The StylesheetJson (StylesheetJsonBlock[]) used to style the graph. For convenience, this option can alternatively be specified as a promise that resolves to the stylesheet.
*/
style?: StylesheetJson | Promise<StylesheetJson>;
/**
* A plain object that specifies layout options.
* Which layout is initially run is specified by the name field.
* Refer to a layout's documentation for the options it supports.
* If you want to specify your node positions yourself in your elements JSON,
* you can use the preset layout — by default it does not set any positions,
* leaving your nodes in their current positions
* (e.g. specified in options.elements at initialisation time)
*/
layout?: LayoutOptions;
/**
* A plain object that contains graph-level data (i.e. data that does not belong to any particular node or edge).
*/
data?: Record<string, any>;
///////////////////////////////////////
// initial viewport state:
/**
* The initial zoom level of the graph.
* Make sure to disable viewport manipulation options, such as fit, in your layout so that it is not overridden when the layout is applied.
* You can set options.minZoom and options.maxZoom to set restrictions on the zoom level.
*
* The default value is 1.
*/
zoom?: number;
/**
* The initial panning position of the graph. Make sure to disable viewport manipulation options, such as fit,
* in your layout so that it is not overridden when the layout is applied.
*/
pan?: Position;
///////////////////////////////////////
// interaction options?:
/**
* A minimum bound on the zoom level of the graph. The viewport can not be scaled smaller than this zoom level.
*
* The default value is 1e-50.
*/
minZoom?: number;
/**
* A maximum bound on the zoom level of the graph. The viewport can not be scaled larger than this zoom level.
*
* The default value is 1e50.
*/
maxZoom?: number;
/**
* Whether zooming the graph is enabled, both by user events and programmatically.
*
* The default value is true.
*/
zoomingEnabled?: boolean;
/**
* Whether user events (e.g. mouse wheel, pinch-to-zoom) are allowed to zoom the graph. Programmatic changes to zoom are unaffected by this option.
*
* The default value is true.
*/
userZoomingEnabled?: boolean;
/**
* Whether panning the graph is enabled, both by user events and programmatically.
*
* The default value is true.
*/
panningEnabled?: boolean;
/**
* Whether user events (e.g. dragging the graph background) are allowed to pan the graph. Programmatic changes to pan are unaffected by this option.
*
* The default value is true.
*/
userPanningEnabled?: boolean;
/**
* Whether box selection (i.e. drag a box overlay around, and release it to select) is enabled. If enabled, the user must taphold to pan the graph.
*
* The default value is false.
*/
boxSelectionEnabled?: boolean;
/**
* A string indicating the selection behaviour from user input.
* By default, this is set automatically for you based on the type of input device detected.
* On touch devices, 'additive' is default — a new selection made by the user adds to the set of currenly selected elements.
* On mouse-input devices, 'single' is default — a new selection made by the user becomes the entire set of currently selected elements (i.e. the previous elements are unselected).
*
* The default value is (isTouchDevice ? 'additive' : 'single').
*/
selectionType?: SelectionType;
/**
* A nonnegative integer that indicates the maximum allowable distance that a user may move during a tap gesture,
* on touch devices and desktop devices respectively.
*
* This makes tapping easier for users.
* These values have sane defaults, so it is not advised to change these options unless you have very good reason for doing so.
* Larger values will almost certainly have undesirable consequences.
*
* The default value is is 8.
*/
touchTapThreshold?: number;
/**
* A nonnegative integer that indicates the maximum allowable distance that a user may move during a tap gesture,
* on touch devices and desktop devices respectively.
*
* This makes tapping easier for users.
* These values have sane defaults,
* so it is not advised to change these options unless you have very good reason for doing so.
* Larger values will almost certainly have undesirable consequences.
*
* The default value is 4.
*/
desktopTapThreshold?: number;
/**
* Whether nodes should be locked (not draggable at all) by default (if true, overrides individual node state).
*
* The default value is false.
*/
autolock?: boolean;
/**
* Whether nodes should be ungrabified (not grabbable by user) by default (if true, overrides individual node state).
*
* The default value is false.
*/
autoungrabify?: boolean;
/**
* Whether nodes should be unselectified (immutable selection state) by default (if true, overrides individual element state).
*
* The default value is false.
*/
autounselectify?: boolean;
///////////////////////////////////////
// rendering options:
/**
* A convenience option that initialises the Core to run headlessly.
* You do not need to set this in environments that are implicitly headless (e.g. Node.js).
* However, it is handy to set headless: true if you want a headless Core in a browser.
*
* The default value is false.
*/
headless?: boolean;
/**
* A boolean that indicates whether styling should be used.
* For headless (i.e. outside the browser) environments,
* display is not necessary and so neither is styling necessary — thereby speeding up your code.
* You can manually enable styling in headless environments if you require it for a special case.
* Note that it does not make sense to disable style if you plan on rendering the graph.
*
* The default value is true.
*/
styleEnabled?: boolean;
/**
* When set to true, the renderer does not render edges while the viewport is being manipulated.
* This makes panning, zooming, dragging, et cetera more responsive for large graphs.
*
* The default value is false.
*/
hideEdgesOnViewport?: boolean;
/**
* when set to true, the renderer does not render labels while the viewport is being manipulated.
* This makes panning, zooming, dragging, et cetera more responsive for large graphs.
*
* The default value is false.
*/
hideLabelsOnViewport?: boolean;
/**
* When set to true, the renderer uses a texture (if supported) during panning and zooming instead of drawing the elements,
* making large graphs more responsive.
*
* The default value is false.
*/
textureOnViewport?: boolean;
/**
* When set to true, the renderer will use a motion blur effect to make the transition between frames seem smoother.
* This can significantly increase the perceived performance for a large graphs.
*
* The default value is false.
*/
motionBlur?: boolean;
/**
* When motionBlur: true, this value controls the opacity of motion blur frames.
* Higher values make the motion blur effect more pronounced.
*
* The default value is 0.2.
*/
motionBlurOpacity?: number;
/**
* Changes the scroll wheel sensitivity when zooming. This is a multiplicative modifier.
* So, a value between 0 and 1 reduces the sensitivity (zooms slower), and a value greater than 1 increases the sensitivity (zooms faster).
*
* The default value is 1.
*/
wheelSensitivity?: number;
/**
* Overrides the screen pixel ratio with a manually set value (1.0 or 0.666 recommended, if set).
* This can be used to increase performance on high density displays by reducing the effective area that needs to be rendered.
* If you want to use the hardware's actual pixel ratio at the expense of performance, you can set pixelRatio: 'auto'.
*
* The default value is 1.
*/
pixelRatio?: number | "auto";
/**
* Enables the experimental WebGL mode.
* WARNING: This is currently experimental, and may have API changes in future.
*/
webgl?: boolean;
/**
* Prints debug info to the browser console.
* (optional)
* WARNING: This is currently experimental, and may have API changes in future.
*/
webglDebug?: boolean;
/**
* The size of the WebGL texture.
* (provisional, may change in future releases)
* WARNING: This is currently experimental, and may have API changes in future.
*/
webglTexSize?: number;
/**
* The number of rows in the WebGL texture.
* (provisional, may change in future releases)
* WARNING: This is currently experimental, and may have API changes in future.
*/
webglTexRows?: number;
/**
* The batch size for WebGL.
* (provisional, may change in future releases)
* WARNING: This is currently experimental, and may have API changes in future.
*/
webglBatchSize?: number;
/**
* The number of textures per batch in WebGL.
* (provisional, may change in future releases)
* WARNING: This is currently experimental, and may have API changes in future.
*/
webglTexPerBatch?: number;
}
/**
* cy --> Cy.Core
* The core object is your interface to a graph.
*
* It is your entry point to Cytoscape.js:
* All of the library’s features are accessed through this object.
* http://js.cytoscape.org/#core
*/
interface Core
extends
CoreGraphManipulation,
CoreData,
CoreGraphManipulationExt,
CoreEvents,
CoreViewportManipulation,
CoreAnimation,
CoreLayout,
CoreStyle,
CoreExport
{}
/**
* These are the principle functions used to interact with the graph model.
*
* http://js.cytoscape.org/#core/graph-manipulation
*/
interface CoreGraphManipulation {
/**
* Add elements to the graph and return them.
*/
add(
eles: ElementDefinition | ElementDefinition[] | ElementsDefinition | CollectionArgument,
): CollectionReturnValue;
/**
* Remove elements in collecion or match the selector from the graph and return them.
*/
remove(eles: CollectionArgument | Selector): CollectionReturnValue;
/**
* Get a collection from elements in the graph matching the specified selector or from an array of elements.
* If no parameter specified, an empty collection will be returned
*/
collection(eles?: Selector | CollectionArgument[]): CollectionReturnValue;
/**
* check whether the specified id is in the collection
*/
hasElementWithId(id: string): boolean;
/**
* Get an element from its ID in a very performant way.
* http://js.cytoscape.org/#cy.getElementById
*/
getElementById(id: string): CollectionReturnValue;
/**
* Get an element from its ID in a very performant way.
* http://js.cytoscape.org/#cy.getElementById
*/
$id(id: string): CollectionReturnValue;
/**
* Get elements in the graph matching the specified selector.
* http://js.cytoscape.org/#cy.$
*/
$(selector: Selector): CollectionReturnValue;
/**
* Get elements in the graph matching the specified selector.
* http://js.cytoscape.org/#cy.$
*/
elements(selector?: Selector): CollectionReturnValue;
/**
* Get nodes in the graph matching the specified selector.
*/
nodes(selector?: Selector): NodeCollection;
/**
* Get edges in the graph matching the specified selector.
*/
edges(selector?: Selector): EdgeCollection;
/**
* Get elements in the graph matching the specified selector or filter function.
*/
filter(
selector: Selector | ((ele: Singular, i: number, eles: CollectionArgument) => boolean),
): CollectionReturnValue;
/**
* Allow for manipulation of elements without triggering multiple style calculations or multiple redraws.
* http://js.cytoscape.org/#cy.batch
* A callback within which you can make batch updates to elements.
*/
batch(callback: () => void): void;
/**
* Allow for manipulation of elements without triggering multiple style calculations or multiple redraws.
* http://js.cytoscape.org/#cy.batch
*
* Starts batching manually (useful for asynchronous cases).
*/
startBatch(): void;
/**
* Allow for manipulation of elements without triggering multiple style calculations or multiple redraws.
* http://js.cytoscape.org/#cy.batch
*
* Ends batching manually (useful for asynchronous cases).
*/
endBatch(): void;
/**
* Attaches the instance to the specified container for visualisation.
* http://js.cytoscape.org/#cy.mount
*
* If the core instance is headless prior to calling cy.mount(), then
* the instance will no longer be headless and the visualisation will
* be shown in the specified container. If the core instance is
* non-headless prior to calling cy.mount(), then the visualisation
* is swapped from the prior container to the specified container.
*/
mount(element: Element): void;
/**
* Remove the instance from its current container.
* http://js.cytoscape.org/#cy.unmount
*
* This function sets the instance to be headless after unmounting from
* the current container.
*/
unmount(): void;
/**
* A convenience function to explicitly destroy the Core.
* http://js.cytoscape.org/#cy.destroy
*/
destroy(): void;
/**
* Get whether the instance of Cytoscape.js has been destroyed or not.
* https://js.cytoscape.org/#cy.destroyed
*/
destroyed(): boolean;
}
/**
* https://js.cytoscape.org/#core/data
*/
interface CoreData {
/**
* Read and write developer-defined data associated with the graph.
* http://js.cytoscape.org/#cy.data
*/
/**
* Get the entire data object or a particular data field.
* @alias attr
*
* @param name The name of the field to get.
*/
data(name?: string): any;
/**
* Set a particular data field.
* @alias attr
*
* @param name The name of the field to set.
* @param value The value to set for the field (must be JSON-serializable).
*/
data(name: string, value: any): this;
/**
* Update multiple data fields at once via an object.
* @alias attr
*
* @param obj The object containing name-value pairs to update data fields (must be JSON-serializable).
*/
data(obj: Record<string, any>): this;
/**
* Get the entire data object or a particular data field.
*
* @param name The name of the field to get. Get the entire data object
*/
attr(name?: string): any;
/**
* Set a particular data field.
*
* @param name The name of the field to set.
* @param value The value to set for the field (must be JSON-serializable).
*/
attr(name: string, value: any): this;
/**
* Update multiple data fields at once via an object.
*
* @param obj The object containing name-value pairs to update data fields.
*/
attr(obj: Record<string, any>): this;
/**
* Remove developer-defined data associated with the elements.
* https://js.cytoscape.org/#cy.removeData
* @alias removeAttr
*
* @param names A space-separated list of fields to delete.
*/
removeData(names?: string): this;
/**
* Remove developer-defined data associated with the elements.
* https://js.cytoscape.org/#cy.removeData
*
* @param names A space-separated list of fields to delete.
*/
removeAttr(names?: string): this;
}
/**
* http://js.cytoscape.org/#core/graph-manipulation
* http://js.cytoscape.org/#extensions
* These functions are intended for use in extensions.
*/
interface CoreGraphManipulationExt {
/**
* Set the scratchpad at a particular namespace,
* where temporary or non-JSON data can be stored.
* App-level scratchpad data should use namespaces prefixed with underscore, like '_foo'.
*
* If no parameter provided, the entire scratchpad will be returned.
* If only namespace provided, the scratchpad with the namespace will be returned.
*
* @param namespace A namespace string.
* @param value The value to set at the specified namespace.
*/
scratch(namespace?: string): Scratchpad;
scratch(namespace: string, value: any): this;
/**
* Remove scratchpad data. You should remove scratchpad data only at your own namespaces.
* http://js.cytoscape.org/#cy.removeScratch
*
* @param namespace A namespace string.
*/
removeScratch(namespace: string): this;
}
/**
* The principle events from the graph model.
* http://js.cytoscape.org/#core/events
*/
interface CoreEvents {
/**
* Bind to events that occur in the graph.
*
* @param events A space separated list of event names.
* @param handler The handler function that is called when one of the specified events occurs.
* @param selector A selector to specify elements for which the handler is triggered.
* @param data A plain object which is passed to the handler in the event object argument.
* @param eventsMap A map of event names to handler functions.
*/
on(events: EventNames, handler: EventHandler): this;
on(events: EventNames, selector: Selector, handler: EventHandler): this;
on(events: EventNames, selector: Selector, data: any, handler: EventHandler): this;
on(eventsMap: { [value: string]: EventHandler }, selector?: Selector, data?: any): this;
bind(events: EventNames, handler: EventHandler): this;
bind(events: EventNames, selector: Selector, handler: EventHandler): this;
bind(events: EventNames, selector: Selector, data: any, handler: EventHandler): this;
bind(eventsMap: { [value: string]: EventHandler }, selector?: Selector, data?: any): this;
listen(events: EventNames, handler: EventHandler): this;
listen(events: EventNames, selector: Selector, handler: EventHandler): this;
listen(events: EventNames, selector: Selector, data: any, handler: EventHandler): this;
listen(eventsMap: { [value: string]: EventHandler }, selector?: Selector, data?: any): this;
addListener(events: EventNames, handler: EventHandler): this;
addListener(events: EventNames, selector: Selector, handler: EventHandler): this;
addListener(events: EventNames, selector: Selector, data: any, handler: EventHandler): this;
addListener(eventsMap: { [value: string]: EventHandler }, selector?: Selector, data?: any): this;
/**
* Get a promise that is resolved with the first
* of any of the specified events triggered on the graph.
* @param events A space separated list of event names.
* @param selector [optional] A selector to specify elements for which the handler is triggered.
*/
promiseOn(events: EventNames, selector?: Selector): Promise<EventHandler>;
pon(events: EventNames, selector?: Selector): Promise<EventHandler>;
/**
* Bind to events that occur in the graph, and trigger the handler only once.
*
* @param events A space separated list of event names.
* @param handler The handler function that is called when one of the specified events occurs.
*/
one(events: EventNames, handler: EventHandler): this;
/**
* Bind to events that occur in the graph, and trigger the handler only once.
*
* @param events A space separated list of event names.
* @param handler The handler function that is called when one of the specified events occurs.
* @param selector A selector to specify elements for which the handler is triggered.
*/
one(events: EventNames, selector: Selector, handler: EventHandler): this;
/**
* Bind to events that occur in the graph, and trigger the handler only once.
*
* @param events A space separated list of event names.
* @param handler The handler function that is called when one of the specified events occurs.
* @param selector A selector to specify elements for which the handler is triggered.
* @param data A plain object which is passed to the handler in the event object argument.
*/
one(events: EventNames, selector: Selector, data: any, handler: EventHandler): this;
/**
* Bind to events that occur in the graph, and trigger the handler only once.
*
* @param eventsMap A map of event names to handler functions.
* @param selector A selector to specify elements for which the handler is triggered.
* @param data A plain object which is passed to the handler in the event object argument.
*/
one(eventsMap: { [value: string]: EventHandler }, selector?: Selector, data?: any): this;
/**
* Remove event handlers.
* http://js.cytoscape.org/#cy.off
*
* @param events A space separated list of event names.
* @param selector [optional] The same selector used to bind to the events.
* @param handler [optional] A reference to the handler function to remove.
* @param eventsMap A map of event names to handler functions to remove.
*/
off(events: EventNames, handler?: EventHandler): this;
off(events: EventNames, selector: Selector, handler?: EventHandler): this;
off(eventsMap: { [value: string]: EventHandler }, selector?: Selector): this;
unbind(events: EventNames, handler?: EventHandler): this;
unbind(events: EventNames, selector: Selector, handler?: EventHandler): this;
unbind(eventsMap: { [value: string]: EventHandler }, selector?: Selector): this;
unlisten(events: EventNames, handler?: EventHandler): this;
unlisten(events: EventNames, selector: Selector, handler?: EventHandler): this;
unlisten(eventsMap: { [value: string]: EventHandler }, selector?: Selector): this;
removeListener(events: EventNames, handler?: EventHandler): this;
removeListener(events: EventNames, selector: Selector, handler?: EventHandler): this;
removeListener(eventsMap: { [value: string]: EventHandler }, selector?: Selector): this;
/**
* Remove all event handlers.
* https://js.cytoscape.org/#cy.removeAllListeners
*/
removeAllListeners(): this;
/**
* Trigger one or more events.
*
* @param events A space separated list of event names to trigger.
* @param extraParams [optional] An array of additional parameters to pass to the handler.
*/
trigger(events: EventNames, extraParams?: any[]): this;
emit(events: EventNames, extraParams?: any[]): this;
/**
* Run a callback as soon as the graph becomes ready. If the graph is already ready, then the callback is called immediately.
* @param fn The callback run as soon as the graph is ready, inside which this refers to the core (cy).
*/
ready(fn: EventHandler): this;
}
interface ZoomOptionsModel {
/** The position about which to zoom. */
position: Position;
}
interface ZoomOptionsRendered {
/** The rendered position about which to zoom. */
renderedPosition: Position;
}
interface ZoomOptionsLevel {
/** The zoom level to set. */
level: number;
}
type ZoomOptions = number | (ZoomOptionsLevel & (ZoomOptionsModel | ZoomOptionsRendered));
/**
* http://js.cytoscape.org/#core/viewport-manipulation
*/
interface CoreViewportManipulation {
/**
* Get the HTML DOM element in which the graph is visualised.
* A null value is returned if the Core is headless.
*/
container(): HTMLElement | null;
/**
* Pan the graph to the centre of a collection.
*
* @param eles The collection to centre upon.
*/
center(eles?: CollectionArgument): this;
/**
* Pan the graph to the centre of a collection.
*
* @param eles The collection to centre upon.
*/
centre(eles?: CollectionArgument): this;
/**
* Pan and zooms the graph to fit to a collection.
* http://js.cytoscape.org/#cy.fit
*
* @param eles [optional] The collection to fit to.
* @param padding [optional] An amount of padding (in pixels) to have around the graph
*/
fit(eles?: CollectionArgument, padding?: number): this;
/**
* Reset the graph to the default zoom level and panning position.
* http://js.cytoscape.org/#cy.reset
*/
reset(): this;
/**
* Get the panning position of the graph.
* http://js.cytoscape.org/#cy.pan
*/
pan(): Position;
/**
* Set the panning position of the graph.
* http://js.cytoscape.org/#cy.pan
*
* @param renderedPosition The rendered position to pan the graph to.
*/
pan(renderedPosition?: Position): this;
/**
* Relatively pan the graph by a specified rendered position vector.
* http://js.cytoscape.org/#cy.panBy
*
* @param renderedPosition The rendered position vector to pan the graph by.
*/
panBy(renderedPosition: Position): this;
/**
* Get whether panning is enabled.
* If cy.boxSelectionEnabled() === true, then the user
* must taphold to initiate panning.
* http://js.cytoscape.org/#cy.panningEnabled
*/
panningEnabled(): boolean;
/**
* Set whether panning is enabled. If cy.boxSelectionEnabled() === true, then the user must taphold to initiate panning.
* http://js.cytoscape.org/#cy.panningEnabled
*
* @param bool A truthy value enables panning; a falsey value disables it.
*/
panningEnabled(bool?: boolean): this;
/**
* Get whether panning by user events (e.g. dragging the graph background) is enabled. If cy.boxSelectionEnabled() === true, then the user must taphold to initiate panning.
* http://js.cytoscape.org/#cy.userPanningEnabled
*/
userPanningEnabled(): boolean;
/**
* Set whether panning by user events (e.g. dragging the graph background) is enabled. If cy.boxSelectionEnabled() === true, then the user must taphold to initiate panning.
* http://js.cytoscape.org/#cy.userPanningEnabled
*
* @param bool A truthy value enables user panning; a falsey value disables it.
*/
userPanningEnabled(bool?: boolean): this;
/**
* Get the zoom level.
* http://js.cytoscape.org/#cy.zoom
*/
zoom(): number;
/**
* Set the zoom level.
* http://js.cytoscape.org/#cy.zoom
*
* @param level The zoom level to set.
* @param options The options for zooming.
*/
zoom(level?: number | ZoomOptions): this;
/**
* Set or get whether zooming is enabled. Get if no parameter provided.
* http://js.cytoscape.org/#cy.zoomingEnabled
*
* @param bool A truthy value enables zooming; a falsey value disables it.
*/
zoomingEnabled(bool?: boolean): this;
/**
* Get whether zooming by user events (e.g. mouse wheel, pinch-to-zoom)
* is enabled.
* http://js.cytoscape.org/#cy.userZoomingEnabled
*/
userZoomingEnabled(): boolean;
/**
* Get or set whether zooming by user events get if no parameter provided
* (e.g. mouse wheel, pinch-to-zoom) is enabled.
* http://js.cytoscape.org/#cy.userZoomingEnabled
*
* @param bool A truthy value enables user zooming; a falsey value disables it.
*/
userZoomingEnabled(bool?: boolean): this;
/**
* Get the minimum zoom level.
* http://js.cytoscape.org/#cy.minZoom
*/
minZoom(): number;
/**
* Set the minimum zoom level.
* http://js.cytoscape.org/#cy.minZoom
*
* @param zoom The new minimum zoom level to use.
*/
minZoom(zoom: number): this;
/**
* Get the maximum zoom level.
* http://js.cytoscape.org/#cy.maxZoom
*/
maxZoom(): number;
/**
* Set the maximum zoom level.
* http://js.cytoscape.org/#cy.maxZoom
*
* @param zoom The new maximum zoom level to use.
*/
maxZoom(zoom: number): this;
/**
* Set the viewport state (pan & zoom) in one call.
* http://js.cytoscape.org/#cy.viewport
*
* @param options The viewport options.
* @param options.zoom The zoom level to set.
* @param options.pan The pan to set (a rendered position).
*/
viewport(options: { zoom: number; pan: Position }): this;
/**
* Get whether box selection is enabled.
* If enabled, the user must hold left-click to initiate panning.
* http://js.cytoscape.org/#cy.boxSelectionEnabled
*/
boxSelectionEnabled(): boolean;
/**
* Set whether box selection is enabled.
* If enabled, the user must hold left-click to initiate panning.
* http://js.cytoscape.org/#cy.boxSelectionEnabled
*
* @param bool A truthy value enables box selection; a falsey value disables it.
*/
boxSelectionEnabled(bool?: boolean): this;
/**
* Get the selection type.
* http://js.cytoscape.org/#cy.selectionType
*/
selectionType(): SelectionType;
/**
* Set the selection type.
* http://js.cytoscape.org/#cy.selectionType