Skip to content

Commit

Permalink
color-picker: 一些情况下取色光标定位不准问题修复
Browse files Browse the repository at this point in the history
  • Loading branch information
cnwhy committed Aug 15, 2018
1 parent b70da53 commit 50d6ff1
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions packages/color-picker/src/components/sv-panel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,16 @@
const value = this.color.get('value');
const el = this.$el;
let { width, height } = el.getBoundingClientRect();
// let { width, height } = el.getBoundingClientRect();
if (!height) height = width * 3 / 4;
// if (!height) height = width * 3 / 4;
// 的宽高比应为 14/9 (280*180), 非 4/3
/*
此处无需使用 getBoundingClientRect ,
直接使用 clientWidth , clientHeight 更好, 且不受 CSS transform 影响, 动画期间也能正常获取
*/
let { clientWidth: width, clientHeight: height } = el;
this.cursorLeft = saturation * width / 100;
this.cursorTop = (100 - value) * height / 100;
Expand Down

0 comments on commit 50d6ff1

Please sign in to comment.