Changeset 0c6b92a for imaps-frontend/src/scripts/shapes/InfoPin.js
- Timestamp:
- 12/12/24 17:06:06 (5 weeks ago)
- Branches:
- main
- Parents:
- d565449
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
imaps-frontend/src/scripts/shapes/InfoPin.js
rd565449 r0c6b92a 1 import Konva from "konva"; 2 import MapShape from "./MapShape"; 3 import Factory from "../util/Factory"; 1 4 2 import { _registerNode } from "konva/lib/Global"; 5 export default class InfoPin extends MapShape { 6 constructor(mousePos, blockSize, layer, snappable,id) { 3 import MapNode from "../base/MapNode.js"; 4 import {node} from "prop-types"; 5 import draw from "../../pages/Draw/Draw.jsx"; 6 export default class InfoPin extends MapNode { 7 constructor(attrs,id) { 8 attrs.snap = false; 7 9 super( 8 10 { 9 x: mousePos.x,10 y: mousePos.y,11 radiusX: blockSize * 0.5,12 radiusY: blockSize * 0.7,13 tailHeight: blockSize * 1.2,14 fill: "# d70113",11 x: attrs.position.x, 12 y: attrs.position.y, 13 radiusX: attrs.blockSize * 0.5, 14 radiusY: attrs.blockSize * 0.7, 15 tailHeight: attrs.blockSize * 1.2, 16 fill: "#f60000", 15 17 stroke: "#1b1b1b", 16 strokeWidth: 0.2,18 strokeWidth: 1, 17 19 draggable: true, 18 20 name: "mapObj", 19 21 }, 20 layer,21 blockSize,22 snappable22 attrs.layer, 23 attrs.blockSize, 24 attrs.snap 23 25 ); 24 26 25 27 this.id = id; 28 this.eventName = "openPinModalEvent"; 29 this.floorNum = attrs.floorNum; 26 30 27 this.modalEventName = "openPinModalEvent";28 31 this.type = "InfoPin"; 29 32 this._info = { 30 name: `Pin ${id}`,33 name: `Pin${id} [${this.floorNum}F]`, 31 34 selectedPins: [], 32 35 description: "", … … 34 37 35 38 this.on("mouseover", () => { 36 this.fill(" yellow");39 this.fill("#FFD700"); 37 40 }); 38 41 this.on("mouseout", () => { 39 this.fill(" red");42 this.fill("#f60000"); 40 43 }); 44 41 45 42 46 this.initText(); 43 47 } 44 48 _sceneFunc(context, shape) { 45 const { radiusX, radiusY, tailHeight } = this.attrs; 49 const { radiusX, radiusY, tailHeight } = this.attrs; // attrs od konva 46 50 47 51 context.beginPath(); … … 59 63 } 60 64 65 61 66 loadInfo(attrs) { 62 67 this.info.name = attrs.obj_name; 63 68 this.info.selectedPins = attrs.connected_pins; 64 69 this.info.description = attrs.description; 70 this.floorNum = attrs.floor_num 65 71 } 66 72 … … 69 75 this.setAttr("connected_pins", this.info.selectedPins); 70 76 this.setAttr("description", this.info.description); 77 this.setAttr("floor_num",this.floorNum) 71 78 console.log(this.info, "vnatre vo info"); 79 } 80 81 connect(node, draw = true) { 82 if(this.floorNum !== node.floorNum) return; 83 super.connect(node) 72 84 } 73 85 }
Note:
See TracChangeset
for help on using the changeset viewer.