0

How do I change the scroll position of a scrollable container based on input field value?

Hi,

 

I have a prototype which is working really good so far. No I have a problem, I can’t figure out, how to get rid of it.

 

My setup: 

I have 3 input fields and a scrollable container as you can see on the attached image.

What I already can do is swiping the scrollable container and changing the position of the ruler. When I do so, the numbers inside the three input fields are changing.

The same interaction is working on the smaller ruler between the three input fields and the big ruler.

What I also want to achieve, but I can’t figure out how is, to change the value inside the input field and after that, changing the scroll position of the scroll container (ruler).

What I have done so far is:

  1. Set a variable "inputvalue" to get the value of the input field
  2. Set variable "scrollposition" to get the current x-position of the scrollable container
  3. Set variable "calcnewposition". Using a formula where I calculate the x-value based on the current scroll position and the value of the input field
  4. Change "Horizontal scroll position" based of the value i get from "calcnewposition"

There is something I’m doing wrong. The position of the scroll container is not changing and all values of the input fields printing "NaN".

Any idea of how to get it working?

Thanks
Kai

1 comment

Please sign in to leave a comment.