Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
430 views
in Technique[技术] by (71.8m points)

gesture - React Native drawing on RTL devices is incorrect/mirrored

I am facing a problem with drawing on RTL devices. gestureRecorder's gesture path is coming correctly onPanRelease callback, its displayed correctly when I finished drawing. But in GesturePath when I try to draw the live path it doesn't get drawn correctly its the exact mirror on the screen, if I draw left side with clock circular, it will be right screen side with anti clock way, but when i finish drawing its drawed in the right place..

 <View style={{ position: "absolute", width: WIDTH, height: VIEW_HEIGHT - HEIGHT * 0.5, zIndex: 4 }}>
        <GestureRecorder
          onPanRelease={(gesture) => {
              const point = {
                id: allPoints2.length + 1,
                points: gesture,
              };
              setAllPoints2((allPoints2) => [...allPoints2, point]);
            }
          }
        >
          {({ gesture, offset }) => {
            if (!_.isEqual(offset, recorderOffset) && offset !== null) {
              setRecorderOffset(offset);
              // setPoints(offset);
              if (offset) {
                const point = {
                  x: offset.x,
                  y: offset.y,
                };
                setAllPoints((allPoints) => [...allPoints, point]);
                // console.log("offset", allPoints);
              }
            }

            return (
              <View
                style={{
                  position: "relative",
                  width: "100%",
                  height: "100%",
                }}
              >
                <View style={{ position: "relative", width: "100%", height: "100%" }}>
                  <GesturePath
                    path={gesture.map((coordinate) => {
                      if (recorderOffset) {
                        return {
                          x: coordinate.x + recorderOffset.x,
                          y: coordinate.y + recorderOffset.y,
                        };
                      }
                      console.log("coordinate: ",coordinate)
                      return coordinate;
                    })}
                    color="green"
                    slopRadius={5}
                    center={false}
                  />
                </View>
              </View>
            );
          }}
        </GestureRecorder>
      </View>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...