Skip to content

Commit

Permalink
缩放跳动和文字行高
Browse files Browse the repository at this point in the history
  • Loading branch information
zhijun committed Oct 7, 2019
1 parent 4b787ed commit 18fc173
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
12 changes: 7 additions & 5 deletions src/App.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,9 +398,9 @@ class App extends React.Component {
let height = textBox.height / 1 + (textBox.lineHeight / 1 - 1) * textBox.fontSize + padding * 2;
left = css.left - padding + borderWidth;
top = css.top - padding + borderWidth;
/* textBox.set({
top: top + height / 2
}); */
textBox.set({
top: -((textBox.lineHeight / 1 - 1) * textBox.fontSize) / 2
});

let Rect = new fabric.Rect({
width: width + borderWidth,
Expand Down Expand Up @@ -810,8 +810,10 @@ class App extends React.Component {
let item2 = this.activeObject;
let width = `${(item2.width - item2.strokeWidth) * item2.scaleX}`;
let height = `${(item2.height - item2.strokeWidth) * item2.scaleY}`;
let left = `${(item2.left / item2.scaleY - (item2.width - item2.strokeWidth) / 2 - item2.strokeWidth).toFixed(2)}`;
let top = `${(item2.top / item2.scaleY - (item2.height - item2.strokeWidth) / 2 - item2.strokeWidth).toFixed(2)}`;
/* let left = `${(item2.left / item2.scaleY - (item2.width - item2.strokeWidth) / 2 - item2.strokeWidth).toFixed(2)}`;
let top = `${(item2.top / item2.scaleY - (item2.height - item2.strokeWidth) / 2 - item2.strokeWidth).toFixed(2)}`; */
let left = `${(item2.left - width / 2).toFixed(2)}`;
let top = `${(item2.top - height / 2).toFixed(2)}`;
//console.log('item2.strokeWidth', `${item2.shadow}`, item2.scaleY);
let css = {
width,
Expand Down
Loading

0 comments on commit 18fc173

Please sign in to comment.