Size: a a a

2021 January 03

MG

Matthew Good in pro.algorithms
Azure Mynn
You need multiplier = scrollBarPosition / (getHeight() - scrollThumbHeight);
hm ok
источник

AM

Azure Mynn in pro.algorithms
Matthew Good
it should be relativeOffset = absoluteOffset - absoluteOffsetLast; right?
No clue what this is about lol
источник

MG

Matthew Good in pro.algorithms
to convert absolute offset to relative offset per frame
источник

MG

Matthew Good in pro.algorithms
eg get the amount of pixels the bar has moved in comparison to the last absolute position
источник

AM

Azure Mynn in pro.algorithms
Matthew Good
it should be relativeOffset = absoluteOffset - absoluteOffsetLast; right?
Yes
источник

MG

Matthew Good in pro.algorithms
hmm it seems to be off
источник

MG

Matthew Good in pro.algorithms
when i scroll the scroll bar all the way to the bottom, my content does not get scrolled all the way to the bottom
источник

MG

Matthew Good in pro.algorithms
and it seems to scroll by a less amount depending on how fast i move the scroll bar
источник

AM

Azure Mynn in pro.algorithms
That has something to do with the relative scrolling thingy, is there really not an API to just specify an absolute value?
источник

MG

Matthew Good in pro.algorithms
Azure Mynn
That has something to do with the relative scrolling thingy, is there really not an API to just specify an absolute value?
ill see if i can find one
источник

MG

Matthew Good in pro.algorithms
this seems to work

document.scrollBy(0, -documentScrollY);
document.scrollBy(0, (int) absoluteOffset);
источник

MG

Matthew Good in pro.algorithms
Matthew Good
and it seems to scroll by a less amount depending on how fast i move the scroll bar
ok, this can be fixed by scrolling when i draw my view
источник

MG

Matthew Good in pro.algorithms
which means i do not need to scroll when i compute the scroll position either 🙂
источник

MG

Matthew Good in pro.algorithms
now, if i want to also be able to scroll via contents (eg scrolling the contents also scrolls the scroll bar) how should i go about such?

eg the contents being scrolled also synchronizes the current position of the scroll bar
источник

AM

Azure Mynn in pro.algorithms
Just do the whole algorithm in reverse
источник

MG

Matthew Good in pro.algorithms
o.o
источник

MG

Matthew Good in pro.algorithms
im not sure how
источник

AM

Azure Mynn in pro.algorithms
Matthew Good
im not sure how
Take the final scroll value as the input and scrollBarPosition as the output
источник

MG

Matthew Good in pro.algorithms
would it be something like this?

void scrollThumb() {
   multiplier2 = documentScrollY / (windowHeight - documentHeight);
   absoluteOffset2 = multiplier2 * (getHeight() - clip.getHeight());
   clip.setY(absoluteOffset2);
}

void scrollDocument() {
   multiplier = clip.getY() / (getHeight() - clip.getHeight());
   absoluteOffset = multiplier * (documentHeight - windowHeight);
   scrolling = true;
   document.scrollBy(0, -documentScrollY);
   document.scrollBy(0, (int) absoluteOffset);
   scrolling = false;
}
источник

AM

Azure Mynn in pro.algorithms
multiplier = absoluteOffset / (documentHeight - windowHeight);

scrollBarPosition = multiplier * (getHeight() - scrollBarPosition);
источник