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 Code for the CartZone class which represents a drop zone Samples function element this element initialize function this initialize this dispose function this this dispose _ 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. The IDropTarget interface The 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 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 Methods defined in the .