-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: 支持图片旋转 #1
base: master
Are you sure you want to change the base?
feat: 支持图片旋转 #1
Conversation
x = 0, | ||
y = 0, | ||
zoom = 1, | ||
rotate = 0, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
增加的参数,控制旋转。本函数用来生成 transform css。
f0985f2
to
25d4f5f
Compare
const isRotateRight270 = direction === 'right' && rotate === 270; | ||
const isRotateLeft0 = direction === 'left' && rotate === 0; | ||
|
||
if (isRotateRight270 || isRotateLeft0) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
避免出现旋转 270/360 度的动画
degree = 360 - (-degree % 360); | ||
} | ||
|
||
if (this.props.animationDisabled) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
现有代码其他地方就是这么做的,保持一致。
做的事是这样:
- 开启动画(css 加上 transition)
- 等动画播完后,关闭动画
- 再让按钮重获 focus,以响应键盘事件
- ESC、左右方向键
this.setTimeout(() => this.requestMove(direction, event)); | ||
return; | ||
} | ||
// Reset the zoom level & rotation on image move |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
避免切换图片时发生 270 度旋转动画
let transitionStyle = {}; | ||
let transitionStyle = { | ||
transition: 'transform 0s', | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
在 chromium 中,如果 transition 属性本来为空,临时加上的话,不会播放旋转动画。所以放入一个 placeholder。
- added 2 buttons with icons ( rotate left & rotate right) fix: 避免 0 --> 270 度旋转动画的产生 feat: demo 打印旋转后的角度 fix: typo & bind this & focus on button & aria label fix: typo & bind this & focus on button & aria label
25d4f5f
to
142f37b
Compare
13872a8
to
af93468
Compare
rotate
控制图片旋转 cssenableRotate
,默认为true
onImageRotate
图片旋转后,会将顺时针旋转角度作为参数执行回调0
、90
、180
、270
核心改动看下面链接那个 PR 就行,这边多出来的改动都是因为加上了旋转动画(因为实际体验发现没有旋转动画有时候看到突然的图片方向变动有些错愕,一下子识别不出来图片的朝向)
https://github.com/frontend-collective/react-image-lightbox/pull/438/files