PDA

View Full Version : calling scrollTo causes error.



omulriain
28 Sep 2010, 8:11 AM
I am attempting to scroll a panel within a carousel. It works but I am getting an error. Is there something the carousel needs or something I can pass in to illiminate this. I can catch the error and everything works but I don't want to have any errors.

the culprit is newCard.scroller._scrollTo(oldCard.scroller.offset,1,'easingOutStrong'); as seen below.
my listener.



var timeline1 = new Ext.Component({
title: 'Timeline',
cls: 'timeline',
scroll: 'vertical',
tpl: [
'<table width="100%" border="1">',
'<tpl for=".">',
'<tr>',
'<td>{col1}</td>',
'<td>{col2}</td>',
'<td>{col3}</td>',
'<td>{col4}</td>',
'</tr>',
'</tpl>',
'</table>'
]
});
//timeline2 and timeline3 same as timeline1

var tableCarousel = new Ext.Carousel({
iconCls: 'bookmarks',
cls: 'card card2',
title: 'Guide',
ui: 'light',
monitorOrientation: 'true',
listeners: {
cardswitch: function(container, newCard, oldCard){
newCard.scroller.offset = oldCard.scroller.offset;
newCard.scroller._scrollTo(oldCard.scroller.offset,1,'easingOutStrong');

}

}
,items: [timeline1,timeline2,timeline3]

});


I am getting the following error:


Uncaught TypeError: Cannot read property 'y' of undefined
scrollToext-touch-debug.js:12651
_scrollToext-touch-debug.js:12196
tableCarousel.Ext.Carousel.listeners.cardswitchindex.js:370
fireext-touch-debug.js:940
fireEventext-touch-debug.js:569
onCardSwitchext-touch-debug.js:16349
onCardSwitchext-touch-debug.js:19144
onTransitionEndext-touch-debug.js:19135
anonymous:5
(anonymous function)ext-touch-debug.js:3253

omulriain
28 Sep 2010, 8:56 AM
I tracked down the error but don't know how to fix it. the API is looking for scroller.bouncing.y which throws an error because it cant find scroller.bouncing so the line if{scroller.bouncing.y} throws a hard error. Is this a known issue? Should I be doing something different? The listener I posted is the only thing that has worked so far. My workaround is to catch the error, because the procedure does scroll the content. Swallowing errors is not a good idea though so I obviously want to figure out how to do this the preferred way.

I have tried several variations of the call including
newCard.scroller._scrollTo(oldCard.scroller.offset,1,'linear')
newCard.scroller._scrollTo(oldCard.scroller.offset,0,null)
newCard.scroller._scrollTo(oldCard.scroller.offset,null,null)
newCard.scroller._scrollTo(oldCard.scroller.offset,1)
newCard.scroller._scrollTo(oldCard.scroller.offset)


the error is occuring in ext-touch-debug.js:12651 in function scrollTo:function(pos,animate,easing) at the line else{
if(scroller.bouncing.y)

djkraz
28 Sep 2010, 11:18 AM
I have been having the exact same issue for quite a while now when calling scrollTo from a JSONP callback function. Instead of trapping it, i just added the bouncing.y parameter like so: "x.scroller.bouncing = { x: 0, y: 0 }" before calling the scrollTo function on the panel (x).

I don't like it either but for now it's the best I could come up with and probably better than letting the error happen even if you are trapping it. I know this has been an issue since 0.93 for sure and most likely older versions as well but I can't confirm prior to 0.93.

omulriain
28 Sep 2010, 11:22 AM
That fixed it. I was trying to set newCard.scroller.bouncing.y and that wasn't working. Thanks for the reply. One of us should submit a bug if it isn't already reported.

djkraz
28 Sep 2010, 11:28 AM
I thought about it but I haven't had a chance to learn the "rules" of the bug system yet so I haven't reported them. The last time I posted here about a bug one of the developers created a bug ticket for me. Please do so if you are comfortable with it..

evant
28 Sep 2010, 2:51 PM
It's already been fixed I believe, try 0.96.

djkraz
29 Sep 2010, 5:40 AM
I'm not sure how I can try 0.96... It's not in the release notes on the forum and when I download from the site I still get 0.95...