Đang chuẩn bị liên kết để tải về tài liệu:
ASP.NET AJAX in Action phần 9
Đang chuẩn bị nút TẢI XUỐNG, xin hãy chờ
Tải xuống
Cho đến nay, bạn đã tạo ra một điều khiển máy khách để duyệt một tập hợp các hình ảnh được lưu trữ trong trang web. Mục tiêu tiếp theo của bạn là để tăng cường kiểm soát bằng cách thêm một chuyển đổi động giữa các hình ảnh. Cuối cùng, mất dần hình ảnh mới và thay thế hình ảnh cũ. | The drag-and-drop engine 423 Listing 12.4 Code for the CartZone class which represents a drop zone Type.registerNamespace Samples Samples.CartZone function element Samples.CartZone.initializeBase this element Samples.CartZone.prototype initialize function Samples.CartZone.callBaseMethod this initialize Sys.Preview.UI.DragDropManager.registerDropTarget this dispose function Sys.Preview.UI.DragDropManager.unregisterDropTarget this Samples.CartZone.callBaseMethod this dispose _ Samples.CartZone.registerClass Samples.CartZone Sys.UI.Control As anticipated the registerDropTarget method is called in the initialize method where you perform the control s initial setup. Its counterpart is the unregisterDropTarget method which is used to remove the control from the list of drop targets held by the DragDropManager. It s usually invoked in the dispose method where the cleanup of the current instance is performed. To receive feedback from the DragDropManager a drop target must implement the IDropTarget interface. Following the same approach we took with the BookItem control we ll first introduce the interface and then implement it in the CartZone control. 12.1.7 The IDropTarget interface The Sys.Preview.UI.IDropTarget interface is implemented by drop targets to receive feedback from the DragDropManager. By implementing this interface a drop target can determine whether a draggable item can be dropped over its area. You can also take actions based on the position of the draggable item with respect to the drop zone. Table 12.2 lists the methods defined by the IDropTarget interface along with their descriptions. The get_dropTargetElement method returns the DOM element that acts as the drop zone. Usually this is the associated element of the client component that represents the drop target. When an element is being dragged the DragDropManager calls this method on every registered drop targets. Then it performs 424 CHAPTER 12 Dragging and dropping Table 12.2 Methods defined in the .