案例:
<style>
#box {
width: 100px;
height: 100px;
background-color: red;
}
</style>
<body>
<div id="box"></div>
</body>
<script>
(function () {
let box = document.querySelector("#box");
box.onclick = function () {
mTween({
el: box,
attr: {
width: 300
},
duration: 600,
fx: "backOut",
cb() {
mTween({
el: box,
attr: {
height: 300
},
duration: 600,
fx: "backOut",
cb() {
mTween({
el: box,
attr: {
opacity: 0.5
},
duration: 600,
fx: "backOut",
});
}
});
}
});
}
})()
</script>