I don't understand how to use XUI tween. On the xui website, they give the following example code:
x$('#box').tween([{left:'100px', backgroundColor:'green', duration:.2 }, { right:'100px' }]);
What is that supposed to do? I created a <div id="box"></div>
, ran the line of js code above, but nothing happened. Here's my complete code:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script type="text/javascript" src="xui.min.js"></script>
<script type="text/javascript">
x$('#box').tween([{left:'100px', backgroundColor:'green', duration:.2 }, { right:'100px' }]);
</script>
</head>
<body>
<div id="box"></div>
</body>
</html>
Nothing happens...
So, XUI's tween seems to be a work in process. In fact, in the master branch code on GitHub you find:
So, in short, the array-based tween properties appear busted at the moment. In addition, XUI's
tween
seems to be a little flakey when dealing with properties that are not currently set on the DOM element. (For example, setting thebackground-color
on a transparent element turns it black...rather than the intended color.)That said, the single
tween
andcallback
work well on previously set properties. So take a look at the following (and excuse the inline css):Because
#box
now has a cssbackground-property
andleft
position explicitly set, it is relatively easy to produce an effect similar to the one desired.One-half second after the page loads,
#box
should spend 2 seconds moving fromleft:500px
toleft:100px
while turning the background color from white to green. Then, using the callback,#box
moves back to its original position atleft:500px
--taking another 2 seconds to get back.Obviously, this does not answer your exact question but for those (like me) who stumble upon this, it provides a workaround for the time being.