久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

在 Raphael js 中使路徑和圖像可拖動

Making paths and images draggable in Raphael js(在 Raphael js 中使路徑和圖像可拖動)
本文介紹了在 Raphael js 中使路徑和圖像可拖動的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

是否可以使用 Raphael js 在頁面周圍拖放除圓形和矩形以外的對象?

Is it possible to be able to drag and drop objects other than just circles and rectangles around a page using Raphael js?

我想添加路徑和圖像,然后您可以四處移動,但事實證明這很棘手.我想和 Raphael 一起解決這個問題,因為它支持觸摸界面.

I want to add in paths and images which you can then move around but its proving tricky. I would like to work this out with Raphael because of its support with touch interfaces.

這里是代碼

<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: "#fff", "fill-opacity": 0, "stroke-width": 0.8, opacity: .5}),
            p = R.path("M 250 250 l 0 -50 l -50 0 l 0 -50 l -50 0 l 0 50 l -50 0 l 0 50 z") .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>

推薦答案

這里的關鍵(我發(fā)現(xiàn))是將 x 和 y 增量轉換為路徑對象可以理解的翻譯值.

The key here (that I found) is to convert the x and y deltas into translate values, which the path object understands.

http://www.nathancolgate.com/post/2946823151/drag-and-drop-paths-in-raphael-js

實際上是相同的方法:

var paper = Raphael(10, 50, 320, 200);

var tri = paper.path("M0 0L0 20L25 10L0 0Z").attr("fill", "#ff0");
var rex = paper.rect(10, 20, 50, 50).attr("fill", "#ff0");

var start = function () {
  this.odx = 0;
  this.ody = 0;
  this.animate({"fill-opacity": 0.2}, 500);
},
move = function (dx, dy) {
  this.translate(dx - this.odx, dy - this.ody);
  this.odx = dx;
  this.ody = dy;
},
up = function () {
    this.animate({"fill-opacity": 1}, 500);
};

tri.drag(move, start, up);
rex.drag(move, start, up);

這篇關于在 Raphael js 中使路徑和圖像可拖動的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!

【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!

相關文檔推薦

How can I get my jasmine tests fixtures to load before the javascript considers the document to be quot;readyquot;?(在 javascript 認為文檔“準備好之前,如何讓我的 jasmine 測試裝置加載?) - IT屋-程序員軟件開發(fā)技術
What do jasmine runs and waitsFor actually do?(jasmine 運行和等待實際上是做什么的?)
How to provide mock files to change event of lt;input type=#39;file#39;gt; for unit testing(如何提供模擬文件來更改 lt;input type=filegt; 的事件用于單元測試)
How to unit test a chained method using Jasmine(如何使用 Jasmine 對鏈式方法進行單元測試)
How do I inject $rootScope into an AngularJS unit test?(如何將 $rootScope 注入 AngularJS 單元測試?)
Jasmine - How to spy on a function call within a function?(Jasmine - 如何監(jiān)視函數(shù)中的函數(shù)調(diào)用?)
主站蜘蛛池模板: 国产美女在线观看 | 亚洲午夜精品视频 | 成人在线免费av | 国产激情毛片 | 九九九久久国产免费 | 天天操夜夜爽 | 一区精品国产欧美在线 | 国产精品久久久久久久毛片 | 天天操人人干 | 亚洲协和影视 | 精品在线一区 | 一级做a| 色视频成人在线观看免 | 99re在线视频| 综合色播 | 国产精品国产精品国产专区不卡 | 日韩成人中文字幕 | 亚洲女人天堂成人av在线 | 成人午夜性成交 | 欧美区日韩区 | 日韩视频免费看 | 天堂资源 | 国产一区二区三区 | 在线观看av网站永久 | 成人国产在线视频 | 国产区在线观看 | 亚洲成人www | 亚洲成人免费在线观看 | 国产精品福利久久久 | 久久久久久久久久久久91 | 黄色在线免费观看 | 亚洲国产成人精品女人久久久 | 日本精品一区二区三区在线观看 | 久久久久国产一区二区三区不卡 | 在线一区| 日本精品裸体写真集在线观看 | 国产精品久久久久aaaa | av永久免费 | 久久国产成人 | 国产精品一区二区免费 | 亚洲欧美在线观看 |