• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL

Hour 17. Adding Advanced Behaviors: Drag... > Capturing the Drop Target Location

Capturing the Drop Target Location

We could calculate or guess at the exact target location, which might work some of the time. But the easiest way to capture the perfect target location is to take advantage of the Drag Layer behavior's built-in Get Current Position button. This button will capture the position of the layer and fill in the coordinates for you. First, make sure the Prevent Layer Overlaps check box is not selected in the Layers panel.

Line up the layer that you set previously in the Drag Layer behavior in its final position on the target. Remember that you can use the arrow keys on the keyboard to move the layer one pixel at a time for fine-tuning.

Select the <body> tag from the tag selector.

Double-click the Drag Layer behavior you just set up in the Behaviors panel to edit it.

If you do not see the behavior attached to the <body> tag when you select it, you've applied the behavior to the wrong tag. You will need to hunt down the object to which you applied the behavior and delete the behavior in the Behaviors panel. As you click on objects in the document window, look at the Behaviors panel to see which object has the behavior attached to it.

Click on the Get Current Position button. The Left and Top values will fill in automatically, as shown in Figure 17.4. The Snap if Within box automatically defaults to 50 pixels.

Figure 17.4. The Get Current Position button automatically fills in the coordinates with the current position of the Drag Layer.

Accept the default Snap if Within value or change it. This value sets how close the user must drop the layer in order for it to snap and depends upon the size of your target area. Make sure this value isn't so small that it's difficult for the user to position the layer, or so big that the user doesn't need to be accurate.

Click OK.

Remember to put the layer back in its original position. Then preview the page in the browser.



Not a subscriber?

Start A Free Trial

  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint