react-photo-view-fix
Version:
一款精致的 React 的图片预览组件
95 lines (94 loc) • 3.2 kB
TypeScript
import React from 'react';
import { TapFuncType } from './utils/withContinuousTap';
import { ReachMoveFunction, ReachFunction, PhotoTapFunction, ReachTypeEnum, ShowAnimateEnum, OriginRectType, brokenElementDataType } from './types';
import './PhotoView.less';
export interface IPhotoViewProps {
src: string;
intro?: React.ReactNode;
viewClassName?: string;
className?: string;
style?: object;
loadingElement?: JSX.Element;
brokenElement?: JSX.Element | ((photoProps: brokenElementDataType) => JSX.Element);
rotate: number;
onPhotoTap: PhotoTapFunction;
onMaskTap: PhotoTapFunction;
onReachMove: ReachMoveFunction;
onReachUp: ReachFunction;
onPhotoResize?: () => void;
isActive: boolean;
showAnimateType?: ShowAnimateEnum;
originRect?: OriginRectType;
}
declare const initialState: {
naturalWidth: number;
naturalHeight: number;
width: number;
height: number;
loaded: boolean;
broken: boolean;
x: number;
y: number;
scale: number;
touched: boolean;
maskTouched: boolean;
clientX: number;
clientY: number;
lastX: number;
lastY: number;
lastMoveClientX: number;
lastMoveClientY: number;
touchedTime: number;
lastTouchLength: number;
reachState: ReachTypeEnum;
};
export default class PhotoView extends React.Component<IPhotoViewProps, typeof initialState> {
static displayName: string;
readonly state: {
naturalWidth: number;
naturalHeight: number;
width: number;
height: number;
loaded: boolean;
broken: boolean;
x: number;
y: number;
scale: number;
touched: boolean;
maskTouched: boolean;
clientX: number;
clientY: number;
lastX: number;
lastY: number;
lastMoveClientX: number;
lastMoveClientY: number;
touchedTime: number;
lastTouchLength: number;
reachState: ReachTypeEnum;
};
private initialTouchState;
private readonly handlePhotoTap;
constructor(props: IPhotoViewProps);
componentDidMount(): void;
componentDidUpdate(prevProps: Readonly<IPhotoViewProps>): void;
componentWillUnmount(): void;
handleImageLoad: (imageParams: any) => void;
handleResize: () => void;
handleStart: (clientX: number, clientY: number, touchLength?: number) => void;
onMove: (newClientX: number, newClientY: number, touchLength?: number) => void;
onPhotoTap: (clientX: number, clientY: number) => void;
onDoubleTap: TapFuncType<number>;
handleWheel: (e: any) => void;
handleMaskStart: (clientX: number, clientY: number) => void;
handleMaskMouseDown: (e: any) => void;
handleMaskTouchStart: (e: any) => void;
handleTouchStart: (e: any) => void;
handleMouseDown: (e: any) => void;
handleTouchMove: (e: any) => void;
handleMouseMove: (e: any) => void;
handleUp: (newClientX: number, newClientY: number) => void;
handleTouchEnd: (e: any) => void;
handleMouseUp: (e: any) => void;
render(): JSX.Element;
}
export {};