jquery-动画?
目前我正在开发一个网络商店,我想制作一个动画。当用户点击“添加到购物车”按钮时,我想将产品添加到购物车(图像直接进入购物车动画)。我尝试使用jquery函数,但速度太慢了jquery-动画?,jquery,jquery-animate,effect,Jquery,Jquery Animate,Effect,目前我正在开发一个网络商店,我想制作一个动画。当用户点击“添加到购物车”按钮时,我想将产品添加到购物车(图像直接进入购物车动画)。我尝试使用jquery函数,但速度太慢了 <script> var cCount = 0; var cId = -1; function add_to_cart(){ cId = setInterval(function(){ animateCart(); }, 1); } function animateCart(){ $("#car
<script>
var cCount = 0;
var cId = -1;
function add_to_cart(){
cId = setInterval(function(){ animateCart(); }, 1);
}
function animateCart(){
$("#cart-image").animate({
"left" : "+=1px",
"top" : "-=1px"
}, 1);
if(cCount >= 400)
clearInterval(cId);
cCount++;
}
</script>
var Account=0;
var-cId=-1;
函数add_to_cart(){
cId=setInterval(函数(){animateCart();},1);
}
函数animateCart(){
$(“#购物车图像”)。设置动画({
“左”:“+=1px”,
“顶部”:“-=1px”
}, 1);
如果(帐户>=400)
清除间隔(cId);
cCount++;
}
$(“#购物车图像”)是一幅120x120的图像,绝对位置,不透明度为0.5
脚本正在运行,它将直接进入购物车,但速度太慢。时间太长,4或5秒。我想要跳跃效果之类的东西。这可能吗?一次移动多个像素。一次移动多个像素。你做错了。动画方法本身用于动画,不需要额外的间隔。只需将#购物车图像项目移动到所需位置,在本例中为顶部100px,左侧100px
$("#cart-image").animate({
"left" : "100px",
"top" : "100px"
}, 500);
你做错了。动画方法本身用于动画,不需要额外的间隔。只需将#购物车图像项目移动到所需位置,在本例中为顶部100px,左侧100px
$("#cart-image").animate({
"left" : "100px",
"top" : "100px"
}, 500);
试试这一件吧,太棒了 下载Min文件 最小文件() 购物车文件() 拉胡尔编辑
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js/jquery.cart.min.js"></script>
<body>
<div id="cart" style="margin-left:80%;">Cart</div>
<div><img src="your image path" class="image" width="194" height="259" /></div>
<div><input type="submit" name="cart" value="Add To Cart" id="adcrt" /></div>
</body>
<script type="text/javascript">
$(document).ready(function(e) {
$('#adcrt').click(function()
{
$('.image').imgMove('#cart',0.8,'150','200');
})
});
</script>
运货马车
$(文档).ready(函数(e){
$('#adcrt')。单击(函数()
{
$('image').imgMove('cart',0.8,'150','200');
})
});
试试这一款。它太棒了
下载Min文件
最小文件()
购物车文件()
拉胡尔编辑
<script type="text/javascript" src="js/jquery-1.9.1.js"></script>
<script type="text/javascript" src="js/jquery.cart.min.js"></script>
<body>
<div id="cart" style="margin-left:80%;">Cart</div>
<div><img src="your image path" class="image" width="194" height="259" /></div>
<div><input type="submit" name="cart" value="Add To Cart" id="adcrt" /></div>
</body>
<script type="text/javascript">
$(document).ready(function(e) {
$('#adcrt').click(function()
{
$('.image').imgMove('#cart',0.8,'150','200');
})
});
</script>
运货马车
$(文档).ready(函数(e){
$('#adcrt')。单击(函数()
{
$('image').imgMove('cart',0.8,'150','200');
})
});