(layoutInfo: LayoutInfo, timelineModel: SliderTimelineModel)
| 264 | } |
| 265 | |
| 266 | private _position(layoutInfo: LayoutInfo, timelineModel: SliderTimelineModel) { |
| 267 | // Position is be called finally, because bounding rect is needed for |
| 268 | // adapt content to fill viewRect (auto adapt offset). |
| 269 | |
| 270 | // Timeline may be not all in the viewRect when 'offset' is specified |
| 271 | // as a number, because it is more appropriate that label aligns at |
| 272 | // 'offset' but not the other edge defined by viewRect. |
| 273 | |
| 274 | const mainGroup = this._mainGroup; |
| 275 | const labelGroup = this._labelGroup; |
| 276 | |
| 277 | let viewRect = layoutInfo.viewRect; |
| 278 | if (layoutInfo.orient === 'vertical') { |
| 279 | // transform to horizontal, inverse rotate by left-top point. |
| 280 | const m = matrix.create(); |
| 281 | const rotateOriginX = viewRect.x; |
| 282 | const rotateOriginY = viewRect.y + viewRect.height; |
| 283 | matrix.translate(m, m, [-rotateOriginX, -rotateOriginY]); |
| 284 | matrix.rotate(m, m, -PI / 2); |
| 285 | matrix.translate(m, m, [rotateOriginX, rotateOriginY]); |
| 286 | viewRect = viewRect.clone(); |
| 287 | viewRect.applyTransform(m); |
| 288 | } |
| 289 | |
| 290 | const viewBound = getBound(viewRect); |
| 291 | const mainBound = getBound(mainGroup.getBoundingRect()); |
| 292 | const labelBound = getBound(labelGroup.getBoundingRect()); |
| 293 | |
| 294 | const mainPosition = [mainGroup.x, mainGroup.y]; |
| 295 | const labelsPosition = [labelGroup.x, labelGroup.y]; |
| 296 | |
| 297 | labelsPosition[0] = mainPosition[0] = viewBound[0][0]; |
| 298 | |
| 299 | const labelPosOpt = layoutInfo.labelPosOpt; |
| 300 | |
| 301 | if (labelPosOpt == null || isString(labelPosOpt)) { // '+' or '-' |
| 302 | const mainBoundIdx = labelPosOpt === '+' ? 0 : 1; |
| 303 | toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx); |
| 304 | toBound(labelsPosition, labelBound, viewBound, 1, 1 - mainBoundIdx); |
| 305 | } |
| 306 | else { |
| 307 | const mainBoundIdx = labelPosOpt >= 0 ? 0 : 1; |
| 308 | toBound(mainPosition, mainBound, viewBound, 1, mainBoundIdx); |
| 309 | labelsPosition[1] = mainPosition[1] + labelPosOpt; |
| 310 | } |
| 311 | |
| 312 | mainGroup.setPosition(mainPosition); |
| 313 | labelGroup.setPosition(labelsPosition); |
| 314 | mainGroup.rotation = labelGroup.rotation = layoutInfo.rotation; |
| 315 | |
| 316 | setOrigin(mainGroup); |
| 317 | setOrigin(labelGroup); |
| 318 | |
| 319 | function setOrigin(targetGroup: graphic.Group) { |
| 320 | targetGroup.originX = viewBound[0][0] - targetGroup.x; |
| 321 | targetGroup.originY = viewBound[1][0] - targetGroup.y; |
| 322 | } |
| 323 |
no test coverage detected