Canvas drag and dropIf your application has a graphical emphasis, then dịch - Canvas drag and dropIf your application has a graphical emphasis, then Việt làm thế nào để nói

Canvas drag and dropIf your applica

Canvas drag and drop

If your application has a graphical emphasis, then the choice to use canvas is probably a sensible one. While graphical applications are possible with DOM based approaches, as more graphical elements are added, the DOM can become cluttered and performance can be affected. Since canvas is simply rendered as a bitmap, it does not have the same overhead. This comes at a price however. Since there are no actual elements, just the canvas bitmap, there is no event handling API, so this must be managed by the application.

Having said this, we can drag an element around on canvas much as we can drag an element around on the page, but we have a little extra work to do because of the lack of an event handling API. Drag and drop on a DOM element is easier, since we can detect the element in which the event occurred.

With canvas, we will know the coordinates where a touch started or ended, but we will need to determine what objects on the canvas might have been potential targets of the interaction. A simple approach would be to maintain a list of objects, and their bounding boxes, and for each touch event, to match against this list, to find what object has been interacted with, and to make it the target of the touch. This is the approach we take in the following example:

Simple Canvas drag and drop example

In this example, we show how to implement a simple drag and drop on the canvas element. First we start with the canvas element.
0/5000
Từ: -
Sang: -
Kết quả (Việt) 1: [Sao chép]
Sao chép!
Canvas drag and dropIf your application has a graphical emphasis, then the choice to use canvas is probably a sensible one. While graphical applications are possible with DOM based approaches, as more graphical elements are added, the DOM can become cluttered and performance can be affected. Since canvas is simply rendered as a bitmap, it does not have the same overhead. This comes at a price however. Since there are no actual elements, just the canvas bitmap, there is no event handling API, so this must be managed by the application.Having said this, we can drag an element around on canvas much as we can drag an element around on the page, but we have a little extra work to do because of the lack of an event handling API. Drag and drop on a DOM element is easier, since we can detect the element in which the event occurred.With canvas, we will know the coordinates where a touch started or ended, but we will need to determine what objects on the canvas might have been potential targets of the interaction. A simple approach would be to maintain a list of objects, and their bounding boxes, and for each touch event, to match against this list, to find what object has been interacted with, and to make it the target of the touch. This is the approach we take in the following example:Simple Canvas drag and drop exampleIn this example, we show how to implement a simple drag and drop on the canvas element. First we start with the canvas element.
đang được dịch, vui lòng đợi..
Kết quả (Việt) 2:[Sao chép]
Sao chép!
Canvas kéo và thả

Nếu ứng dụng của bạn có một sự nhấn mạnh đồ họa, sau đó lựa chọn để sử dụng vải có lẽ là một hợp lý. Trong khi các ứng dụng đồ họa có thể xảy ra với các phương pháp tiếp cận dựa trên DOM, như nhiều yếu tố đồ họa được thêm vào, DOM có thể trở nên lộn xộn và hiệu suất có thể bị ảnh hưởng. Kể từ khi vải được chỉ đơn giản là kết xuất như một bitmap, nó không có các chi phí tương tự. Điều này xuất phát ở một mức giá tuy nhiên. Vì không có các yếu tố thực tế, chỉ bitmap vải, không có xử lý sự kiện API, vì vậy điều này phải được quản lý bởi các ứng dụng.

Có nói này, chúng ta có thể kéo một yếu tố xung quanh trên vải nhiều như chúng tôi có thể kéo một yếu tố xung quanh trên trang, nhưng chúng tôi có một ít công việc để làm vì thiếu một sự kiện xử lý API. Kéo và thả trên một phần tử DOM là dễ dàng hơn, vì chúng ta có thể phát hiện các yếu tố, trong đó sự kiện xảy ra.

Với canvas, chúng ta sẽ biết được tọa độ nơi một liên lạc bắt đầu hoặc kết thúc, nhưng chúng ta cần phải xác định những đối tượng trên vải có thể có được mục tiêu tiềm năng của sự tương tác. Một cách tiếp cận đơn giản có thể duy trì một danh sách các đối tượng, và các khung giới hạn của họ, và cho mỗi sự kiện liên lạc, để phù hợp với danh sách này, để tìm thấy những gì đối tượng đã được hưởng, và để làm cho nó trở thành mục tiêu của các liên lạc. Đây là cách tiếp cận chúng ta lấy trong ví dụ sau:

Đơn giản Canvas kéo và thả dụ

Trong ví dụ này, chúng ta thấy làm thế nào để thực hiện một đơn giản kéo và thả trên canvas. Đầu tiên chúng ta bắt đầu với các phần tử canvas.
đang được dịch, vui lòng đợi..
 
Các ngôn ngữ khác
Hỗ trợ công cụ dịch thuật: Albania, Amharic, Anh, Armenia, Azerbaijan, Ba Lan, Ba Tư, Bantu, Basque, Belarus, Bengal, Bosnia, Bulgaria, Bồ Đào Nha, Catalan, Cebuano, Chichewa, Corsi, Creole (Haiti), Croatia, Do Thái, Estonia, Filipino, Frisia, Gael Scotland, Galicia, George, Gujarat, Hausa, Hawaii, Hindi, Hmong, Hungary, Hy Lạp, Hà Lan, Hà Lan (Nam Phi), Hàn, Iceland, Igbo, Ireland, Java, Kannada, Kazakh, Khmer, Kinyarwanda, Klingon, Kurd, Kyrgyz, Latinh, Latvia, Litva, Luxembourg, Lào, Macedonia, Malagasy, Malayalam, Malta, Maori, Marathi, Myanmar, Mã Lai, Mông Cổ, Na Uy, Nepal, Nga, Nhật, Odia (Oriya), Pashto, Pháp, Phát hiện ngôn ngữ, Phần Lan, Punjab, Quốc tế ngữ, Rumani, Samoa, Serbia, Sesotho, Shona, Sindhi, Sinhala, Slovak, Slovenia, Somali, Sunda, Swahili, Séc, Tajik, Tamil, Tatar, Telugu, Thái, Thổ Nhĩ Kỳ, Thụy Điển, Tiếng Indonesia, Tiếng Ý, Trung, Trung (Phồn thể), Turkmen, Tây Ban Nha, Ukraina, Urdu, Uyghur, Uzbek, Việt, Xứ Wales, Yiddish, Yoruba, Zulu, Đan Mạch, Đức, Ả Rập, dịch ngôn ngữ.

Copyright ©2024 I Love Translation. All reserved.

E-mail: