jQuery in Action

Introduction to the UI Plugin
307
Exercise 4--Reset the Lab, and choose True for the
revert
option, and click
Apply. Drag the test subject, and note how it moves back to its original location
when the operation concludes. Now, select Clone for the
helper
, click Apply, and
repeat the exercise. Note that
revert
is applied to the clone.
Exercise 5--Reset the Lab, and experiment with the setting of the
axis
option.
You can use this option to constrain the movement during a drag to the horizon-
tal or vertical planes.
Exercise 6--In this exercise, we'll turn our attention to the
containment
option.
You'll want to increase the height of your browser window to as much as your
screen will allow; hopefully, your resolution will cause some extra space to be
shown below the Console pane.
Up to this point, we've left
containment
unspecified. Recall how you were able
to move the dragon anywhere within the browser window. Now choose Docu-
ment, and click Apply. When you drag the image note two important things:
You can no longer move the image beyond the edges of the window, so no
scrollbars appear where there were previously none.
You can't move the image below the bottom of the Console pane where the
document stops but the window doesn't.
Now change the setting to Parent, and click Apply. When a drag operation is
started, note how you can only drag the image around the inside of the Test Sub-
ject pane (a
<fieldset>
element), which is the parent of the test subject element.
Note, also, that this is true even if the drag operation started outside the parent
(as a result of a previous drag operation that was not constrained to the parent).
Exercise 7--Choose a
helper
option of Clone, and observe the effect of the
Effect
option on the helper in its various settings.
Exercise 8--Reset the Lab, and specify an Opacity of 0.5. Observe how the
opacity of the dragged element is affected whether the original element or a
helper clone is being dragged.
Exercise 9--Reset the Lab, and set the
preventionDistance
option to a large
value such as 200. After clicking Apply, start a drag operation by clicking the edge
of the dragon's left wing and moving the mouse pointer to the right. You traverse
almost the entire width of the dragon (whose image width is 250 pixels) before
the drag operation starts. It would be rare to set this option to such a large value,
but we did so here for illustration of the behavior of the option. More often, this
would be set to a much smaller value to prevent accidental movements of a few
pixels from initiating an unintended drag operation.


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.