我正在使用PanGestureHandler和PinchGestureHandler来允许在屏幕上平移和放大/缩小大图像。但是,一旦引入缩放变换,平移的行为就会有所不同。
我通过此实施实现了三个目标:
0不会将图像置于左上角(由于缩放原点居中)。1)。这是我到目前为止所拥有的:
import React, { useRef, useCallback } from 'react';
import { StyleSheet, Animated, View, LayoutChangeEvent } from 'react-native';
import {
PanGestureHandler,
PinchGestureHandler,
PinchGestureHandlerStateChangeEvent,
State,
PanGestureHandlerStateChangeEvent,
} from 'react-native-gesture-handler';
const IMAGE_DIMENSIONS = {
width: 2350,
height: 1767,
} as const;
export default function App() {
const scale = useRef(new Animated.Value(1)).current;
const translateX = useRef(new Animated.Value(0)).current;
const translateY = useRef(new Animated.Value(0)).current;
const setInitialPanZoom = useCallback((event: LayoutChangeEvent) …Run Code Online (Sandbox Code Playgroud) animation react-native react-tsx react-native-gesture-handler
我正在尝试在流星项目上运行Jasmine客户端集成测试.我正在使用meteor 0.9.4,以及sanjo:jasmineJasmine 的包.
我写了一个测试,看起来像:
describe("Template.dashboard.tasks", function() {
it("ela displays correct assessment", function() {
Session.set("selected_subject", "math");
Session.set('selected_grade', "1");
tasks = Template.dashboard.tasks();
expect(true).toBe(true);
});
});
Run Code Online (Sandbox Code Playgroud)
在它可以到达测试结束之前我得到一个错误:
Cannot read property 'tasks' of undefined
Run Code Online (Sandbox Code Playgroud)
这意味着Template.dashboard在本次测试的范围内不存在.
Template.dashboard.tasks()是一个完全有效的辅助函数,它js位于视图文件夹中的文件中.常规Jasmine测试按预期工作,但是一旦我尝试从另一个文件中使用我自己的一个函数,它就不起作用.
我的问题是:我是否需要做一些事情才能让Jasmine测试访问我的模板帮助函数?
animation ×1
jasmine ×1
javascript ×1
meteor ×1
react-native ×1
react-native-gesture-handler ×1
react-tsx ×1
templates ×1
unit-testing ×1