dixonandmoe / rellax

Lightweight, vanilla javascript parallax library
https://dixonandmoe.com/rellax/
MIT License
7.06k stars 878 forks source link

Cannot pass a node list or an array of html elements to the constructor #159

Open ThisNameWasTaken opened 5 years ago

ThisNameWasTaken commented 5 years ago

Steps to reproduce the problem

Inside a js file write the fallowing code

new Rellax(document.querySelectorAll('.rellax'));

Current behavior

This error is thrown

- TypeError: el.getAttribute is not a function

Expected behavior

It should work just like

new Rellax('.rellax');

Motivation

The first scenario can be useful when you already stored a node list and need to share it with other components as well. On large DOM trees this could increase performance since there would be no need to query multiple times for the same elements.

For instance

const elements = document.querySelectorAll('.rellax');
new Rellax(elements);
new SomeOtherComponent(elements);
// Do more work on the elements ...

I will make a PR which enables this behavior.