nk-o / jarallax

Parallax scrolling for modern browsers
https://jarallax.nkdev.info
MIT License
1.39k stars 214 forks source link

Don't force usage of 'jarallax-img' #201

Closed coldpumpkin closed 2 years ago

coldpumpkin commented 2 years ago

Issue description:

I noticed that if my <img> tag doesn't have the "jarallax-img" class, then it doesn't work. Shouldn't the script search for the <img> or <picture> tags instead? Seems like a redundancy, there's no need to include this class if I already defined the container in JS.

Version used:

1.12.8

Code to reproduce the issue (HTML blocks + JavaScript initialization)

<div class="something">
    <img src="someimage.jpg">
</div>
$('.something').jarallax({
    speed: 0.5
})
nk-o commented 2 years ago

Containers contain different content in most cases. Content with text, photos, galleries, etc. This is why we should use the image class. If you don't need this class, change the selector string to your own in option imgElement https://github.com/nk-o/jarallax#options