Skip to content

Commit

Permalink
allow for 0 sized scrollWidth/scrollHeight - browser quirk?
Browse files Browse the repository at this point in the history
  • Loading branch information
ianharrigan committed Dec 14, 2023
1 parent a422c7c commit 4022575
Showing 1 changed file with 28 additions and 9 deletions.
37 changes: 28 additions & 9 deletions haxe/ui/backend/TextInputImpl.hx
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,20 @@ class TextInputImpl extends TextDisplayImpl {
_inputData.hscrollPos = element.scrollLeft;
_inputData.vscrollPos = element.scrollTop;

_inputData.hscrollMax = element.scrollWidth - _width;
_inputData.hscrollPageSize = (_width * _inputData.hscrollMax) / element.scrollWidth;

_inputData.vscrollMax = element.scrollHeight - _height;
_inputData.vscrollPageSize = (_height * _inputData.vscrollMax) / element.scrollHeight;
if (element.scrollWidth != 0) {
_inputData.hscrollMax = element.scrollWidth - _width;
_inputData.hscrollPageSize = (_width * _inputData.hscrollMax) / element.scrollWidth;
} else {
_inputData.hscrollMax = _textWidth - _width;
_inputData.hscrollPageSize = (_width * _inputData.hscrollMax) / _textWidth;
}
if (element.scrollHeight != 0) {
_inputData.vscrollMax = element.scrollHeight - _height;
_inputData.vscrollPageSize = (_height * _inputData.vscrollMax) / element.scrollHeight;
} else {
_inputData.vscrollMax = _textHeight - _height;
_inputData.vscrollPageSize = (_height * _inputData.vscrollMax) / _textHeight;
}

if (_inputData.onScrollCallback != null) {
_inputData.onScrollCallback();
Expand Down Expand Up @@ -139,11 +148,21 @@ class TextInputImpl extends TextDisplayImpl {
_textWidth = div.clientWidth;
_textHeight = div.clientHeight + 2;

_inputData.hscrollMax = element.scrollWidth - _width;
_inputData.hscrollPageSize = (_width * _inputData.hscrollMax) / element.scrollWidth;
if (element.scrollWidth != 0) {
_inputData.hscrollMax = element.scrollWidth - _width;
_inputData.hscrollPageSize = (_width * _inputData.hscrollMax) / element.scrollWidth;
} else {
_inputData.hscrollMax = _textWidth - _width;
_inputData.hscrollPageSize = (_width * _inputData.hscrollMax) / _textWidth;
}

_inputData.vscrollMax = element.scrollHeight - _height;
_inputData.vscrollPageSize = (_height * _inputData.vscrollMax) / element.scrollHeight;
if (element.scrollHeight != 0) {
_inputData.vscrollMax = element.scrollHeight - _height;
_inputData.vscrollPageSize = (_height * _inputData.vscrollMax) / element.scrollHeight;
} else {
_inputData.vscrollMax = _textHeight - _height;
_inputData.vscrollPageSize = (_height * _inputData.vscrollMax) / _textHeight;
}
}

private var _selectionStartIndex:Int = 0;
Expand Down

0 comments on commit 4022575

Please sign in to comment.