Resetting the timer when you reach the image

Hello,
I want to stop the timer when reaching a certain image in a dynamic image.
Would appreciate help!

I assume you have created a timer which can be stopped, and you know how to stop it. I’ll further assume that “reaching a certain image” means scrolling, and that “dynamic image” means your image is inside a Dynamic Panel.

You can use the Dynamic Panel’s Scrolled event to test the amount of scroll against the image’s position. So, if you are scrolling vertically, the “total amount of scroll” in pixels is available with a built-in property named, scrollY (or, if scrolling horizontally, scrollX).

  • For a dynamic panel, use [[This.scrollY]] (or [[LVAR1.scrollY]] , where LVAR1 is local variable pointing to the dynamic panel).
  • To get the vertical scroll amount of the entire page, or browser window, use the expression, [[Window.scrollY]]

The easiest case is determining when an image reaches the top of the dynamic panel. Using LVAR1 as a local variable pointing to your image, the case logic goes like:

If [[This.scrollY]] is greater than or equals [[LVAR1.top]] StopTimer

If you want to stop your timer when an image first becomes visible (reaches the bottom of the panel when scrolling down):

If [[This.scrollY]] is greater than or equals [[LVAR1.top - This.height]] StopTimer

If you want to stop your timer when an image becomes fully visible (image bottom reaches the bottom of the panel when scrolling down):

If [[This.scrollY]] is greater than or equals [[LVAR1.bottom - This.height]] StopTimer

If “reaching an image” is some other location, you can use additional math to calculate the location of an image in relation to another widget.