11import TestCase from '../../TestCase' ;
22import Fixture from '../../Fixture' ;
3+ import PrintRectsFragmentContainer from './PrintRectsFragmentContainer' ;
34
45const React = window . React ;
5- const { Fragment, useRef, useState} = React ;
66
77export default function GetClientRectsCase ( ) {
8- const fragmentRef = useRef ( null ) ;
9- const [ rects , setRects ] = useState ( [ ] ) ;
10- const getRects = ( ) => {
11- const rects = fragmentRef . current . getClientRects ( ) ;
12- setRects ( rects ) ;
13- } ;
14-
158 return (
169 < TestCase title = "getClientRects" >
1710 < TestCase . Steps >
@@ -26,74 +19,35 @@ export default function GetClientRectsCase() {
2619 </ TestCase . ExpectedResult >
2720 < Fixture >
2821 < Fixture . Controls >
29- < button onClick = { getRects } > Print Rects</ button >
30- < div style = { { display : 'flex' } } >
31- < div
22+ < PrintRectsFragmentContainer >
23+ < span
3224 style = { {
33- position : 'relative' ,
34- width : '30vw' ,
35- height : '30vh' ,
25+ width : '300px' ,
26+ height : '250px' ,
27+ backgroundColor : 'lightblue' ,
28+ fontSize : 20 ,
3629 border : '1px solid black' ,
30+ marginBottom : '10px' ,
3731 } } >
38- { rects . map ( ( { x, y, width, height} , index ) => {
39- const scale = 0.3 ;
40-
41- return (
42- < div
43- key = { index }
44- style = { {
45- position : 'absolute' ,
46- top : y * scale ,
47- left : x * scale ,
48- width : width * scale ,
49- height : height * scale ,
50- border : '1px solid red' ,
51- boxSizing : 'border-box' ,
52- } } > </ div >
53- ) ;
54- } ) }
55- </ div >
56- < div >
57- { rects . map ( ( { x, y, width, height} , index ) => {
58- return (
59- < div >
60- { index } :: { `{` } x: { x } , y: { y } , width: { width } , height:{ ' ' }
61- { height }
62- { `}` }
63- </ div >
64- ) ;
65- } ) }
66- </ div >
67- </ div >
32+ Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do
33+ eiusmod tempor incididunt ut labore et dolore magna aliqua.
34+ </ span >
35+ < div
36+ style = { {
37+ width : '150px' ,
38+ height : '100px' ,
39+ backgroundColor : 'lightgreen' ,
40+ border : '1px solid black' ,
41+ } } > </ div >
42+ < div
43+ style = { {
44+ width : '500px' ,
45+ height : '50px' ,
46+ backgroundColor : 'lightpink' ,
47+ border : '1px solid black' ,
48+ } } > </ div >
49+ </ PrintRectsFragmentContainer >
6850 </ Fixture . Controls >
69- < Fragment ref = { fragmentRef } >
70- < span
71- style = { {
72- width : '300px' ,
73- height : '250px' ,
74- backgroundColor : 'lightblue' ,
75- fontSize : 20 ,
76- border : '1px solid black' ,
77- marginBottom : '10px' ,
78- } } >
79- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do
80- eiusmod tempor incididunt ut labore et dolore magna aliqua.
81- </ span >
82- < div
83- style = { {
84- width : '150px' ,
85- height : '100px' ,
86- backgroundColor : 'lightgreen' ,
87- border : '1px solid black' ,
88- } } > </ div >
89- < div
90- style = { {
91- width : '500px' ,
92- height : '50px' ,
93- backgroundColor : 'lightpink' ,
94- border : '1px solid black' ,
95- } } > </ div >
96- </ Fragment >
9751 </ Fixture >
9852 </ TestCase >
9953 ) ;
0 commit comments