>  기사  >  웹 프론트엔드  >  "HTML5 Canvas 및 JS 라이브러리의 선택/드래그 앤 드롭 기능이 있습니까?"

"HTML5 Canvas 및 JS 라이브러리의 선택/드래그 앤 드롭 기능이 있습니까?"

WBOY
WBOY앞으로
2023-09-02 11:13:021038검색

"HTML5 Canvas和JS库中的选择/拖放功能?"

HTML5 캔버스를 사용하여 모양, 텍스트 및 곡선을 그리고 onClick 또는 드래그 앤 드롭 기능과 같은 기존 DOM 이벤트를 첨부하려는 경우 드래그 앤 드롭 작업에 Crossbar 프레임워크 Raphael을 사용할 수 있습니다. 터치 이벤트.

이 기술은 이전 버전의 IE에 대해 SVG 및 XML을 사용합니다. HTML을 사용한 드래그 앤 드롭은 아래와 같습니다.

<!DOCTYPE html>
<html lang = "en">
   <head>
      <meta charset = "utf-8">
         <title>Rapha&euml;l &middot; Drag-n-drop</title>
         <link rel = "stylesheet" href = "demo.css" type = "text/css" media = "screen">
         <meta name = "apple-mobile-web-app-capable" content = "yes">
         <link rel = "apple-touch-icon-precomposed" href = "/Raphael.png">
         <link rel = "stylesheet" href = "demo-print.css" type = "text/css" media = "print">
         <script src = "raphael.js"></script>
         <script>
            window.onload = function () {
               var R = Raphael(0, 0, "100%", "100%"),
               r = R.circle(100, 100, 50).attr({fill: "hsb(0, 1, 1)", stroke: "none", opacity: .5}),
               g = R.circle(210, 100, 50).attr({fill: "hsb(.3, 1, 1)", stroke: "none", opacity: .5}),
               b = R.circle(320, 100, 50).attr({fill: "hsb(.6, 1, 1)", stroke: "none", opacity: .5}),
               p = R.circle(430, 100, 50).attr({fill: "hsb(.8, 1, 1)", stroke: "none", opacity: .5});
            var start = function () {
               this.ox = this.attr("cx");
               this.oy = this.attr("cy");
               this.animate({r: 70, opacity: .25}, 500, ">");
            },
            move = function (dx, dy) {
               this.attr({cx: this.ox + dx, cy: this.oy + dy});
            },
            up = function () {
               this.animate({r: 50, opacity: .5}, 500, ">");
            };
            R.set(r, g, b, p).drag(move, start, up);
         };
      </script>
   </head>
   <body>
      <div id = "holder"></div>
      <p id = "copy">Demo of <a href = "http://raphaeljs.com/">Rapha&euml;l</a>&mdash; JavaScript Vector Library</p>
   </body>
</html>

위 내용은 "HTML5 Canvas 및 JS 라이브러리의 선택/드래그 앤 드롭 기능이 있습니까?"의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

성명:
이 기사는 tutorialspoint.com에서 복제됩니다. 침해가 있는 경우 admin@php.cn으로 문의하시기 바랍니다. 삭제