MCPcopy Create free account
hub / github.com/esengine/esengine / scrollToView

Method scrollToView

packages/fairygui/src/scroll/ScrollPane.ts:393–426  ·  view source on GitHub ↗

* Scroll to make child visible * 滚动使子对象可见

(target: GObject, bAnimate: boolean = false, bSetFirst: boolean = false)

Source from the content-addressed store, hash-verified

391 * 滚动使子对象可见
392 */
393 public scrollToView(target: GObject, bAnimate: boolean = false, bSetFirst: boolean = false): void {
394 const rect = {
395 x: target.x,
396 y: target.y,
397 width: target.width,
398 height: target.height
399 };
400
401 if (this._overlapHeight > 0) {
402 const bottom = this._scrollY + this._viewHeight;
403 if (bSetFirst || rect.y <= this._scrollY || rect.height >= this._viewHeight) {
404 this.setPosY(rect.y, bAnimate);
405 } else if (rect.y + rect.height > bottom) {
406 if (rect.height <= this._viewHeight / 2) {
407 this.setPosY(rect.y + rect.height * 2 - this._viewHeight, bAnimate);
408 } else {
409 this.setPosY(rect.y + rect.height - this._viewHeight, bAnimate);
410 }
411 }
412 }
413
414 if (this._overlapWidth > 0) {
415 const right = this._scrollX + this._viewWidth;
416 if (bSetFirst || rect.x <= this._scrollX || rect.width >= this._viewWidth) {
417 this.setPosX(rect.x, bAnimate);
418 } else if (rect.x + rect.width > right) {
419 if (rect.width <= this._viewWidth / 2) {
420 this.setPosX(rect.x + rect.width * 2 - this._viewWidth, bAnimate);
421 } else {
422 this.setPosX(rect.x + rect.width - this._viewWidth, bAnimate);
423 }
424 }
425 }
426 }
427
428 /**
429 * Check if child is in view

Callers

nothing calls this directly

Calls 2

setPosYMethod · 0.95
setPosXMethod · 0.95

Tested by

no test coverage detected