-
23 Nov 2012 12:31 AM #1
Answered: setScrollable(false) refreshes List. How to prevent?
Answered: setScrollable(false) refreshes List. How to prevent?
I am trying to create a List re-ordering functionality by dragging list items around. It works perfectly. I disable list scrolling on dragstart event and enable scrolling on dragend event.
However, the problem comes while there is more items in a list and it requires scrolling. While I scroll down to say 20th Item, while starting dragging again the list scrolls to top. I am not refreshing list anywhere and found out the issue is mostly coming for setScrollable(false) function. Here is my dragstart code:
I have to stop scrolling at dragstart event anyway to drag items properly. Any idea how to prevent list scroll-to-top function?Code:onDragStart : function(draggable, e, offsetX, offsetY){ this.deselectAll(); this.setScrollable(false); // This line causes list scroll to top every time this.dragEl = draggable.getElement(); this.calculateBoxes(); draggable.getElement().toMoveIndex = draggable.getElement().index; }
Here is how the functionality looks. I have also attached source code for all the necessary files. You can test yourself and provide suggestions.
list-drag.pngSwarnendu
Co-founder & Lead Architect @ Innofied
------------------
I blog at http://www.swarnendude.com
-
Best Answer Posted by hadukiCode:
... //this.setScrollable(false); var scrollview=this.getScrollable(); if(scrollview){ scrollview.getScroller().setDisabled(true); } ...
-
23 Nov 2012 1:43 AM #2
Code:... //this.setScrollable(false); var scrollview=this.getScrollable(); if(scrollview){ scrollview.getScroller().setDisabled(true); } ...Last edited by haduki; 23 Nov 2012 at 2:44 AM. Reason: misspelling
I write English by translator.
-
23 Nov 2012 1:59 AM #3
Great. It worked fine. However, please change the variable name"scrollerview" to "scrollview" inside if condition.
Swarnendu
Co-founder & Lead Architect @ Innofied
------------------
I blog at http://www.swarnendude.com
-
23 Nov 2012 7:37 AM #4
Hello,
I have an error with "calculateBoxes" function.
Could you share a full working exemple.
Thanks.
-
10 Apr 2013 6:11 AM #5
Issue with Sencha Touch 2.0
Issue with Sencha Touch 2.0
Hello Swarnendu,
I am using your code for reordering list cell and facing issue in following function:-
createDraggables : function(list,eOpts){
var me = this, draggableItem, index = 0;
// Create draggable component for each list item
Ext.each(list.element.query(this.getSelector()), function(item){
/**Uncaught TypeError: Cannot call method 'query' of undefined*/
item = Ext.get(item);
// Add an index to each draggable item for moving around
item.index = index++;
// If the element is already draggable, skip it
if(item.hasCls('x-draggable')){
return;
}
Ext.create('Ext.ux.util.Draggable', {
element : item,
threshold: 0,
revert: true,
revertDuration : 0,
direction : 'vertical',
constraint : {
min: {
x: -Infinity,
y: -Infinity
},
max: {
x: Infinity,
y: Infinity
}
},
listeners : {
scope: me,
dragstart: me.onDragStart,
dragend: me.onDragEnd,
drag : me.onDrag,
order: 'before'
}
});
}, this);
},
Please reply as early as possible.
Thanks in advance



Reply With Quote