@opentui/core 0.1.37 → 0.1.39

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -136,7 +136,7 @@ import {
136
136
  white,
137
137
  wrapWithDelegates,
138
138
  yellow
139
- } from "./index-7bav3fax.js";
139
+ } from "./index-d4f5t33k.js";
140
140
  // src/text-buffer-view.ts
141
141
  class TextBufferView {
142
142
  lib;
@@ -4111,7 +4111,10 @@ class ScrollBoxRenderable extends BoxRenderable {
4111
4111
  set scrollTop(value) {
4112
4112
  this.verticalScrollBar.scrollPosition = value;
4113
4113
  if (!this._isApplyingStickyScroll) {
4114
- this._hasManualScroll = true;
4114
+ const maxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
4115
+ if (!this.isAtStickyPosition() && maxScrollTop > 1) {
4116
+ this._hasManualScroll = true;
4117
+ }
4115
4118
  }
4116
4119
  this.updateStickyState();
4117
4120
  }
@@ -4121,7 +4124,10 @@ class ScrollBoxRenderable extends BoxRenderable {
4121
4124
  set scrollLeft(value) {
4122
4125
  this.horizontalScrollBar.scrollPosition = value;
4123
4126
  if (!this._isApplyingStickyScroll) {
4124
- this._hasManualScroll = true;
4127
+ const maxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
4128
+ if (!this.isAtStickyPosition() && maxScrollLeft > 1) {
4129
+ this._hasManualScroll = true;
4130
+ }
4125
4131
  }
4126
4132
  this.updateStickyState();
4127
4133
  }
@@ -4136,9 +4142,6 @@ class ScrollBoxRenderable extends BoxRenderable {
4136
4142
  return;
4137
4143
  const maxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
4138
4144
  const maxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
4139
- if (this._hasManualScroll && this._stickyStart) {
4140
- return;
4141
- }
4142
4145
  if (this.scrollTop <= 0) {
4143
4146
  this._stickyScrollTop = true;
4144
4147
  this._stickyScrollBottom = false;
@@ -4259,7 +4262,10 @@ class ScrollBoxRenderable extends BoxRenderable {
4259
4262
  onChange: (position) => {
4260
4263
  this.content.translateY = -position;
4261
4264
  if (!this._isApplyingStickyScroll) {
4262
- this._hasManualScroll = true;
4265
+ const maxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
4266
+ if (!this.isAtStickyPosition() && maxScrollTop > 1) {
4267
+ this._hasManualScroll = true;
4268
+ }
4263
4269
  }
4264
4270
  this.updateStickyState();
4265
4271
  }
@@ -4277,7 +4283,10 @@ class ScrollBoxRenderable extends BoxRenderable {
4277
4283
  onChange: (position) => {
4278
4284
  this.content.translateX = -position;
4279
4285
  if (!this._isApplyingStickyScroll) {
4280
- this._hasManualScroll = true;
4286
+ const maxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
4287
+ if (!this.isAtStickyPosition() && maxScrollLeft > 1) {
4288
+ this._hasManualScroll = true;
4289
+ }
4281
4290
  }
4282
4291
  this.updateStickyState();
4283
4292
  }
@@ -4305,7 +4314,6 @@ class ScrollBoxRenderable extends BoxRenderable {
4305
4314
  this.verticalScrollBar.scrollBy(delta.y, unit);
4306
4315
  this.horizontalScrollBar.scrollBy(delta.x, unit);
4307
4316
  }
4308
- this._hasManualScroll = true;
4309
4317
  }
4310
4318
  scrollTo(position) {
4311
4319
  if (typeof position === "number") {
@@ -4315,6 +4323,25 @@ class ScrollBoxRenderable extends BoxRenderable {
4315
4323
  this.scrollLeft = position.x;
4316
4324
  }
4317
4325
  }
4326
+ isAtStickyPosition() {
4327
+ if (!this._stickyScroll || !this._stickyStart) {
4328
+ return false;
4329
+ }
4330
+ const maxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
4331
+ const maxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
4332
+ switch (this._stickyStart) {
4333
+ case "top":
4334
+ return this.scrollTop === 0;
4335
+ case "bottom":
4336
+ return this.scrollTop >= maxScrollTop;
4337
+ case "left":
4338
+ return this.scrollLeft === 0;
4339
+ case "right":
4340
+ return this.scrollLeft >= maxScrollLeft;
4341
+ default:
4342
+ return false;
4343
+ }
4344
+ }
4318
4345
  add(obj, index) {
4319
4346
  return this.content.add(obj, index);
4320
4347
  }
@@ -4344,7 +4371,11 @@ class ScrollBoxRenderable extends BoxRenderable {
4344
4371
  } else if (dir === "right") {
4345
4372
  this.scrollLeft += baseDelta * multiplier;
4346
4373
  }
4347
- this._hasManualScroll = true;
4374
+ const maxScrollTop = Math.max(0, this.scrollHeight - this.viewport.height);
4375
+ const maxScrollLeft = Math.max(0, this.scrollWidth - this.viewport.width);
4376
+ if (maxScrollTop > 1 || maxScrollLeft > 1) {
4377
+ this._hasManualScroll = true;
4378
+ }
4348
4379
  }
4349
4380
  if (event.type === "drag" && event.isSelecting) {
4350
4381
  this.updateAutoScroll(event.x, event.y);
@@ -6362,5 +6393,5 @@ export {
6362
6393
  ASCIIFont
6363
6394
  };
6364
6395
 
6365
- //# debugId=1E654B6F0692B62564756E2164756E21
6396
+ //# debugId=5DEE20591CE7786764756E2164756E21
6366
6397
  //# sourceMappingURL=index.js.map