H.wrap(H.Chart.prototype, 'render', function (proceed) {
var chart = this,
proceed.call(chart);
// Add the mousewheel event to make vertical scroll
H.addEvent(chart.container,'mousewheel', function (event) {
let delta, extr, step, axis = chart.yAxis[0];
let e = chart.pointer.normalize(event);
// Firefox uses e.detail, WebKit and IE uses wheelDelta
delta = e.detail || (e.wheelDelta / 120);
delta = delta < 0 ? 1 : -1;
extr = axis.getExtremes();
const min = extr.min;
const max = extr.max;
const dataMax = extr.dataMax;
if (chart.isInsidePlot(e.chartX - chart.plotLeft, e.chartY - chart.plotTop) && (min > 1 || (min < 1 && delta === 1)) && (max < dataMax || (max >= dataMax && delta === -1))) {
step = (extr.max - extr.min) / 5 * delta;
axis.setExtremes(extr.min + step, extr.max + step, true, false);
}
globalObj.stopEvent(event); // Issue #5011, returning false from non-jQuery event does not prevent default
return false;
});
})
我正在销毁ngOndestroy中的图表,当我再次返回到相同的组件时,之前创建的闭包仍然没有被销毁。当组件被销毁时,我需要删除wrap函数。
1条答案
按热度按时间idv4meu81#
根据@ppotaczek的建议,我删除了Wrap函数,并在创建图表后调用了add event函数。