Recently, I developed a page that allows users to drag an image of the sun in an arc. The sun transitions from a bright sun to a darker version and eventually into a moon as it moves along the arc. Now, my goal is to have the background image also transition seamlessly.
I am seeking advice on how to smoothly fade the current sky background image into a tiled night sky image (similar to the one provided below) when the sun reaches the halfway point of its arc.
https://i.sstatic.net/8kI2q.gif
To visualize what I'm describing, you can check out the interactive demonstration at .
var width = 300,
sun = $("#sun"),
dark = $("#dark_sun"),
moon = $("#moon"),
total = $(window).width()
firstOfThree = (total / 3) * 0,
secondOfThree = (total / 3) * 1,
thirdOfThree = (total / 3) * 2;
// Drag functionality
// CSS styling for elements
<script src="//code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<img id="moon" src="http://i.imgur.com/VmFEwrH.png">
<img id="dark_sun" src="http://i.imgur.com/f3UFHb7.png">
<img id="sun" src="http://i.imgur.com/DGkZYZQ.png">