-
-
Notifications
You must be signed in to change notification settings - Fork 531
/
Copy pathApp.js
829 lines (806 loc) · 30.8 KB
/
App.js
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
import React, { Component } from 'react'
import ReactTooltip from 'react-tooltip'
export default class App extends Component {
constructor(props) {
super(props)
this.state = {
place: 'top',
type: 'dark',
effect: 'float',
condition: false,
}
}
changePlace(place) {
this.setState({
place,
})
}
changeType(type) {
this.setState({
type,
})
}
changeEffect(effect) {
this.setState({
effect,
})
}
_onClick() {
this.setState({
condition: true,
})
}
render() {
const { place, type, effect } = this.state
return (
<div>
<section className="tooltip-example">
<h4 className="title">React Tooltip - V4</h4>
<div className="demonstration">
<a data-for="main" data-tip="Hello<br />multiline<br />tooltip" data-iscapture="true">
◕‿‿◕
</a>
</div>
<div className="control-panel">
<div className="button-group">
<div className="item">
<p>Place</p>
<a
className={place === 'top' ? 'active' : ''}
onClick={this.changePlace.bind(this, 'top')}
>
Top<span className="mark">(default)</span>
</a>
<a
className={place === 'right' ? 'active' : ''}
onClick={this.changePlace.bind(this, 'right')}
>
Right
</a>
<a
className={place === 'bottom' ? 'active' : ''}
onClick={this.changePlace.bind(this, 'bottom')}
>
Bottom
</a>
<a
className={place === 'left' ? 'active' : ''}
onClick={this.changePlace.bind(this, 'left')}
>
Left
</a>
</div>
<div className="item">
<p>Type</p>
<a
className={type === 'dark' ? 'active' : ''}
onClick={this.changeType.bind(this, 'dark')}
>
Dark<span className="mark">(default)</span>
</a>
<a
className={type === 'success' ? 'active' : ''}
onClick={this.changeType.bind(this, 'success')}
>
Success
</a>
<a
className={type === 'warning' ? 'active' : ''}
onClick={this.changeType.bind(this, 'warning')}
>
Warning
</a>
<a
className={type === 'error' ? 'active' : ''}
onClick={this.changeType.bind(this, 'error')}
>
Error
</a>
<a
className={type === 'info' ? 'active' : ''}
onClick={this.changeType.bind(this, 'info')}
>
Info
</a>
<a
className={type === 'light' ? 'active' : ''}
onClick={this.changeType.bind(this, 'light')}
>
Light
</a>
</div>
<div className="item">
<p>Effect</p>
<a
className={effect === 'float' ? 'active' : ''}
onClick={this.changeEffect.bind(this, 'float')}
>
Float<span className="mark">(default)</span>
</a>
<a
className={effect === 'solid' ? 'active' : ''}
onClick={this.changeEffect.bind(this, 'solid')}
>
Solid
</a>
</div>
</div>
<pre>
<div>
<p className="label">Code</p>
<hr />
<p>{'<a data-tip="React-tooltip"> ◕‿‿◕ </a>'}</p>
<p>{`<ReactTooltip place="${place}" type="${type}" effect="${effect}"/>`}</p>
</div>
</pre>
</div>
<ReactTooltip id="main" place={place} type={type} effect={effect} multiline />
</section>
<section className="advance">
<div className="section">
<h4 className="title">Advance features</h4>
<p className="sub-title">Use everything as tooltip</p>
<div className="example-jsx">
<div className="side" style={{ transform: 'translate3d(5px, 5px, 5px)' }}>
<a data-tip data-for="happyFace">
d(`・∀・)b
</a>
<ReactTooltip id="happyFace" type="error">
<span>Show happy face</span>
</ReactTooltip>
</div>
<div className="side">
<a data-tip data-for="sadFace">
இдஇ
</a>
<ReactTooltip id="sadFace" type="warning" effect="solid">
<span>Show sad face</span>
</ReactTooltip>
</div>
</div>
<br />
<pre className="example-pre">
<div>
<p>
{"<a data-tip data-for='happyFace'> d(`・∀・)b </a>\n" +
"<ReactTooltip id='happyFace' type='error'>\n" +
' ' +
' ' +
'<span>Show happy face</span>\n' +
'</ReactTooltip>\n' +
"<a data-tip data-for='sadFace'> இдஇ </a>\n" +
"<ReactTooltip id='sadFace' type='warning' effect='solid'>\n" +
' ' +
' ' +
'<span>Show sad face</span>\n' +
'</ReactTooltip>'}
</p>
</div>
</pre>
<div className="example-jsx">
<div className="side">
<a data-tip data-for="global">
σ`∀´)σ
</a>
</div>
<div className="side">
<a data-tip data-for="global">
(〃∀〃)
</a>
</div>
<ReactTooltip id="global" aria-haspopup="true">
<p>This is a global react component tooltip</p>
<p>You can put every thing here</p>
<ul>
<li>Word</li>
<li>Chart</li>
<li>Else</li>
</ul>
</ReactTooltip>
</div>
<pre className="example-pre">
<div>
<p>
{"<a data-tip data-for='global'> σ`∀´)σ </a>\n" +
"<a data-tip data-for='global'> (〃∀〃) </a>\n" +
"<ReactTooltip id='global' aria-haspopup='true' >\n" +
' <p>This is a global react component tooltip</p>\n' +
' <p>You can put every thing here</p>\n' +
' <ul>\n' +
' ' +
' ' +
' <li>Word</li>\n' +
' ' +
' ' +
' <li>Chart</li>\n' +
' ' +
' ' +
' <li>Else</li>\n' +
' </ul>\n' +
'</ReactTooltip>'}
</p>
</div>
</pre>
</div>
</section>
<section className="advance">
<div className="section">
<h4 className="title">Custom event</h4>
<p className="sub-title" />
<div className="example-jsx">
<div className="side">
<a data-for="custom-event" data-tip="custom show" data-event="click focus">
( •̀д•́)
</a>
<ReactTooltip id="custom-event" globalEventOff="click" />
</div>
<div className="side">
<a
data-for="custom-off-event"
ref={(ref) => (this.targetRef = ref)}
data-tip="custom show and hide"
data-event="click"
data-event-off="dblclick"
>
( •̀д•́)
</a>
<ReactTooltip id="custom-off-event" />
</div>
</div>
<br />
<pre className="example-pre">
<div>
<p>
{"<a data-tip='custom show' data-event='click focus'>( •̀д•́)</a>\n" +
"<ReactTooltip globalEventOff='click' />"}
</p>
</div>
<div>
<p>
{"<a data-tip='custom show and hide' data-event='click' data-event-off='dblclick'>( •̀д•́)</a>\n" +
'<ReactTooltip/>'}
</p>
</div>
</pre>
</div>
<div className="section">
<h4 className="title">Custom colors</h4>
<p className="sub-title" />
<div className="example-jsx">
<div className="side">
<a data-for="custom-color-no-arrow" data-tip="Lovely colors!">
ㅇㅅㅇ
</a>
<ReactTooltip
id="custom-color-no-arrow"
className="custom-color-no-arrow"
textColor="#5F4B8BFF"
backgroundColor="#E69A8DFF"
effect="solid"
/>
</div>
<div className="side">
<a
data-for="custom-color"
data-tip="That is one weird arrow (and a border with custom class name)!"
>
V(^-^)V
</a>
<ReactTooltip
id="custom-color"
className="custom-color"
place="right"
border
borderClass="custom-border-class"
textColor="#5F4B8BFF"
backgroundColor="#E69A8DFF"
borderColor="darkgreen"
arrowColor="red"
/>
</div>
</div>
<br />
<pre className="example-pre">
<div>
<p>
{"<a data-for='custom-color-no-arrow' data-tip='Lovely colors!'>ㅇㅅㅇ</a>\n" +
"<ReactTooltip id='custom-color-no-arrow' className='custom-color-no-arrow' delayHide={1000}\n" +
"textColor='#5F4B8BFF' backgroundColor='#E69A8DFF' effect='solid'/>"}
</p>
</div>
<div>
<p>
{"<a data-for='custom-color' data-tip='That is one weird arrow (and a border)!'>V(^-^)V</a>\n" +
"<ReactTooltip id='custom-color' className='custom-color' place='right' border\n" +
"textColor='#5F4B8BFF' backgroundColor='#E69A8DFF' borderColor='darkgreen' arrowColor='red'/>"}
</p>
</div>
</pre>
</div>
<div className="section">
<h4 className="title">Custom radius</h4>
<p className="sub-title" />
<div className="example-jsx">
<div className="side">
<a data-for="custom-tooltip-radius" data-tip="No tooltip border radius!">
ㅇㅅㅇ
</a>
<ReactTooltip
id="custom-tooltip-radius"
place="right"
className="custom-tooltip-radius"
tooltipRadius="0"
/>
</div>
<div className="side">
<a data-for="custom-arrow-radius" data-tip="That is an arrow with border radius!">
V(^-^)V
</a>
<ReactTooltip
id="custom-arrow-radius"
className="custom-arrow-radius"
place="top"
arrowRadius="3"
/>
</div>
</div>
<br />
<pre className="example-pre">
<div>
<p>
{"<a data-for='custom-tooltip-radius' data-tip='Lovely colors!'>ㅇㅅㅇ</a>\n" +
"<ReactTooltip id='custom-tooltip-radius' className='custom-tooltip-radius' place='right'\n" +
"backgroundColor='#E69A8DFF' tooltipRadius='0'/>"}
</p>
</div>
<div>
<p>
{"<a data-for='custom-arrow-radius' data-tip='That is an arrow with border radius!'>V(^-^)V</a>\n" +
"<ReactTooltip id='custom-arrow-radius' className='custom-arrow-radius' place='top' border\n" +
"backgroundColor='#E69A8DFF' arrowRadius='3'/>"}
</p>
</div>
</pre>
</div>
<div className="section">
<h4 className="title">Theme and delay</h4>
<p className="sub-title" />
<div className="example-jsx">
<div className="side">
<a data-for="custom-class" data-tip="hover on me will keep the tooltip">
(・ω´・ )
</a>
<ReactTooltip
id="custom-class"
className="extraClass"
delayHide={1000}
effect="solid"
/>
</div>
<div className="side">
<a data-for="custom-theme" data-tip="custom theme">
(・ω´・ )
</a>
<ReactTooltip id="custom-theme" className="customTheme" />
</div>
</div>
<br />
<pre className="example-pre">
<div>
<p>
{"<a data-tip='hover on me will keep the tooltip'>(・ω´・ )</a>\n" +
"<ReactTooltip className='extraClass' delayHide={1000} effect='solid'/>\n" +
'.extraClass {\n' +
' font-size: 20px !important;\n' +
' pointer-events: auto !important;\n' +
' &:hover {\n' +
'visibility: visible !important;\n' +
'opacity: 1 !important;\n' +
' }\n' +
'}'}
</p>
</div>
<div>
<p>
{"<a data-tip='custom theme'>(・ω´・ )</a>\n" +
"<ReactTooltip className='customTheme'/>\n" +
' .customTheme {\n' +
' color: #ff6e00 !important;\n' +
' background-color: orange !important;\n' +
' &.place-top {\n' +
' &:after {\n' +
' border-top-color: orange !important;\n' +
' border-top-style: solid !important;\n' +
' border-top-width: 6px !important;\n' +
' }\n' +
' }\n' +
'}'}
</p>
</div>
</pre>
</div>
<div className="section">
<h4 className="title">Update tip content over time</h4>
<p className="sub-title" />
<div className="example-jsx">
<div className="side">
<a data-for="getContent" data-tip>
=( •̀д•́)
</a>
<ReactTooltip id="getContent" getContent={() => Math.floor(Math.random() * 100)} />
</div>
<div className="side">
<a data-for="overTime" data-tip>
=( •̀д•́)
</a>
<ReactTooltip
id="overTime"
getContent={[
() => {
return 'Random length content'.slice(0, Math.floor(Math.random() * 21) + 1)
},
1000,
]}
/>
</div>
</div>
<br />
<pre className="example-pre">
<div>
<p>
{"<a data-for='getContent' data-tip>=( •̀д•́)</a>\n" +
"<ReactTooltip id='getContent' getContent={() => Math.floor(Math.random() * 100)} />"}
</p>
</div>
<div>
<p>
{"<a data-for='overTime' data-tip>=( •̀д•́)</a>\n" +
"<ReactTooltip id='overTime' getContent={[() => {\n" +
" return 'Random length content'.slice(0, Math.floor(Math.random() * 21) + 1)\n" +
'}, 1000]}/>'}
</p>
</div>
</pre>
</div>
<div className="section">
<h4 className="title">Compute or enrich tip content</h4>
<p className="sub-title" />
<div className="example-jsx">
<div className="side">
<a data-for="enrich" data-tip="sooooo cute">
(❂‿❂)
</a>
</div>
<div className="side">
<a data-for="enrich" data-tip="really high">
(❂‿❂)
</a>
</div>
<ReactTooltip
id="enrich"
getContent={(dataTip) => `This little buddy is ${dataTip}`}
/>
</div>
<br />
<pre className="example-pre">
<div>
<p>
{"<a data-for='enrich' data-tip='sooooo cute'>(❂‿❂)</a>\n" +
"<a data-for='enrich' data-tip='really high'>(❂‿❂)</a>\n" +
/* eslint-disable no-template-curly-in-string */
"<ReactTooltip id='enrich' getContent={(dataTip) => `This little buddy is ${dataTip}`}/>"}
</p>
</div>
</pre>
</div>
<div className="section">
<h4 className="title">Test Scrolling</h4>
<p className="sub-title" />
<div className="example-jsx" style={{ height: '200px' }}>
<div className="side" style={{ overflow: 'auto', height: '200px' }}>
<div
data-for="scrollContent"
data-tip
data-iscapture="true"
style={{ width: '5000px', height: '5000px' }}
>
Scroll me with the mouse wheel.
<br />
The tooltip will hide.
<br />
Make sure you set data-iscapture="true"
</div>
<ReactTooltip
id="scrollContent"
getContent={() => Math.floor(Math.random() * 100)}
/>
</div>
<div className="side" style={{ overflow: 'auto', height: '200px' }}>
<div
data-for="scrollTime"
data-tip
data-iscapture="true"
data-scroll-hide="false"
style={{ width: '5000px', height: '5000px' }}
>
Scroll me with the mouse wheel.
<br />
The tooltip will stay visible.
</div>
<ReactTooltip
id="scrollTime"
getContent={[
() => {
return new Date().toISOString()
},
1000,
]}
/>
</div>
</div>
<br />
<pre className="example-pre">
<div>
<p>
{"<div data-for='scrollContent' data-tip data-iscapture='true'\n" +
"style={{ width: '5000px', height: '5000px' }}>...</div>\n" +
"<ReactTooltip id='scrollContent' getContent={() => Math.floor(Math.random() * 100)}/>"}
</p>
</div>
<div>
<p>
{"<div data-for='scrollTime' data-tip data-iscapture='true' data-scroll-hide='false'\n" +
"style={{ width: '5000px', height: '5000px' }}>...</div>\n" +
"<ReactTooltip id='scrollTime' getContent={[() => {return new Date().toISOString()}, 1000]}/>"}
</p>
</div>
</pre>
</div>
<div className="section">
<h4 className="title">Test SVG</h4>
<p>Note: if you dynamically change elements in the SVG, add:</p>
<pre>{' componentDidUpdate() {\n' + ' ReactTooltip.rebuild()\n' + ' }'}</pre>
<p className="sub-title" />
<div className="example-jsx">
<div className="side" style={{ textAlign: 'center' }}>
<svg data-tip="=( •̀д•́)" data-for="svgTooltip" width="50" height="50">
<circle cx="25" cy="25" r="22" fill="#fff" stroke="#000" strokeWidth="4" />
</svg>
<ReactTooltip id="svgTooltip" />
</div>
<div className="side" style={{ textAlign: 'center' }}>
<svg width="75" height="50">
<circle
data-tip="=( •̀‿•́)"
data-for="svgTooltip2"
cx="25"
cy="25"
r="22"
fill="#fff"
stroke="#000"
strokeWidth="4"
/>
<circle
data-tip="=( ❂‿❂)"
data-for="svgTooltip2"
cx="50"
cy="25"
r="16"
fill="#ddd"
stroke="#444"
strokeWidth="4"
/>
</svg>
<ReactTooltip id="svgTooltip2" />
</div>
</div>
<br />
<pre className="example-pre">
<div>
<p>
{"<svg data-tip='=( •̀д•́)' data-for='svgTooltip' width='50' height='50'>\n" +
" <circle cx='25' cy='25' r='22' fill='#fff' stroke='#000' strokeWidth='8'/>\n" +
'</svg>\n' +
"<ReactTooltip id='svgTooltip' />"}
</p>
<p>
{"<svg width='75' height='50'>\n" +
"<circle data-tip='=( •̀‿•́)' data-for='svgTooltip2'\n" +
" cx='25' cy='25' r='22' fill='#fff' stroke='#000' strokeWidth='4'/>\n" +
"<circle data-tip='=( ❂‿❂)' data-for='svgTooltip2'\n" +
" cx='50' cy='25' r='16' fill='#fdf' stroke='#404' strokeWidth='4'/>\n" +
'</svg>\n' +
"<ReactTooltip id='svgTooltip2'/>"}
</p>
</div>
</pre>
</div>
<div className="section">
<h4 className="title">Demonstrate using mouse in tooltip. </h4>
<p>
Notice that the tooltip delays going away so you can get your mouse in it. You must
set delayUpdate and delayHide for the tooltip to stay long enough to get your mouse
over it.
</p>
<p className="sub-title" />
<div className="example-jsx">
<div className="block">
<a data-for="soclose" data-tip="1">
1 (❂‿❂)
</a>
</div>
<div className="block">
<a data-for="soclose" data-tip="2">
2 (❂‿❂)
</a>
</div>
<div className="block">
<a data-for="soclose" data-tip="3">
3 (❂‿❂)
</a>
</div>
<div className="block">
<a data-for="soclose" data-tip="4">
4 (❂‿❂)
</a>
</div>
<div className="block">
<a data-for="soclose" data-tip="5">
5 (❂‿❂)
</a>
</div>
<div className="block">
<a data-for="soclose" data-tip="6">
6 (❂‿❂)
</a>
</div>
<div className="block">
<a data-for="soclose" data-tip="7">
7 (❂‿❂)
</a>
</div>
<div className="block">
<a data-for="soclose" data-tip="8">
8 (❂‿❂)
</a>
</div>
<ReactTooltip
id="soclose"
getContent={(dataTip) => (
<div>
<h3>This little buddy is {dataTip}</h3>
<p>Put mouse here</p>
</div>
)}
effect="solid"
delayHide={500}
delayShow={500}
delayUpdate={500}
place="right"
border
type="light"
/>
</div>
<br />
<pre className="example-pre">
<div>
<p>{"<a data-for='soclose' data-tip='1'>1 (❂‿❂)</a>"}</p>
<p>{"<a data-for='soclose' data-tip='2'>2 (❂‿❂)</a>..."}</p>
<p>{"<a data-for='soclose' data-tip='8'>8 (❂‿❂)</a>"}</p>
<p>
{"<ReactTooltip id='soclose'\n" +
' getContent={(dataTip) => \n' +
' <div><h3>This little buddy is {dataTip}</h3><p>Put mouse here</p></div> }\n' +
" effect='solid'\n" +
' delayHide={500}\n' +
' delayShow={500}\n' +
' delayUpdate={500}\n' +
" place={'right'}\n" +
' border={true}\n' +
" type={'light'}\n" +
'/>'}
</p>
</div>
</pre>
<p>
When <em>clickable</em> property is set to <em>true</em>, tooltip can respond to mouse
(or touch) events.
</p>
<p className="sub-title" />
<div className="example-jsx">
<div className="block">
<a data-tip data-for="clickme" data-event="click">
(❂‿❂)
</a>
</div>
<ReactTooltip id="clickme" place="right" effect="solid" clickable>
<input type="text" placeholder="Type something..." />
</ReactTooltip>
</div>
<br />
<pre className="example-pre">
<div>
<p>{"<a data-tip data-for='clickme' data-event='click'> (❂‿❂) </a>"}</p>
<p>
{"<ReactTooltip id='clickme' place='right' effect='solid' clickable={true}>\n" +
"<input type='text' placeholder='Type something...' /> \n" +
'</ReactTooltip>'}
</p>
</div>
</pre>
</div>
<div className="section">
<h4 className="title">Override position</h4>
<p className="sub-title">
Try to resize/zoom in window - tooltip in this sample will try to magnet to window
borders, top left border is priority here. Idea is following: sometimes you have
custom border cases, like custom scrolls, small windows, iframes, react-tooltip itself
can not cover everything, so up to you if you want to customize default behavior, or
may be just limit it like in this example.
</p>
<div className="example-jsx">
<div className="side" style={{ display: 'flex', width: '100%' }}>
<a data-tip data-for="overridePosition">
( •̀д•́) override
</a>
<ReactTooltip
id="overridePosition"
overridePosition={({ left, top }, currentEvent, currentTarget, node) => {
const d = document.documentElement
left = Math.min(d.clientWidth - node.clientWidth, left)
top = Math.min(d.clientHeight - node.clientHeight, top)
left = Math.max(0, left)
top = Math.max(0, top)
return { top, left }
}}
>
<div>header</div>
<img src="http://lorempixel.com/100/1500" alt="lorem 100x1500" />
<div>footer</div>
</ReactTooltip>
<a data-tip data-for="noOverridePosition">
( •̀д•́) noOverride
</a>
<ReactTooltip id="noOverridePosition">
<div>header</div>
<img src="http://lorempixel.com/100/1500" alt="lorem 100x1500" />
<div>footer</div>
</ReactTooltip>
</div>
</div>
<br />
<pre className="example-pre">
<div>
<p>
{"<a data-tip data-for='overridePosition'>( •̀д•́) override</a>\n" +
'<ReactTooltip\n' +
" id='overridePosition'\n" +
' overridePosition={ (\n' +
' { left, top },\n' +
' currentEvent, currentTarget, node) => {\n' +
' const d = document.documentElement;\n' +
' left = Math.min(d.clientWidth - node.clientWidth, left);\n' +
' top = Math.min(d.clientHeight - node.clientHeight, top);\n' +
' left = Math.max(0, left);\n' +
' top = Math.max(0, top);\n' +
' return { top, left }\n' +
'} }>\n' +
' <div>header</div>\n' +
' <img src="http://lorempixel.com/100/1500" alt="lorem image 100x1500" />\n' +
' <div>footer</div>\n' +
'</ReactTooltip>\n' +
"<a data-tip data-for='noOverridePosition'>( •̀д•́) noOverride</a>\n" +
"<ReactTooltip id='noOverridePosition'>\n" +
' <div>header</div>\n' +
' <img src="http://lorempixel.com/100/1500" alt="lorem image 100x1500" />\n' +
' <div>footer</div>\n' +
'</ReactTooltip>'}
</p>
</div>
</pre>
</div>
</section>
</div>
)
}
}