Skip to content

Commit 918a18d

Browse files
maeda-mhidakatsuya
authored andcommitted
Fixed line rendering in list
1 parent 1269cad commit 918a18d

2 files changed

Lines changed: 51 additions & 17 deletions

File tree

src/app/core/line.js

Lines changed: 47 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -168,33 +168,49 @@ thin.core.Line.prototype.getCoordinate = function() {
168168
};
169169

170170

171+
/**
172+
* @param {number} left
173+
* @private
174+
*/
175+
thin.core.Line.prototype.setLeft_ = function(left) {
176+
this.left_ = thin.numberWithPrecision(left - this.getParentTransLateX());
177+
};
178+
179+
171180
/**
172181
* @param {number} left
173182
*/
174183
thin.core.Line.prototype.setLeft = function(left) {
175-
left = thin.numberWithPrecision(left - this.getParentTransLateX());
176-
this.left_ = left;
177-
this.setX1(left);
178-
this.setX2(left + this.getWidth());
184+
this.setLeft_(left);
185+
this.setX1(this.left_);
186+
this.setX2(this.left_ + this.getWidth());
187+
};
188+
189+
190+
/**
191+
* @param {number} top
192+
* @private
193+
*/
194+
thin.core.Line.prototype.setTop_ = function(top) {
195+
this.top_ = thin.numberWithPrecision(top - this.getParentTransLateY());
179196
};
180197

181198

182199
/**
183200
* @param {number} top
184201
*/
185202
thin.core.Line.prototype.setTop = function(top) {
186-
top = thin.numberWithPrecision(top - this.getParentTransLateY());
187-
this.top_ = top;
203+
this.setTop_(top);
188204

189205
var directionType = thin.core.Line.DIRECTION_;
190206
var direction = this.getDirection();
191207

192208
if (direction == directionType.Y1) {
193-
var y1 = top;
194-
var y2 = top + this.getHeight();
209+
var y1 = this.top_;
210+
var y2 = this.top_ + this.getHeight();
195211
} else if (direction == directionType.Y2) {
196-
var y1 = top + this.getHeight();
197-
var y2 = top;
212+
var y1 = this.top_ + this.getHeight();
213+
var y2 = this.top_;
198214
}
199215
this.setY1(y1);
200216
this.setY2(y2);
@@ -203,19 +219,37 @@ thin.core.Line.prototype.setTop = function(top) {
203219

204220
/**
205221
* @param {number} width
222+
* @private
206223
*/
207-
thin.core.Line.prototype.setWidth = function(width) {
224+
thin.core.Line.prototype.setWidth_ = function(width) {
208225
width = thin.numberWithPrecision(width);
209226
this.width_ = width;
210-
this.setX2(this.getLeft() + width);
227+
};
228+
229+
230+
/**
231+
* @param {number} width
232+
*/
233+
thin.core.Line.prototype.setWidth = function(width) {
234+
this.setWidth_(width);
235+
this.setX2(this.getLeft() + this.width_);
236+
};
237+
238+
239+
/**
240+
* @param {number} height
241+
* @private
242+
*/
243+
thin.core.Line.prototype.setHeight_ = function(height) {
244+
this.height_ = thin.numberWithPrecision(height);
211245
};
212246

213247

214248
/**
215249
* @param {number} height
216250
*/
217251
thin.core.Line.prototype.setHeight = function(height) {
218-
this.height_ = thin.numberWithPrecision(height);
252+
this.setHeight_(height);
219253
this.setTop(this.getTop());
220254
};
221255

src/app/core/lineshape.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -379,10 +379,10 @@ thin.core.LineShape.prototype.update = function(attrs) {
379379

380380
this.calculateDirection(y1, y2);
381381

382-
this.setLeft(Math.min(x1, x2) + this.getParentTransLateX());
383-
this.setTop(Math.min(y1, y2) + this.getParentTransLateY());
384-
this.setWidth(Math.abs(x1 - x2));
385-
this.setHeight(Math.abs(y1 - y2));
382+
this.setLeft_(Math.min(x1, x2) + this.getParentTransLateX());
383+
this.setTop_(Math.min(y1, y2) + this.getParentTransLateY());
384+
this.setWidth_(Math.abs(x1 - x2));
385+
this.setHeight_(Math.abs(y1 - y2));
386386
}
387387

388388
};

0 commit comments

Comments
 (0)