You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by GitBox <gi...@apache.org> on 2018/11/29 03:27:52 UTC

[GitHub] YorkShen closed pull request #1839: *[Android] interaction position for fix element

YorkShen closed pull request #1839: *[Android] interaction position for fix element
URL: https://github.com/apache/incubator-weex/pull/1839
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
index 1255579e2d..1e1353ed2c 100644
--- a/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
+++ b/android/sdk/src/main/java/com/taobao/weex/ui/component/WXComponent.java
@@ -173,6 +173,8 @@
   private String mLastBoxShadowId;
   public int mDeepInComponentTree = 0;
   public boolean mIsAddElementToTree = false;
+  //for fix element case
+  public int interactionAbsoluteX=0,interactionAbsoluteY=0;
 
   public WXTracing.TraceInfo mTraceInfo = new WXTracing.TraceInfo();
 
@@ -988,21 +990,6 @@ public void setLayout(WXComponent component) {
     mAbsoluteY = (int) (nullParent ? 0 : mParent.getAbsoluteY() + getCSSLayoutTop());
     mAbsoluteX = (int) (nullParent ? 0 : mParent.getAbsoluteX() + getCSSLayoutLeft());
 
-    if (mIsAddElementToTree){
-      if (null == getInstance().getApmForInstance().instanceRect){
-        getInstance().getApmForInstance().instanceRect = new Rect();
-      }
-      Rect instanceRect = getInstance().getApmForInstance().instanceRect;
-      instanceRect.set(0,0,mInstance.getWeexWidth(),mInstance.getWeexHeight());
-      boolean inScreen =
-          instanceRect.contains(mAbsoluteX,mAbsoluteY) //leftTop
-          || instanceRect.contains(mAbsoluteX+realWidth,mAbsoluteY)//rightTop
-          || instanceRect.contains(mAbsoluteX,mAbsoluteY+realHeight)//leftBottom
-          || instanceRect.contains(mAbsoluteX+realWidth,mAbsoluteY+realHeight);//rightBottom
-      mInstance.onChangeElement(this,!inScreen);
-    }
-
-
     if (mHost == null) {
       return;
     }
@@ -1051,6 +1038,7 @@ private void setComponentLayoutParams(int realWidth, int realHeight, int realLef
       } else {
         setHostLayoutParams(mHost, realWidth, realHeight, realLeft, realRight, realTop, realBottom);
       }
+      recordInteraction(realWidth,realHeight);
       mPreRealWidth = realWidth;
       mPreRealHeight = realHeight;
       mPreRealLeft = realLeft;
@@ -1062,6 +1050,34 @@ private void setComponentLayoutParams(int realWidth, int realHeight, int realLef
     }
   }
 
+  private void recordInteraction(int realWidth,int realHeight){
+    if (!mIsAddElementToTree){
+      return;
+    }
+    mIsAddElementToTree = false;
+    if (null == mParent){
+      interactionAbsoluteX = 0;
+      interactionAbsoluteY = 0;
+    }else {
+      float cssTop = getCSSLayoutTop();
+      float cssLeft = getCSSLayoutLeft();
+      interactionAbsoluteX = (int)(this.isFixed() ? cssLeft : mParent.interactionAbsoluteX + cssLeft);
+      interactionAbsoluteY = (int)(this.isFixed() ? cssTop  : mParent.interactionAbsoluteY + cssTop);
+    }
+
+    if (null == getInstance().getApmForInstance().instanceRect){
+      getInstance().getApmForInstance().instanceRect = new Rect();
+    }
+    Rect instanceRect = getInstance().getApmForInstance().instanceRect;
+    instanceRect.set(0,0,mInstance.getWeexWidth(),mInstance.getWeexHeight());
+    boolean inScreen =
+          instanceRect.contains(interactionAbsoluteX,interactionAbsoluteY) //leftTop
+              || instanceRect.contains(interactionAbsoluteX+realWidth,interactionAbsoluteY)//rightTop
+              || instanceRect.contains(interactionAbsoluteX,interactionAbsoluteY+realHeight)//leftBottom
+              || instanceRect.contains(interactionAbsoluteX+realWidth,interactionAbsoluteY+realHeight);//rightBottom
+    mInstance.onChangeElement(this,!inScreen);
+  }
+
   private void setWidgetParams(Widget widget, FlatGUIContext UIImp, Point rawoffset,
                                int width, int height, int left, int right, int top, int bottom) {
     Point childOffset = new Point();


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services