Simulate a Pan action using MouseEnter to start the movement and MouseExit to stop it

Hi there, has anyone been able to simulate a pan action where:

  1. There is an image in a div, but only part of the image is shown (div is set to be smaller than the image).
  2. There is a pan right button, that when the mouse enters the button, the image starts moving left (which look like you are panning right).
  3. On mouse exit, I want the panning to stop and the image to stay where it is.

I’ve got #1 and #2 working, but not #3.

I’ve attached the rp file.

I’m open to other ways of doing this other than on mouse enter / exit. I’m just trying to simulate someone using their iphone camera and panning a room.Panning.rp (288.1 KB)

In order to do this kind of dynamic go/stop action, you’ll want to move a small amount, test if another small move should be done (mouse cursor still over the button) and repeat that until a move should not be done (mouse cursor no longer over the button.) If you issue a command to move something “all the way” then that will happen (ballistically) and cannot be stopped.

In Axure, the most reliable way to repetitively loop an action or series of actions is with a dynamic panel set to change state to “Next, repeat every N milliseconds.” You don’t need any content in the dynamic panel, just a minimum of two states (so it can actually change states.)

I duplicated your page to Dessi (1), added two dynamic panels–one for each panning button–named “functionPanLeft” and “functionPanRight” (placed just below each button.) I changed the Mouse Exit action to “Set Panel State functionPanLeft to Next, wrap, repeat every 100 ms” to create this repeating loop. I added a Mouse Exit event with action of “Set Panel State funtionPanLeft to stop repeating” which breaks the loop. The “functionPanLeft” dynamic panel has a State Changed action of “Move room simulation by (30, 0) with boundaries: left <= 0”. So, when the mouse cursor enters “button.pan left” the “room simulation” image will move 30 pixels every 100 ms (but cannot move past x=0) and when the mouse cursor exits that widget the dynamic panel stops repeating so the movement stops.

You can play around with the speed and smoothness of motion by changing the duration of the “state change repeat” value (currently 100 ms) and/or the amount of movement per each state change (currently 30 px).

Panning.rp (459.8 KB)

1 Like

WOW mbc66! That is AWESOME! Thanks so much! This really helped. I actually like the exact way you have it since I needed to simulate someone panning a room with their iPhone.

Hello, (excuse for my english)
I was trying to do something like that in Axure but there was something i didn’t understand, I was looking for something like “onEnterframe” in Flash or how to create a “listener”…
So thank you so much for this share, it was a big help for me !