Setting up parallax.js I ran into this:
The html source markup (in the official GIThub project) is:
<ul id="scene" class="scene">
<li class="layer" data-depth="1.00"><img src="images/layer1.png"></li>
<li class="layer" data-depth="0.80"><img src="images/layer2.png"></li>
<li class="layer" data-depth="0.60"><img src="images/layer3.png"></li>
<li class="layer" data-depth="0.40"><img src="images/layer4.png"></li>
<li class="layer" data-depth="0.20"><img src="images/layer5.png"></li>
<li class="layer" data-depth="0.00"><img src="images/layer6.png"></li>
</ul>
But if we look at the (really awesome) Wagerfield example it looks like the images are brought in as a background image of a div block inside each .layer class element.
The explanation I can give myself is that in this way the image can be controlled more flexibly,
I'm just starting out with JS so I really can't find a workaround: but couldn't the script transform this
<img src="images/layer1.png">
into something like:
<div class="layer1" style="background:url(images/layer1.png) no-repeat 50% 100%"></div>
Can this be achieved easily?
Extending the question it would be cool to entirely style the .layer with inline styles passed through the script.
Script so far:
jQuery("li.layer > img").replaceWith
("<div class=\"" + $((("li.layer > img").src).replace(/\.[^/.]+$/, "")) + "\"</div>" );
this part isn't working (i'm looking for the url output of images..):
(("li.layer > img").src).replace(/\.[^/.]+$/, "")