Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Bonsai JS を使い始めたばかりで、ドキュメントに何も見つからないので、ここで質問することにしました。CSS でいくつかのスタイルを定義できるように、要素のクラス属性を設定するにはどうすればよいですか? ほとんどのスタイルは Bonsai で直接サポートされていますが、要素の上にカーソルを置いたときにカーソルの種類を変更する必要もあります。
BonsaiJS では「class」属性を設定できません。代わりに、カーソルが の上に置かれたときにリスナーを追加しますDisplayObject。
DisplayObject
new Rect(150, 150, 150, 150).attr({ fillColor: "red" }).addTo(stage).on("mouseover mouseout", function(e) { this.attr({ cursor: e.type == "mouseover" ? "pointer" : "inherit" }); });
Orbit で開く: http://orbit.bonsaijs.org/#new%20Rect(150%2C%20150%2C%20150%2C%20150).attr(%7B%0A%20%20fillColor%3A%20%22red %22%0A%7D).addTo(stage).on(%22mouseover%20mouseout%22%2C%20function(e)%20%7B%0A%20%20this.attr(%7B%0A%20%20% 20%20cursor%3A%20e.type%20%3D%3D%20%22mouseover%22%20%3F%20%22pointer%22%20%3A%20%22inherit%22%0A%20%20%7D) %3B%0A%7D)%3B%0A%20