我正在尝试使用CSS3过渡动画创建动态创建的html元素.
我希望动画在元素创建之前启动.
对于这些我创建一个类来设置元素的原始位置,然后我通过jquery css()方法设置目标位置
但它刚刚在目标位置上出现的新元素没有任何过渡.
如果我使用0ms的setTimeout来设置它的新css值.
有什么我做错了吗?或者是一种限制?我认为我不应该使用setTimeout解决方法.
谢谢!
更新:这是与jsfiddle.net上运行的代码的链接,供您进行实验. http://jsfiddle.net/blackjid/s9zSH/
更新我已经用答案中的解决方案更新了示例.
http://jsfiddle.net/s9zSH/52/
这是一个完整的示例代码
<html>
<head>
<script src="http://code.jquery.com/jquery-1.4.3.min.js"></script>
<script type="text/javascript">
//Bind click event to the button to duplicate the element
$(".duplicate").live("click", function (e){
var $to = $("#original .square").clone()
$("body").append($to);
if($(e.target).hasClass("timeout"))
//With setTimeout it work
setTimeout(function() {
$to.css("left", 200 + "px");
},0);
else if($(e.target).hasClass("notimeout"))
// These way it doesn't work
$to.css("left", 200 + "px");
});
</script>
<style type="text/css">
.animate{
-webkit-transition: all 1s ease-in;
}
.square{
width:50px; …Run Code Online (Sandbox Code Playgroud) 我有这个终点
/clients/:id
/bills/:id
/clients/:id/bills
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用angular-resource创建一些资源来表示我的API.
我为客户创建了一个资源,
.factory('Clients', function($resource){
return $resource('/clients/:id')
})
.factory('Bills', function($resource){
return $resource('/bills/:id')
});
Run Code Online (Sandbox Code Playgroud)
工作得很好.
我的问题是当我想定义一个资源来表示调用端点的客户端的账单时 /client/:id/bills
我认为这应该是一个带有方法或类似方法的Bills资源getFromClient(),因为它将从客户端返回一个Bills数组.但我已经使用了比尔名称.端点与已定义的端点不同.
知道如何构建这个吗?
当我得到de form的名字时,我正试图从控制器的范围中获取一个表单对象.它工作正常,但如果我使用ng-switch创建表单,表单永远不会显示在范围内.
风景
<body ng-controller="MainCtrl">
<div ng-switch on="type">
<form name="theForm" ng-switch-when="1">
<label>Form 1</label>
<input type="text"/>
</form>
<form name="theForm" ng-switch-when="2">
<label>Form 2</label>
<input type="text"/>
<input type="text"/>
</form>
</div>
<button ng-click="showScope()">Show scope</button>
</body>
Run Code Online (Sandbox Code Playgroud)
控制器
app.controller('MainCtrl', function($scope) {
$scope.type = 1;
$scope.showScope = function(){
console.log($scope);
};
});
Run Code Online (Sandbox Code Playgroud)
如果我删除了ng-switch,我可以从$ scope中看到属性"theForm"作为形式obj.
知道如何做到这一点.我不希望这两个表单具有不同的名称并使用ng-show.
以下是"不工作" http://plnkr.co/edit/CnfLb6?p=preview的示例
我试图理解为什么即使在周期性任务执行的25秒限制之后也会调用NotifyComplete()方法.
据我所知,如果在25秒内没有调用notifyComplete(),则该任务将被终止,但这不是正在发生的事情.60秒后仍会调用NotifyComplete().
protected override void OnInvoke(ScheduledTask task)
{
Thread.Sleep(60000); // 60 Seconds
NotifyComplete();
}
Run Code Online (Sandbox Code Playgroud)
任何想法?,我在某种程度上误解后台代理的工作方式?谢谢!
我有这样的 json 响应
{ latitude: 30.4848, longitude: -70.5484 }
Run Code Online (Sandbox Code Playgroud)
现在我这样做是为了用 newtonsoft JSON.NET 反序列化
JsonConvert.DeserializeObject<Test>(json);
Run Code Online (Sandbox Code Playgroud)
并反序列化为
[JsonObject(MemberSerialization.OptIn)]
public class Test
{
[JsonProperty(PropertyName = "longitude")]
public double Longitude{ get; set; }
[JsonProperty(PropertyName = "latitude")]
public double Latitude { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我想将纬度和经度反序列化为 GeoCoordinate 对象的经度和纬度属性
public class Test
{
public GeoCoordinate Location{ get; set; }
}
Run Code Online (Sandbox Code Playgroud)