Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

Adds more information to onDoubleClick callback #126

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions src/image-zoom/image-zoom.component.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,17 +121,18 @@ export default class ImageViewer extends React.Component<Props, State> {
if (new Date().getTime() - this.lastClickTime < (this.props.doubleClickInterval || 0)) {
// 认为触发了双击
this.lastClickTime = 0;

// 因为可能触发放大,因此记录双击时的坐标位置
this.doubleClickX = evt.nativeEvent.changedTouches[0].pageX;
this.doubleClickY = evt.nativeEvent.changedTouches[0].pageY;

if (this.props.onDoubleClick) {
this.props.onDoubleClick();
this.props.onDoubleClick({ pageX: this.doubleClickX, pageY: this.doubleClickY });
}

// 取消长按
clearTimeout(this.longPressTimeout);

// 因为可能触发放大,因此记录双击时的坐标位置
this.doubleClickX = evt.nativeEvent.changedTouches[0].pageX;
this.doubleClickY = evt.nativeEvent.changedTouches[0].pageY;

// 缩放
this.isDoubleClick = true;

Expand Down
7 changes: 6 additions & 1 deletion src/image-zoom/image-zoom.type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export interface IOnClick {
pageY: number
}

export interface IOnDoubleClick {
pageX: number,
pageY: number
}

export class Props {
/**
* 操作区域宽度
Expand Down Expand Up @@ -121,7 +126,7 @@ export class Props {
/**
* 双击的回调
*/
public onDoubleClick?: () => void = () => {
public onDoubleClick?: (eventParams: IOnDoubleClick) => void = () => {
//
};

Expand Down