Skip to content

Commit 7f89a8c

Browse files
Kacper ŻółkiewskiKacper Żółkiewski
authored andcommitted
feat: add handling onSvgLayout event in Svg component
1 parent 022b467 commit 7f89a8c

File tree

2 files changed

+6
-12
lines changed

2 files changed

+6
-12
lines changed

android/src/main/java/com/horcrux/svg/RenderableViewManager.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,7 @@
142142
import com.facebook.react.viewmanagers.RNSVGUseManagerDelegate;
143143
import com.facebook.react.viewmanagers.RNSVGUseManagerInterface;
144144
import com.horcrux.svg.events.SvgLoadEvent;
145+
import com.horcrux.svg.events.SvgOnLayoutEvent;
145146
import java.util.HashMap;
146147
import java.util.Locale;
147148
import java.util.Map;
@@ -589,14 +590,10 @@ class RenderableViewManager<T extends RenderableView> extends VirtualViewManager
589590
super(svgclass);
590591
}
591592

592-
public Map getExportedCustomBubblingEventTypeConstants() {
593-
return MapBuilder.builder().put(
594-
"topSvgLayout",
595-
MapBuilder.of(
596-
"phasedRegistrationNames",
597-
MapBuilder.of("bubbled", "onSvgLayout")
598-
)
599-
).build();
593+
public Map<String, Object> getExportedCustomDirectEventTypeConstants() {
594+
Map<String, Object> eventTypes = new HashMap<>();
595+
eventTypes.put(SvgOnLayoutEvent.EVENT_NAME, MapBuilder.of("registrationName", "onSvgLayout"));
596+
return eventTypes;
600597
}
601598

602599
static class GroupViewManagerAbstract<U extends GroupView> extends RenderableViewManager<U> {

src/elements/Svg.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -172,10 +172,6 @@ export default class Svg extends Shape<SvgProps> {
172172

173173
extractResponder(props, props, this as ResponderInstanceProps);
174174

175-
if (onLayout != null) {
176-
props.onLayout = onLayout;
177-
}
178-
179175
const gStyle = Object.assign({}, StyleSheet.flatten(style));
180176
if (transform) {
181177
if (gStyle.transform) {
@@ -209,6 +205,7 @@ export default class Svg extends Shape<SvgProps> {
209205
strokeLinecap,
210206
strokeLinejoin,
211207
strokeMiterlimit,
208+
onLayout,
212209
}}
213210
/>
214211
</RNSVGSvg>

0 commit comments

Comments
 (0)