【发布时间】:2014-04-02 00:43:28
【问题描述】:
目前我有一个简单的圆形标志,当某些 ajax 功能出现时,我还确保这个 div 旋转 360 度。
它确实按我的意愿工作,但它只在触发函数后发生一次,然后我必须重新加载页面才能让它再次工作。
当函数 spin_logo() 被触发时,如何让旋转工作?
旋转功能
function spin_logo(){
var n = 360;
$('.logo').css({
transform:'rotate('+n+'deg)',
'-ms-transform':'rotate('+n+'deg)',
'-moz-transform':'rotate('+n+'deg)',
'-o-transform':'rotate('+n+'deg)',
transition: '1s linear',
'-ms-transition':'1s linear',
'-moz-transition':'1s linear',
'-o-transition':'1s linear'
});
n+=360;
}
轮换用例
spin_logo() 发生在成功函数之后。
$(document).on('click touchstart', '.publish', function(event){
event.preventDefault();
var $this = $(this);
$.ajax({
type: "POST",
url: base_url + "post/publish",
dataType: "text",
data: {
title: $('.title').html(),
sub: $('.sub-title').html(),
txt: $('.editor').html(),
cat_str: $('#cat-drop').val(),
str: window.location.pathname.split('/').pop()
},
cache:false,
success:
function(data){
spin_logo();
$('.response-info').slideToggle(500);
$('.response-info').html(data).fadeIn(500);
setTimeout(function(){
$('.response-info').slideToggle(1000);
}, 10000);
}
});
return false;
});
提前致谢。
【问题讨论】:
标签: jquery css transform css-transitions