问题描述
Animated.View
import React from "react";
import { StyleSheet,View } from "react-native";
import { PanGestureHandler,State } from "react-native-gesture-handler";
import Animated,{ add,clockRunning,cond,debug,divide,eq,floor,not,set,useCode,} from "react-native-reanimated";
import {
snapPoint,timing,useClock,usePanGestureHandler,useValue,} from "react-native-redash";
import { height,width } from "../../../../../assets/styles/main";
import SingleImage from "./SingleImage";
const MultipleImages = ({ data,content,app }) => {
const styles = StyleSheet.create({
container: {
flex: 1,backgroundColor: "black",},pictures: {
width: width * data.photo.length,height,flexDirection: "row",picture: {
width,overflow: "hidden",image: {
...StyleSheet.absoluteFillObject,width: undefined,height: undefined,});
const clock = useClock();
const index = useValue(0);
const offsetX = useValue(0);
const translateX = useValue(0);
const {
gestureHandler,state,veLocity,translation,} = usePanGestureHandler();
const snapPoints = data.photo.map((_,i) => i * -width);
const to = snapPoint(translateX,veLocity.x,snapPoints);
useCode(
() => [
cond(eq(state,State.ACTIVE),[
set(translateX,add(offsetX,translation.x)),]),cond(eq(state,State.END),timing({ clock,from: translateX,to })),set(offsetX,translateX),cond(not(clockRunning(clock)),[
set(index,floor(divide(translateX,-width))),debug("index",index),],[]
);
return (
<View style={styles.container}>
<PanGestureHandler {...gestureHandler}>
<Animated.View style={{ width: width,height: width }}>
<Animated.View
style={[styles.pictures,{ transform: [{ translateX }] }]}
>
{data.photo.map((item) => (
<SingleImage
app={app}
postId={data._id}
photo={item}
content={content}
/>
))}
</Animated.View>
</Animated.View>
</PanGestureHandler>
</View>
);
};
export default MultipleImages;
解决方法
假设第x列和第a列的值将始终增加,并且那些相应的记录需要并排显示-您可以使用下面的逻辑。但是问题仍然不十分清楚(因为理想情况下,您需要一个排序列或一个ID列才能将它们放在一起。在您的情况下,这些列可能是x&a,但从问题中尚不清楚)。但是,以下查询适用于您的示例。
Select Tb1.a,Tb1.b,Tb2.x
from
(Select a,b,row_number() over(order by a) as rn1 from Table2) Tb1
join (Select x,row_number() over(order by x) as rn2 from Table1) Tb2
on Tb1.rn1 = Tb2.rn2 ;