react-photo-view
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -1,2 +0,2 @@ | ||
declare const _default: import("../../node_modules/styled-components").StyledComponentClass<{ | ||
declare const _default: import("../../../../../../../Users/liumy/Documents/workspace/react-photo-view/node_modules/styled-components").StyledComponentClass<{ | ||
className?: string | undefined; | ||
@@ -3,0 +3,0 @@ }, any, Pick<{ |
import React from 'react'; | ||
import { dataType } from './types'; | ||
import { dataType, TouchTypeEnum } from './types'; | ||
interface IPhotoSliderProps { | ||
@@ -7,4 +7,5 @@ images: (string | dataType)[]; | ||
visible: boolean; | ||
onClose: Function; | ||
onClose: (evt?: React.MouseEvent) => void; | ||
onIndexChange?: Function; | ||
maskClosable?: boolean; | ||
overlay?: React.ReactNode; | ||
@@ -39,5 +40,5 @@ className?: string; | ||
handleReachHorizontalMove: (clientX: any) => void; | ||
handleReachUp: (clientX: any, clientY: any) => void; | ||
handleReachUp: (clientX: number, clientY: number, touchType: TouchTypeEnum) => void; | ||
render(): JSX.Element | null; | ||
} | ||
export {}; |
@@ -9,3 +9,5 @@ import _classCallCheck from 'babel-runtime/helpers/classCallCheck'; | ||
import Backdrop from './components/Backdrop'; | ||
import { maxMoveOffset, defaultOpacity, horizontalOffset } from './variables'; | ||
import { Close, Counter, TopBar } from './components/TopWrap'; | ||
import { TouchTypeEnum } from './types'; | ||
import { defaultOpacity, horizontalOffset, maxMoveOffset } from './variables'; | ||
@@ -80,3 +82,3 @@ var PhotoSlider = function (_React$Component) { | ||
}; | ||
_this.handleReachUp = function (clientX, clientY) { | ||
_this.handleReachUp = function (clientX, clientY, touchType) { | ||
var _window3 = window, | ||
@@ -88,3 +90,5 @@ innerWidth = _window3.innerWidth, | ||
onIndexChange = _this$props.onIndexChange, | ||
onClose = _this$props.onClose; | ||
onClose = _this$props.onClose, | ||
_this$props$maskClosa = _this$props.maskClosable, | ||
maskClosable = _this$props$maskClosa === undefined ? true : _this$props$maskClosa; | ||
var _this$state = _this.state, | ||
@@ -103,4 +107,7 @@ _this$state$lastClien = _this$state.lastClientX, | ||
var currentPhotoIndex = photoIndex; | ||
if (Math.abs(offsetClientY) > innerHeight * 0.14) { | ||
// mask 点击事件 | ||
if (lastClientX === clientX && lastClientY === clientY && maskClosable && touchType === TouchTypeEnum.Mask) { | ||
onClose(); | ||
} else if (Math.abs(offsetClientY) > innerHeight * 0.14) { | ||
onClose(); | ||
// 下一张 | ||
@@ -173,2 +180,3 @@ } else if (offsetClientX < -maxMoveOffset && photoIndex < images.length - 1) { | ||
imageClassName = _props.imageClassName, | ||
onClose = _props.onClose, | ||
loadingElement = _props.loadingElement, | ||
@@ -193,2 +201,14 @@ brokenElement = _props.brokenElement; | ||
React.createElement(Backdrop, { className: maskClassName, style: { background: 'rgba(0, 0, 0, ' + backdropOpacity + ')' } }), | ||
React.createElement( | ||
TopBar, | ||
null, | ||
React.createElement( | ||
Counter, | ||
null, | ||
photoIndex + 1, | ||
' / ', | ||
imageLength | ||
), | ||
React.createElement(Close, { onClick: onClose }) | ||
), | ||
images.slice( // 加载相邻三张 | ||
@@ -195,0 +215,0 @@ Math.max(photoIndex - 1, 0), Math.min(photoIndex + 2, imageLength + 1)).map(function (item, index) { |
import React from 'react'; | ||
declare type ReachFunction = (clientX: number, clientY: number) => void; | ||
import { ReachFunction, ReachTypeEnum } from './types'; | ||
interface IPhotoViewProps { | ||
@@ -15,3 +15,3 @@ src: string; | ||
onReachLeftMove?: ReachFunction; | ||
onReachUp?: ReachFunction; | ||
onReachUp?: (clientX: number, clientY: number, TouchTypeEnum: any) => void; | ||
onPhotoResize?: () => void; | ||
@@ -31,3 +31,3 @@ } | ||
lastTouchLength: number; | ||
reachState: number; | ||
reachState: ReachTypeEnum; | ||
}; | ||
@@ -48,3 +48,3 @@ export default class PhotoView extends React.Component<IPhotoViewProps, typeof initialState> { | ||
lastTouchLength: number; | ||
reachState: number; | ||
reachState: ReachTypeEnum; | ||
}; | ||
@@ -70,3 +70,3 @@ private photoRef; | ||
handleResize: () => void; | ||
handleReachCallback: (x: number, y: number, scale: number, newClientX: number, newClientY: number, reachState: number) => number; | ||
handleReachCallback: (x: number, y: number, scale: number, newClientX: number, newClientY: number, reachState: ReachTypeEnum) => number; | ||
handlePhotoRef: (ref: any) => void; | ||
@@ -73,0 +73,0 @@ render(): JSX.Element; |
@@ -16,3 +16,4 @@ import _extends from 'babel-runtime/helpers/extends'; | ||
import { getClosedHorizontal, getClosedVertical } from './utils/getCloseEdge'; | ||
import { minReachOffset, minScale, maxScale, scaleBuffer } from './variables'; | ||
import { maxScale, minReachOffset, minScale, scaleBuffer } from './variables'; | ||
import { ReachTypeEnum, TouchTypeEnum } from './types'; | ||
var initialState = { | ||
@@ -41,4 +42,4 @@ // 图片 X 偏移量 | ||
lastTouchLength: 0, | ||
// 当前边缘触发状态,0: 未触发,1: x 轴,2: y 轴 | ||
reachState: 0 | ||
// 当前边缘触发状态 | ||
reachState: ReachTypeEnum.Normal | ||
}; | ||
@@ -94,3 +95,3 @@ | ||
// 边缘状态 | ||
var currentReachState = 0; | ||
var currentReachState = ReachTypeEnum.Normal; | ||
if (touchLength === 0) { | ||
@@ -103,5 +104,5 @@ currentX = newClientX - clientX + lastX; | ||
// 横向边缘触发、背景触发禁用当前滑动 | ||
if (currentReachState === 1 || maskTouched) { | ||
if (currentReachState === ReachTypeEnum.XReach || maskTouched) { | ||
_this.setState({ | ||
reachState: 1 | ||
reachState: ReachTypeEnum.XReach | ||
}); | ||
@@ -263,3 +264,3 @@ } else { | ||
if (onReachUp) { | ||
onReachUp(newClientX, newClientY); | ||
onReachUp(newClientX, newClientY, maskTouched ? TouchTypeEnum.Mask : TouchTypeEnum.Image); | ||
} | ||
@@ -269,3 +270,3 @@ var hasMove = clientX !== newClientX || clientY !== newClientY; | ||
var toScale = Math.max(Math.min(scale, Math.max(maxScale, naturalWidth / width)), minScale); | ||
return _extends({ touched: false, maskTouched: false, scale: toScale, reachState: 0 }, hasMove ? slideToSuitableOffset({ | ||
return _extends({ touched: false, maskTouched: false, scale: toScale, reachState: ReachTypeEnum.Normal }, hasMove ? slideToSuitableOffset({ | ||
x: x, | ||
@@ -321,16 +322,16 @@ y: y, | ||
if (onReachLeftMove && (horizontalType && x > minReachOffset && reachState === 0 || reachState === 1)) { | ||
if (onReachLeftMove && (horizontalType && x > minReachOffset && reachState === ReachTypeEnum.Normal || reachState === ReachTypeEnum.XReach)) { | ||
onReachLeftMove(newClientX, newClientY); | ||
return 1; | ||
} else if (onReachRightMove && (horizontalType && x < -minReachOffset && reachState === 0 || reachState === 1)) { | ||
return ReachTypeEnum.XReach; | ||
} else if (onReachRightMove && (horizontalType && x < -minReachOffset && reachState === ReachTypeEnum.Normal || reachState === ReachTypeEnum.XReach)) { | ||
onReachRightMove(newClientX, newClientY); | ||
return 1; | ||
} else if (onReachTopMove && (verticalType && y > minReachOffset && reachState === 0 || reachState === 2)) { | ||
return ReachTypeEnum.XReach; | ||
} else if (onReachTopMove && (verticalType && y > minReachOffset && reachState === ReachTypeEnum.Normal || reachState === ReachTypeEnum.YReach)) { | ||
onReachTopMove(newClientX, newClientY); | ||
return 2; | ||
} else if (onReachBottomMove && (verticalType && y < -minReachOffset && reachState === 0 || reachState === 2)) { | ||
return ReachTypeEnum.YReach; | ||
} else if (onReachBottomMove && (verticalType && y < -minReachOffset && reachState === ReachTypeEnum.Normal || reachState === ReachTypeEnum.YReach)) { | ||
onReachBottomMove(newClientX, newClientY); | ||
return 2; | ||
return ReachTypeEnum.YReach; | ||
} | ||
return 0; | ||
return ReachTypeEnum.Normal; | ||
}; | ||
@@ -337,0 +338,0 @@ _this.handlePhotoRef = function (ref) { |
@@ -8,1 +8,26 @@ /** | ||
}; | ||
export declare type ReachFunction = (clientX: number, clientY: number) => void; | ||
/** | ||
* 边缘超出状态 | ||
*/ | ||
export declare enum CloseEdgeEnum { | ||
Normal = 0, | ||
Small = 1, | ||
Before = 2, | ||
After = 3 | ||
} | ||
/** | ||
* 边缘触发状态 | ||
*/ | ||
export declare enum ReachTypeEnum { | ||
Normal = 0, | ||
XReach = 1, | ||
YReach = 2 | ||
} | ||
/** | ||
* 触摸类型 | ||
*/ | ||
export declare enum TouchTypeEnum { | ||
Image = 1, | ||
Mask = 2 | ||
} |
@@ -0,1 +1,2 @@ | ||
import { CloseEdgeEnum } from '../types'; | ||
/** | ||
@@ -8,3 +9,3 @@ * 接触左边或右边边缘 | ||
*/ | ||
export declare const getClosedHorizontal: (x: number, scale: number, width: number) => number; | ||
export declare const getClosedHorizontal: (x: number, scale: number, width: number) => CloseEdgeEnum; | ||
/** | ||
@@ -17,2 +18,2 @@ * 接触上边或下边边缘 | ||
*/ | ||
export declare const getClosedVertical: (y: number, scale: number, height: number) => number; | ||
export declare const getClosedVertical: (y: number, scale: number, height: number) => CloseEdgeEnum; |
@@ -0,1 +1,2 @@ | ||
import { CloseEdgeEnum } from '../types'; | ||
/** | ||
@@ -16,9 +17,9 @@ * 接触左边或右边边缘 | ||
if (currentWidth <= innerWidth) { | ||
return 1; | ||
return CloseEdgeEnum.Small; | ||
} else if (x > 0 && outOffsetX - x <= 0) { | ||
return 2; | ||
return CloseEdgeEnum.Before; | ||
} else if (x < 0 && outOffsetX + x <= 0) { | ||
return 3; | ||
return CloseEdgeEnum.After; | ||
} | ||
return 0; | ||
return CloseEdgeEnum.Normal; | ||
}; | ||
@@ -40,9 +41,9 @@ /** | ||
if (currentHeight <= innerHeight) { | ||
return 1; | ||
return CloseEdgeEnum.Small; | ||
} else if (y > 0 && outOffsetY - y <= 0) { | ||
return 2; | ||
return CloseEdgeEnum.Before; | ||
} else if (y < 0 && outOffsetY + y <= 0) { | ||
return 3; | ||
return CloseEdgeEnum.After; | ||
} | ||
return 0; | ||
return CloseEdgeEnum.Normal; | ||
}; |
import slideToPosition from './slideToPosition'; | ||
import { getClosedHorizontal, getClosedVertical } from './getCloseEdge'; | ||
import { CloseEdgeEnum } from '../types'; | ||
/** | ||
@@ -39,15 +40,15 @@ * 适应到合适的图片偏移量 | ||
// x | ||
if (horizontalType === 1) { | ||
if (horizontalType === CloseEdgeEnum.Small) { | ||
currentX = 0; | ||
} else if (horizontalType === 2) { | ||
} else if (horizontalType === CloseEdgeEnum.Before) { | ||
currentX = outOffsetX; | ||
} else if (horizontalType === 3) { | ||
} else if (horizontalType === CloseEdgeEnum.After) { | ||
currentX = -outOffsetX; | ||
} | ||
// y | ||
if (verticalType === 1) { | ||
if (verticalType === CloseEdgeEnum.Small) { | ||
currentY = 0; | ||
} else if (verticalType === 2) { | ||
} else if (verticalType === CloseEdgeEnum.Before) { | ||
currentY = outOffsetY; | ||
} else if (verticalType === 3) { | ||
} else if (verticalType === CloseEdgeEnum.After) { | ||
currentY = -outOffsetY; | ||
@@ -54,0 +55,0 @@ } |
@@ -20,3 +20,3 @@ /** | ||
*/ | ||
export var defaultOpacity = 0.8; | ||
export var defaultOpacity = 1; | ||
/** | ||
@@ -23,0 +23,0 @@ * 最小缩放度 |
@@ -1,2 +0,2 @@ | ||
declare const _default: import("../../node_modules/styled-components").StyledComponentClass<{ | ||
declare const _default: import("../../../../../../../Users/liumy/Documents/workspace/react-photo-view/node_modules/styled-components").StyledComponentClass<{ | ||
className?: string | undefined; | ||
@@ -3,0 +3,0 @@ }, any, Pick<{ |
import React from 'react'; | ||
import { dataType } from './types'; | ||
import { dataType, TouchTypeEnum } from './types'; | ||
interface IPhotoSliderProps { | ||
@@ -7,4 +7,5 @@ images: (string | dataType)[]; | ||
visible: boolean; | ||
onClose: Function; | ||
onClose: (evt?: React.MouseEvent) => void; | ||
onIndexChange?: Function; | ||
maskClosable?: boolean; | ||
overlay?: React.ReactNode; | ||
@@ -39,5 +40,5 @@ className?: string; | ||
handleReachHorizontalMove: (clientX: any) => void; | ||
handleReachUp: (clientX: any, clientY: any) => void; | ||
handleReachUp: (clientX: number, clientY: number, touchType: TouchTypeEnum) => void; | ||
render(): JSX.Element | null; | ||
} | ||
export {}; |
@@ -39,2 +39,6 @@ 'use strict'; | ||
var _TopWrap = require('./components/TopWrap'); | ||
var _types = require('./types'); | ||
var _variables = require('./variables'); | ||
@@ -112,3 +116,3 @@ | ||
}; | ||
_this.handleReachUp = function (clientX, clientY) { | ||
_this.handleReachUp = function (clientX, clientY, touchType) { | ||
var _window3 = window, | ||
@@ -120,3 +124,5 @@ innerWidth = _window3.innerWidth, | ||
onIndexChange = _this$props.onIndexChange, | ||
onClose = _this$props.onClose; | ||
onClose = _this$props.onClose, | ||
_this$props$maskClosa = _this$props.maskClosable, | ||
maskClosable = _this$props$maskClosa === undefined ? true : _this$props$maskClosa; | ||
var _this$state = _this.state, | ||
@@ -135,4 +141,7 @@ _this$state$lastClien = _this$state.lastClientX, | ||
var currentPhotoIndex = photoIndex; | ||
if (Math.abs(offsetClientY) > innerHeight * 0.14) { | ||
// mask 点击事件 | ||
if (lastClientX === clientX && lastClientY === clientY && maskClosable && touchType === _types.TouchTypeEnum.Mask) { | ||
onClose(); | ||
} else if (Math.abs(offsetClientY) > innerHeight * 0.14) { | ||
onClose(); | ||
// 下一张 | ||
@@ -205,2 +214,3 @@ } else if (offsetClientX < -_variables.maxMoveOffset && photoIndex < images.length - 1) { | ||
imageClassName = _props.imageClassName, | ||
onClose = _props.onClose, | ||
loadingElement = _props.loadingElement, | ||
@@ -225,2 +235,14 @@ brokenElement = _props.brokenElement; | ||
_react2['default'].createElement(_Backdrop2['default'], { className: maskClassName, style: { background: 'rgba(0, 0, 0, ' + backdropOpacity + ')' } }), | ||
_react2['default'].createElement( | ||
_TopWrap.TopBar, | ||
null, | ||
_react2['default'].createElement( | ||
_TopWrap.Counter, | ||
null, | ||
photoIndex + 1, | ||
' / ', | ||
imageLength | ||
), | ||
_react2['default'].createElement(_TopWrap.Close, { onClick: onClose }) | ||
), | ||
images.slice( // 加载相邻三张 | ||
@@ -227,0 +249,0 @@ Math.max(photoIndex - 1, 0), Math.min(photoIndex + 2, imageLength + 1)).map(function (item, index) { |
import React from 'react'; | ||
declare type ReachFunction = (clientX: number, clientY: number) => void; | ||
import { ReachFunction, ReachTypeEnum } from './types'; | ||
interface IPhotoViewProps { | ||
@@ -15,3 +15,3 @@ src: string; | ||
onReachLeftMove?: ReachFunction; | ||
onReachUp?: ReachFunction; | ||
onReachUp?: (clientX: number, clientY: number, TouchTypeEnum: any) => void; | ||
onPhotoResize?: () => void; | ||
@@ -31,3 +31,3 @@ } | ||
lastTouchLength: number; | ||
reachState: number; | ||
reachState: ReachTypeEnum; | ||
}; | ||
@@ -48,3 +48,3 @@ export default class PhotoView extends React.Component<IPhotoViewProps, typeof initialState> { | ||
lastTouchLength: number; | ||
reachState: number; | ||
reachState: ReachTypeEnum; | ||
}; | ||
@@ -70,3 +70,3 @@ private photoRef; | ||
handleResize: () => void; | ||
handleReachCallback: (x: number, y: number, scale: number, newClientX: number, newClientY: number, reachState: number) => number; | ||
handleReachCallback: (x: number, y: number, scale: number, newClientX: number, newClientY: number, reachState: ReachTypeEnum) => number; | ||
handlePhotoRef: (ref: any) => void; | ||
@@ -73,0 +73,0 @@ render(): JSX.Element; |
@@ -67,2 +67,4 @@ 'use strict'; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
@@ -93,4 +95,4 @@ | ||
lastTouchLength: 0, | ||
// 当前边缘触发状态,0: 未触发,1: x 轴,2: y 轴 | ||
reachState: 0 | ||
// 当前边缘触发状态 | ||
reachState: _types.ReachTypeEnum.Normal | ||
}; | ||
@@ -146,3 +148,3 @@ | ||
// 边缘状态 | ||
var currentReachState = 0; | ||
var currentReachState = _types.ReachTypeEnum.Normal; | ||
if (touchLength === 0) { | ||
@@ -155,5 +157,5 @@ currentX = newClientX - clientX + lastX; | ||
// 横向边缘触发、背景触发禁用当前滑动 | ||
if (currentReachState === 1 || maskTouched) { | ||
if (currentReachState === _types.ReachTypeEnum.XReach || maskTouched) { | ||
_this.setState({ | ||
reachState: 1 | ||
reachState: _types.ReachTypeEnum.XReach | ||
}); | ||
@@ -315,3 +317,3 @@ } else { | ||
if (onReachUp) { | ||
onReachUp(newClientX, newClientY); | ||
onReachUp(newClientX, newClientY, maskTouched ? _types.TouchTypeEnum.Mask : _types.TouchTypeEnum.Image); | ||
} | ||
@@ -321,3 +323,3 @@ var hasMove = clientX !== newClientX || clientY !== newClientY; | ||
var toScale = Math.max(Math.min(scale, Math.max(_variables.maxScale, naturalWidth / width)), _variables.minScale); | ||
return (0, _extends3['default'])({ touched: false, maskTouched: false, scale: toScale, reachState: 0 }, hasMove ? (0, _slideToSuitableOffset2['default'])({ | ||
return (0, _extends3['default'])({ touched: false, maskTouched: false, scale: toScale, reachState: _types.ReachTypeEnum.Normal }, hasMove ? (0, _slideToSuitableOffset2['default'])({ | ||
x: x, | ||
@@ -373,16 +375,16 @@ y: y, | ||
if (onReachLeftMove && (horizontalType && x > _variables.minReachOffset && reachState === 0 || reachState === 1)) { | ||
if (onReachLeftMove && (horizontalType && x > _variables.minReachOffset && reachState === _types.ReachTypeEnum.Normal || reachState === _types.ReachTypeEnum.XReach)) { | ||
onReachLeftMove(newClientX, newClientY); | ||
return 1; | ||
} else if (onReachRightMove && (horizontalType && x < -_variables.minReachOffset && reachState === 0 || reachState === 1)) { | ||
return _types.ReachTypeEnum.XReach; | ||
} else if (onReachRightMove && (horizontalType && x < -_variables.minReachOffset && reachState === _types.ReachTypeEnum.Normal || reachState === _types.ReachTypeEnum.XReach)) { | ||
onReachRightMove(newClientX, newClientY); | ||
return 1; | ||
} else if (onReachTopMove && (verticalType && y > _variables.minReachOffset && reachState === 0 || reachState === 2)) { | ||
return _types.ReachTypeEnum.XReach; | ||
} else if (onReachTopMove && (verticalType && y > _variables.minReachOffset && reachState === _types.ReachTypeEnum.Normal || reachState === _types.ReachTypeEnum.YReach)) { | ||
onReachTopMove(newClientX, newClientY); | ||
return 2; | ||
} else if (onReachBottomMove && (verticalType && y < -_variables.minReachOffset && reachState === 0 || reachState === 2)) { | ||
return _types.ReachTypeEnum.YReach; | ||
} else if (onReachBottomMove && (verticalType && y < -_variables.minReachOffset && reachState === _types.ReachTypeEnum.Normal || reachState === _types.ReachTypeEnum.YReach)) { | ||
onReachBottomMove(newClientX, newClientY); | ||
return 2; | ||
return _types.ReachTypeEnum.YReach; | ||
} | ||
return 0; | ||
return _types.ReachTypeEnum.Normal; | ||
}; | ||
@@ -389,0 +391,0 @@ _this.handlePhotoRef = function (ref) { |
@@ -8,1 +8,26 @@ /** | ||
}; | ||
export declare type ReachFunction = (clientX: number, clientY: number) => void; | ||
/** | ||
* 边缘超出状态 | ||
*/ | ||
export declare enum CloseEdgeEnum { | ||
Normal = 0, | ||
Small = 1, | ||
Before = 2, | ||
After = 3 | ||
} | ||
/** | ||
* 边缘触发状态 | ||
*/ | ||
export declare enum ReachTypeEnum { | ||
Normal = 0, | ||
XReach = 1, | ||
YReach = 2 | ||
} | ||
/** | ||
* 触摸类型 | ||
*/ | ||
export declare enum TouchTypeEnum { | ||
Image = 1, | ||
Mask = 2 | ||
} |
@@ -1,1 +0,32 @@ | ||
"use strict"; | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
/** | ||
* 边缘超出状态 | ||
*/ | ||
var CloseEdgeEnum = exports.CloseEdgeEnum = undefined; | ||
(function (CloseEdgeEnum) { | ||
CloseEdgeEnum[CloseEdgeEnum["Normal"] = 0] = "Normal"; | ||
CloseEdgeEnum[CloseEdgeEnum["Small"] = 1] = "Small"; | ||
CloseEdgeEnum[CloseEdgeEnum["Before"] = 2] = "Before"; | ||
CloseEdgeEnum[CloseEdgeEnum["After"] = 3] = "After"; | ||
})(CloseEdgeEnum || (exports.CloseEdgeEnum = CloseEdgeEnum = {})); | ||
/** | ||
* 边缘触发状态 | ||
*/ | ||
var ReachTypeEnum = exports.ReachTypeEnum = undefined; | ||
(function (ReachTypeEnum) { | ||
ReachTypeEnum[ReachTypeEnum["Normal"] = 0] = "Normal"; | ||
ReachTypeEnum[ReachTypeEnum["XReach"] = 1] = "XReach"; | ||
ReachTypeEnum[ReachTypeEnum["YReach"] = 2] = "YReach"; | ||
})(ReachTypeEnum || (exports.ReachTypeEnum = ReachTypeEnum = {})); | ||
/** | ||
* 触摸类型 | ||
*/ | ||
var TouchTypeEnum = exports.TouchTypeEnum = undefined; | ||
(function (TouchTypeEnum) { | ||
TouchTypeEnum[TouchTypeEnum["Image"] = 1] = "Image"; | ||
TouchTypeEnum[TouchTypeEnum["Mask"] = 2] = "Mask"; | ||
})(TouchTypeEnum || (exports.TouchTypeEnum = TouchTypeEnum = {})); |
@@ -0,1 +1,2 @@ | ||
import { CloseEdgeEnum } from '../types'; | ||
/** | ||
@@ -8,3 +9,3 @@ * 接触左边或右边边缘 | ||
*/ | ||
export declare const getClosedHorizontal: (x: number, scale: number, width: number) => number; | ||
export declare const getClosedHorizontal: (x: number, scale: number, width: number) => CloseEdgeEnum; | ||
/** | ||
@@ -17,2 +18,2 @@ * 接触上边或下边边缘 | ||
*/ | ||
export declare const getClosedVertical: (y: number, scale: number, height: number) => number; | ||
export declare const getClosedVertical: (y: number, scale: number, height: number) => CloseEdgeEnum; |
@@ -1,2 +0,2 @@ | ||
"use strict"; | ||
'use strict'; | ||
@@ -6,2 +6,6 @@ Object.defineProperty(exports, "__esModule", { | ||
}); | ||
exports.getClosedVertical = exports.getClosedHorizontal = undefined; | ||
var _types = require('../types'); | ||
/** | ||
@@ -22,9 +26,9 @@ * 接触左边或右边边缘 | ||
if (currentWidth <= innerWidth) { | ||
return 1; | ||
return _types.CloseEdgeEnum.Small; | ||
} else if (x > 0 && outOffsetX - x <= 0) { | ||
return 2; | ||
return _types.CloseEdgeEnum.Before; | ||
} else if (x < 0 && outOffsetX + x <= 0) { | ||
return 3; | ||
return _types.CloseEdgeEnum.After; | ||
} | ||
return 0; | ||
return _types.CloseEdgeEnum.Normal; | ||
}; | ||
@@ -46,9 +50,9 @@ /** | ||
if (currentHeight <= innerHeight) { | ||
return 1; | ||
return _types.CloseEdgeEnum.Small; | ||
} else if (y > 0 && outOffsetY - y <= 0) { | ||
return 2; | ||
return _types.CloseEdgeEnum.Before; | ||
} else if (y < 0 && outOffsetY + y <= 0) { | ||
return 3; | ||
return _types.CloseEdgeEnum.After; | ||
} | ||
return 0; | ||
return _types.CloseEdgeEnum.Normal; | ||
}; |
@@ -13,2 +13,4 @@ 'use strict'; | ||
var _types = require('../types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
@@ -52,15 +54,15 @@ | ||
// x | ||
if (horizontalType === 1) { | ||
if (horizontalType === _types.CloseEdgeEnum.Small) { | ||
currentX = 0; | ||
} else if (horizontalType === 2) { | ||
} else if (horizontalType === _types.CloseEdgeEnum.Before) { | ||
currentX = outOffsetX; | ||
} else if (horizontalType === 3) { | ||
} else if (horizontalType === _types.CloseEdgeEnum.After) { | ||
currentX = -outOffsetX; | ||
} | ||
// y | ||
if (verticalType === 1) { | ||
if (verticalType === _types.CloseEdgeEnum.Small) { | ||
currentY = 0; | ||
} else if (verticalType === 2) { | ||
} else if (verticalType === _types.CloseEdgeEnum.Before) { | ||
currentY = outOffsetY; | ||
} else if (verticalType === 3) { | ||
} else if (verticalType === _types.CloseEdgeEnum.After) { | ||
currentY = -outOffsetY; | ||
@@ -67,0 +69,0 @@ } |
@@ -25,3 +25,3 @@ "use strict"; | ||
*/ | ||
var defaultOpacity = exports.defaultOpacity = 0.8; | ||
var defaultOpacity = exports.defaultOpacity = 1; | ||
/** | ||
@@ -28,0 +28,0 @@ * 最小缩放度 |
{ | ||
"name": "react-photo-view", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "React photo preview.", | ||
@@ -13,2 +13,7 @@ "main": "./lib/index", | ||
], | ||
"homepage": "https://github.com/MinJieLiu/react-photo-view", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/MinJieLiu/react-photo-view.git" | ||
}, | ||
"scripts": { | ||
@@ -15,0 +20,0 @@ "watch-tsc": "rc-tools run watch-tsc", |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
148016
85
3451
1
0