{"action":"created","issue":{"url":"https://api.github.com/repos/craftyjs/Crafty/issues/966","labels_url":"https://api.github.com/repos/craftyjs/Crafty/issues/966/labels{/name}","comments_url":"https://api.github.com/repos/craftyjs/Crafty/issues/966/comments","events_url":"https://api.github.com/repos/craftyjs/Crafty/issues/966/events","html_url":"https://github.com/craftyjs/Crafty/issues/966","id":110882707,"number":966,"title":"Problem with cancelTween()","user":{"login":"neothemachine","id":530988,"avatar_url":"https://avatars.githubusercontent.com/u/530988?v=3","gravatar_id":"","url":"https://api.github.com/users/neothemachine","html_url":"https://github.com/neothemachine","followers_url":"https://api.github.com/users/neothemachine/followers","following_url":"https://api.github.com/users/neothemachine/following{/other_user}","gists_url":"https://api.github.com/users/neothemachine/gists{/gist_id}","starred_url":"https://api.github.com/users/neothemachine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neothemachine/subscriptions","organizations_url":"https://api.github.com/users/neothemachine/orgs","repos_url":"https://api.github.com/users/neothemachine/repos","events_url":"https://api.github.com/users/neothemachine/events{/privacy}","received_events_url":"https://api.github.com/users/neothemachine/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-10-11T21:02:22Z","updated_at":"2015-11-04T19:47:11Z","closed_at":null,"body":"I think I found a bug in the Tween component. I'm using the latest nightly.\r\n\r\nWhat happens is:\r\n- I start a tween of say 1 sec.\r\n- I cancel the tween at 0.5sec.\r\n- I start another tween at 0.7sec.\r\n- The first tween isn't fully cancelled! (e.g. still in .tweens array)\r\n\r\nIt seems the full cancellation happens only after the time the tween would have ended originally. This effect however screws up my game logic since I use tween loops and rely on correct order of these things.\r\n\r\nUnfortunately I don't have a small self-contained example, but maybe it is easy to find the bug without it."},"comment":{"url":"https://api.github.com/repos/craftyjs/Crafty/issues/comments/153843294","html_url":"https://github.com/craftyjs/Crafty/issues/966#issuecomment-153843294","issue_url":"https://api.github.com/repos/craftyjs/Crafty/issues/966","id":153843294,"user":{"login":"neothemachine","id":530988,"avatar_url":"https://avatars.githubusercontent.com/u/530988?v=3","gravatar_id":"","url":"https://api.github.com/users/neothemachine","html_url":"https://github.com/neothemachine","followers_url":"https://api.github.com/users/neothemachine/followers","following_url":"https://api.github.com/users/neothemachine/following{/other_user}","gists_url":"https://api.github.com/users/neothemachine/gists{/gist_id}","starred_url":"https://api.github.com/users/neothemachine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/neothemachine/subscriptions","organizations_url":"https://api.github.com/users/neothemachine/orgs","repos_url":"https://api.github.com/users/neothemachine/repos","events_url":"https://api.github.com/users/neothemachine/events{/privacy}","received_events_url":"https://api.github.com/users/neothemachine/received_events","type":"User","site_admin":false},"created_at":"2015-11-04T19:47:11Z","updated_at":"2015-11-04T19:47:11Z","body":"My problem is when using the TweenEnd event:\r\n```html\r\n<!doctype html>\r\n<html>\r\n<body>\r\n\r\n<div id=\"game\"></div>\r\n\r\n<script src=\"https://rawgit.com/craftyjs/Crafty-Distro/nightlies/crafty.js\"></script>\r\n<script>\r\nCrafty.init(500,500, document.getElementById('game'));\r\n\r\nvar t0 = new Date()\r\nsquare = Crafty.e(\"Color,2D,DOM,Tween\").color(\"Black\").attr({\r\n    x:10,\r\n    y:10,\r\n    h:50,\r\n    w:55\r\n}).bind('TweenEnd', function() {\r\n\tconsole.log(\"end at \" + (new Date()-t0))\r\n}).tween({\r\n    x:100,\r\n    y:100,\r\n    h:100,\r\n    w:100,\r\n},2000);\r\nwindow.setTimeout(()=>{\r\n    square.cancelTween({x:true});\r\n\r\n//should just have the y,h,w tween group\r\n    square.tween({\r\n    x:1000,\r\n    y:0\r\n    },500);\r\n\r\n//x/y should be in one group and w/h still in the original group..\r\n},1000);\r\n</script>\r\n\r\n</body>\r\n</html>\r\n```\r\n\r\nThe console output is:\r\n```\r\nend at 1496\r\nend at 1995\r\n```\r\n\r\nWhereas it should be (ignoring millisecond accuracy):\r\n```\r\nend at 1000\r\nend at 1500\r\n```\r\n\r\nThe TweenEnd of the first tween only gets fired after its original duration passes, not as soon as it is cancelled. I don't think this makes sense, and this is the actual problem which messes up my logic."}}