File tree 2 files changed +22
-6
lines changed
web-common/src/components/data-graphic
2 files changed +22
-6
lines changed Original file line number Diff line number Diff line change @@ -61,7 +61,13 @@ export function outline(
61
61
const observer = new MutationObserver ( ( ) => {
62
62
clonedElement . setAttribute ( "x" , node . getAttribute ( "x" ) ) ;
63
63
clonedElement . setAttribute ( "y" , node . getAttribute ( "y" ) ) ;
64
- clonedElement . setAttribute ( "text-anchor" , node . getAttribute ( "text-anchor" ) ) ;
64
+ if ( node . getAttribute ( "text-anchor" ) ) {
65
+ clonedElement . setAttribute (
66
+ "text-anchor" ,
67
+ node . getAttribute ( "text-anchor" )
68
+ ) ;
69
+ }
70
+
65
71
if ( node . getAttribute ( "dx" ) ) {
66
72
clonedElement . setAttribute ( "dx" , node . getAttribute ( "dx" ) ) ;
67
73
}
Original file line number Diff line number Diff line change 37
37
elementHeight = bb .height ;
38
38
elementX = bb .x ;
39
39
elementY = bb .y ;
40
-
41
40
if (location === " right" && elementX + elementWidth > $config .plotRight ) {
42
41
xOffset .set (- elementWidth - buffer );
43
42
} else {
44
43
xOffset .set (buffer );
45
44
}
46
45
}
47
46
48
- let observer;
47
+ let resize;
48
+ let mutation;
49
49
50
50
onMount (() => {
51
- observer = new ResizeObserver (() => {
51
+ // resize if element updates.
52
+ resize = new ResizeObserver (() => {
52
53
if (element ) update ();
53
54
});
54
- observer .observe (element );
55
+ // reposition if element DOM parameters change.
56
+ mutation = new MutationObserver (() => {
57
+ update ();
58
+ });
59
+ mutation .observe (element , {
60
+ attributes: true ,
61
+ childList: true ,
62
+ });
63
+ resize .observe (element );
55
64
update ();
56
65
});
57
66
58
67
onDestroy (() => {
59
- observer .unobserve (element );
68
+ resize .unobserve (element );
69
+ mutation .disconnect ();
60
70
});
61
71
62
72
$ : trueX = rx || $xScale (x );
You can’t perform that action at this time.
0 commit comments