-
30 Sep 2010 2:20 PM #1
[INVALID-373] Animation callback scope set to config object instead of config.scope
[INVALID-373] Animation callback scope set to config object instead of config.scope
Sencha Touch version tested:
- 0.96
Platform tested against:- iOS 3.x
- iOS 4
- Android 2.1
- Android 2.2
Description:- In the onTransitionEnd callback function (ext-touch-debug.js line 10276 v .96), the scope for the "after" config callback function is being set to the actual config object instead of the config.scope (line 10303). I can't imagine why the callback scope would be set to the actual config object? if you pass a config with an 'after' callback and scope to the config of run() method, the scope is correctly set:
Description:Code:var opts2 = { scope: { 'test': 'test'}, after: function() { console.log(this); } }; new Ext.Anim(opts).run(el, opts2);
Code to reproduce:Code:... if (me.config.after) { me.config.after.call(config, el, config); } if (o.after) { o.after.call(config.scope || me, el, config); } ...
Possible fix:Code:var el = Ext.getBody().createChild({ style: 'background-color: red; width: 20px; height: 20px; top:150px; position:absolute; opacity: 0.0001;' }); var opts = { scope: { 'test': 'test' }, autoClear: false, before: function(el){ this.to = { 'opacity': '1' }; }, after: function() { console.log('Anim callback'); console.log(this); } }; var opts2 = { scope: { 'test': 'scope from run config' }, after: function() { console.log('run callback'); console.log(this); } }; new Ext.Anim(opts).run(el, opts2);
Additional Question:Code:... if (me.config.after) { me.config.after.call(config.scope || me, el, config); } if (o.after) { o.after.call(config.scope || me, el, config); } ...
Why are there 2 places you can set the callback for an animation?
Is there a preferred place to put the callback?
-
30 Sep 2010 4:08 PM #2
Thanks for the bug report. The team is reviewing your suggestion and they will let you know what they decide.
-
30 Sep 2010 8:27 PM #3
Though I didn't write this code, I think I can see the intent. Also note that the same applies for before as well.
The before/after for the anim are about setting up any initial values on the animation itself, for example if you look at one of the preset animations, you see it's setting the from/to for the animation to actually do anything. The before/after on the config are intended for any ~other~ things, for example if you wanted to chain events or do something once the animation has finished.
I think it's more a documentation issue that needs to be cleared up, because the intent is definitely to set the scope to the animation for both of the before/after on the anim.Evan Trimboli
Sencha Developer
Twitter - @evantrimboli
Don't be afraid of the source code!
-
18 Oct 2010 5:54 PM #4Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
I'm not sure why this is written this way, but are you seeing an actual bug? Adding scope works correctly for your before/after callback functions.
Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
-
28 Oct 2010 1:56 PM #5Sencha - Community Support Team
- Join Date
- Jan 2009
- Location
- Palo Alto, California
- Posts
- 1,941
- Vote Rating
- 6
Closed this as no actual bug appears to be present.
Ext JS Senior Software Architect
Personal Blog: http://edspencer.net
Twitter: http://twitter.com/edspencer
Github: http://github.com/edspencer
Thank you for reporting this bug. We will make it our priority to review this report.
Similar Threads
-
Where to set transition type in setCard with anim config object?
By Bucs in forum Sencha Touch 1.x: DiscussionReplies: 2Last Post: 24 Sep 2010, 5:19 AM -
[SOLVED] Scope problem in Ext.Window config
By caerolus in forum Ext 2.x: Help & DiscussionReplies: 4Last Post: 8 Aug 2008, 10:43 AM -
callback function and scope
By dddu88 in forum Ext 2.x: Help & DiscussionReplies: 10Last Post: 18 Nov 2007, 11:11 AM -
How to keep scope in selectPath callback?
By mherger in forum Ext 1.x: Help & DiscussionReplies: 5Last Post: 8 Aug 2007, 11:33 PM


Reply With Quote