Skip to content

Commit

Permalink
add example for CSS plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Hergaarden committed Dec 18, 2023
1 parent 14c4ae7 commit dc99202
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions examples/CSSPlugin_square.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
<html>

<head>
<script type="text/javascript" src="../lib/tweenjs-NEXT.js"></script>
<script type="text/javascript" src="../src/tweenjs/plugins/CSSPlugin.js"></script>
</head>

<body>
</body>

<script>
timeMs = 0
createjs.Ticker.timingMode = createjs.Ticker.RAF;
createjs.Ticker.init();
createjs.CSSPlugin.install();
var box = document.createElement('div');
box.style.setProperty('background-color', '#008800');
box.style.setProperty('width', '100px');
box.style.setProperty('height', '100px');
box.style.setProperty('opacity', '0.4');
box.style.setProperty('margin-left', '0');
box.style.setProperty('transform', 'skew(30deg, 20deg) scale(0.5, 0.5) rotate(0.2turn)');
document.body.appendChild(box);

createjs.Tween.get(box)
.to({ "margin-left": 240, "top": 0 }, 1000, createjs.Ease["sineIn"]) // Move to (300, 200) in 1 second.
setTimeout(() => {createjs.Tween.get(box).to({ "opacity": 1.0 }, 1000, createjs.Ease["sineIn"])}, 1000) // Move to (300, 200) in 1 second.
setTimeout(() => {createjs.Tween.get(box).to({ "margin-left": 0, "top": 0 }, 1000, createjs.Ease["sineIn"])}, 1000) // Move to (300, 200) in 1 second.
setTimeout(() => {createjs.Tween.get(box).to({ "margin-left": 240, "top": 0 }, 1000, createjs.Ease["sineIn"])}, 3000) // Move to (300, 200) in 1 second.
setTimeout(() => {createjs.Tween.get(box).to({ "margin-left": 0, "top": 0 }, 1000, createjs.Ease["sineIn"])}, 5000) // Move to (300, 200) in 1 second.
setTimeout(() => {createjs.Tween.get(box).to({ "margin-left": 240, "top": 0 }, 1000, createjs.Ease["sineIn"])}, 7000) // Move to (300, 200) in 1 second.
setTimeout(() => {createjs.Tween.get(box).to({ "margin-left": 0, "top": 0 }, 1000, createjs.Ease["sineIn"])}, 9000) // Move to (300, 200) in 1 second.
setTimeout(() => {createjs.Tween.get(box).to({ "transform": "skew(1deg, 1deg) scale(1, 1) rotate(0turn)" }, 1000, createjs.Ease["sineIn"])}, 1000) // Move to (300, 200) in 1 second.
</script>

</html>

0 comments on commit dc99202

Please sign in to comment.