svg.js 中的通用事件

问题描述

我正在 SVG.JS 中绘制交通系统地图,但终生无法弄清楚当有人悬停在车站上空时如何发生一般事件。

var draw = SVG().addTo('#canvas').size('700','700')

// =============== STATIONS ===============
var station = draw.group()

// OGX Station
var ogx = station.group()
var ogx_red = ogx.circle(6).attr({ cx: 401,cy: 50 })
var ogx_grn = ogx.circle(6).attr({ cx: 410,cy: 50 })

// FRO Station
var fro = station.group()
var fro_red = fro.circle(4).attr({ cx: 401,cy: 50 })
var fro_grn = fro.circle(4).attr({ cx: 410,cy: 50 })

// =============== EVENTS ===============
ogx.mouSEOver(function() {
  getStationDepartures("ogx");
  this.fill("#000")
})

ogx.mouSEOut(function() {
  this.fill("#fff")
})

fro.mouSEOver(function() {
  getStationDepartures("fro")
  this.fill("#000")
})

fro.mouSEOut(function() {
  this.fill("#fff")
})

理想情况下,我们可以说当有人将鼠标悬停在/鼠标移出 station 的任何孩子时,应该发生一个通用函数,并传递其中的特定站名。但我不知道该怎么做。

相关文档:https://svgjs.dev/docs/3.0/events/

任何帮助将不胜感激。

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)