扫一扫分享
deck-of-cards是一款非常炫酷的html5扑克牌卡片动画类库。它使用纯js和css3来实现洗牌,发牌等功能。在这个效果的演示中,扑克牌使用SVG来制作,共给出了5种功能的演示效果。
安装
npm install deck-of-cards
例子
<html>
<head>
<title>Cards</title>
<link rel="stylesheet" href="node_modules/deck-of-cards/example/example.css">
</head>
<body>
<script src="node_modules/deck-of-cards/dist/deck.min.js"></script>
<div id="container"></div>
<script>
var $container = document.getElementById('container');
// create Deck
var deck = Deck();
// add to dom
deck.mount($container);
deck.cards.forEach(function (card, i) {
card.setSide(Math.random() < 0.5 ? 'front' : 'back');
// explode
card.animateTo({
delay: 1000 + i * 2, // wait 1 second + i * 2 ms
duration: 500,
ease: 'quartOut',
x: Math.random() * window.innerWidth - window.innerWidth / 2,
y: Math.random() * window.innerHeight - window.innerHeight / 2
});
});
</script>
</body>
</html>
手机预览