|
October 7, 2001 Incrementing the Current Zoom Factor Tips: October 2001
Yehuda Shiran, Ph.D.
|
|
One way to zoom in and out of an element is by incrementing or decrementing the current zoom factor. You can decide for yourself the increment by which you want to go. This zooming method avoids prompting the user for any zoom number. You just provide the user with one button to zoom in and one button to zoom out. Play around with the following Zoom In and Zoom Out buttons. See the effect on the text below ("Press any button above and see the effect!"):
Press any button above and see the effect!
The two buttons are defined as follows:
The event handler zoomInAndOut() handles both cases ("in" and "out"):
The algorithm is straightforward. We determine the current zoom factor, extract the substring without the % sign, convert to integer, and then either add or subtract a one. We then add the % sign back and set the zoom property to the new zoom factor.
People who read this tip also read these tips: Look for similar tips by subject: |