Skip to content

Commit

Permalink
fix(android): element y position use root view location
Browse files Browse the repository at this point in the history
  • Loading branch information
lavnFan authored and zoomchan-cxj committed Nov 16, 2021
1 parent ec2686f commit 3542a59
Showing 1 changed file with 11 additions and 5 deletions.
Expand Up @@ -338,11 +338,12 @@ private int[] getRenderViewLocation(HippyEngineContext context, RenderNode rende
View view = controllerManager.findView(renderNode.getId());
if (view != null) {
view.getLocationOnScreen(viewLocation);
int statusBarHeight = ControllerManager.getStatusBarHeightFromSystem();
viewLocation[1] = viewLocation[1] - statusBarHeight;
if (isTranslucentStatus(context)) {
// 沉浸式,需要加回状态栏的高度
viewLocation[1] = viewLocation[1] + statusBarHeight;
HippyRootView rootView = getRootView(context);
if (rootView != null) {
int[] rootViewLocation = new int[2];
rootView.getLocationOnScreen(rootViewLocation);
viewLocation[0] = viewLocation[0] - rootViewLocation[0];
viewLocation[1] = viewLocation[1] - rootViewLocation[1];
}
} else {
return null;
Expand Down Expand Up @@ -512,6 +513,11 @@ public JSONObject setInspectMode(HippyEngineContext context, JSONObject paramsOb
return new JSONObject();
}

private static HippyRootView getRootView(HippyEngineContext context) {
int rootId = context.getDomManager().getRootNodeId();
return context.getInstance(rootId);
}

/**
* https://dom.spec.whatwg.org/#dom-node-nodetype
*/
Expand Down

0 comments on commit 3542a59

Please sign in to comment.