hustcc / canvas-nest.js

:cancer: Interactive Particle / Nest System With JavaScript and Canvas, no jQuery.
https://git.hust.cc/canvas-nest.js
MIT License
4.3k stars 826 forks source link

如何销毁和关闭? #22

Closed no-simple closed 6 years ago

no-simple commented 6 years ago

在SPA单页中,路由至其他页面依然存在,并且影响页面操作

hustcc commented 6 years ago

react 吗?感觉可以写一个 react 组件…

no-simple commented 6 years ago

vue。我也使用了您提供的针对指定ID的版本,但是有错误使用不了。没有关闭接口,哭晕啊

no-simple commented 6 years ago

使用一次就成全局存在了。在SPA中销毁组件都销毁不了这个动画

no-simple commented 6 years ago

我尝试了 清除画布 也没有生效。可以提供个解决方法或思路吗?

erguotou520 commented 6 years ago

@no-simple 参考 #23

hustcc commented 6 years ago

v2.0.1 可以销毁。

import CanvasNest from 'canvas-nest.js';

const config = {
  color: '255,0,0',
  count: 88,
};

// render nest on element with config.
const cn = new CanvasNest(element, config);

// destroy
cn.destroy();
hustcc commented 6 years ago

@erguotou520 你这个销毁方法在 mouse 事件上没有做的特别好!

erguotou520 commented 6 years ago

Good job.