marcbruederlin / particles.js

A lightweight, dependency-free and responsive javascript plugin for particle backgrounds.

Home Page:https://marcbruederlin.github.io/particles.js/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Use parentNode's width and height instead of window's sizes.

FedericoBiccheddu opened this issue · comments

With a simple change the canvas can be limited to the container, even the body, when it's used as a background, e.g. in a header element.

canvas.width = canvas.parentNode.offsetWidth;
canvas.height = canvas.parentNode.offsetHeight;

If it's ok for you, I can try to submit a PR.

A PR would be nice 👍