Nested React Native Flatlist styling - react-native-flatlist

I'm using nested flatlist in my app. In first flatlist there are array of titles and in second flatlist there are array of items. Now, I'm trying to display the first flatlist title to be visible until all the items of the second flatlist get scrolled. For eg.
first flatlist item ['nuts', 'cashews', 'drynuts', etc];
second flatlist items [[{}, {}, {}, {}, {}], [{}, {}, {}, {}, {}], [{}, {}, {}, {}, {}]]

If I understand your question correctly, I would suggest you using SectionList: https://reactnative.dev/docs/sectionlist
Previously formatted your data

Related

Rails Masonry elements overlapping after an AJAX call

My masonry transitions works well on first load.
However, when I make an AJAX call to retrieve new items, the old elements remains the same position, but the new items are aligned vertically from top to bottom.
It works well on the first load.
After an AJAX call, the new items are aligned vertically
my index.html.haml
.masonry-container.transitions-enabled
= render 'masonry_container', items: #items
_masonry_container.html.haml
- items.each do |item|
#i guess the code here is not important as i generate each image box succesfully
index.js.erb
$(".masonry-container").imagesLoaded(function(){
$(".masonry-container").append("<%= j render 'masonry_container',
items: #items %>").masonry('appended', "<%= j render
'masonry_container', items: #items %>", 'reloadItems');
});
Would appreciate if you could offer some helps.
Because things are changing and Masonry doesn't know about it, you probably need to have it run again after the changes.
https://masonry.desandro.com/methods.html#layout-masonry
Lays out all item elements. layout is useful when an item has changed size, and all items need to be laid out again.
But maybe you want to have Masonry be part of the process, so it has full knowledge of what's happening, instead of forcing it:
https://masonry.desandro.com/methods.html#adding-removing-items

jQuery UI sortable with dynamic "connectWith" option

I'm developing a page with 3 tables. On the 3rd table i have the rows that could be sorted and dropped on the 1st or 2nd table.
Is there a way I can define dynamically if a specific row can or can't be dropped on one of the other 2 tables? A sort of dynamized "connectWith" option...or any other way...
You can define the rows of the third table using the .draggable() method of jQuery UI.
Calling the draggable method, you can specify where the elements can be dropped.
Then on drag of the tr, hide the current tr from the current table (the third one).
On drop of the tr, get the table where you dropped the tr and add really the tr, really removing the row from the third table.
It's better that at the beginning you don't remove immediately the row from the third table, because if the drag event is not fine (for example I drop in a wrong place) you can show again the row.
Here a link to jQuery UI draggable method:
https://jqueryui.com/draggable/
A POC of code:
$( "#third-table tr" ).draggable({
snap: ".drop-tables",
start: function() {
// hide the row from the third table
},
stop: function() {
// add the row to the target table
// remove the row from the third table
}
});

jQuery Sortable, clone and appendTo, helper disappearing

Question is that the clone helper on jQuery Sortable is not showing itself with the following settings:-
$('#sortable').sortable({
items: "li",
helper: "clone",
appendTo: "body",
placeholder: "ui-state-highlight"
});
Essentially, the placeholder is being shown, but the actual helper cloned element is not.
appendTo and helper are necessary because without the helper and appendTo, when I seek to drag the LI element, the li element will sometimes disappear and be deleted when dropped.
I can confirm there is no overflow css on the parent <ul> and that the disappearing <li> also happens when appendTo is set to parent. Containment did not prevent the <li> from disappearing.
I am using jQuery UI 1.10.2. Anyone konw how to address this?
EDIT: To be clear, I've identified that the item is disappearing into a child sortable, because there are intersecting divs in the list structure containing child sortable elements.
Is it possible to reject an LI element with a certain class from a sortable? Whats happening is that the LI is dropping into the child sortable even though it has no connectWith The LI needs to only be sortable inside its parent sortable and not try to insert itself in a child sortable (they even have separate ids and separate classes so not sure why this is happening).
Partial Solution:
stop: function(event, ui){
if(ui.item.parent().attr('id') !== 'sortable'){
$("#sortable").sortable("cancel");
}
},
If anyone has a better solution, please do let me know.

How to make jQuery UI sortable with nested dropdown menu work?

I've read everything similar to my problem posted here but not found any solution.
I have created a menu with sub menu entries inside dropdowns. All menu entries are sortable to all menu levels. root menu entries to child lists and the other way.
Nearly everything works fine but sorting to the first dropdown results a bug. It is neighter not possible to sort a menu entry before the first dropdown nor to sort inside the first dropdown. By trying to sort inside the first dropdown the placeholder code spawn inside the neighbor (last) dropdown and on stop sorting the entry also is inside the last dropdown and not inside the first like it should. Sorting to the other dropdowns does not have this behavior. Maybe anybody has an idea about it?
Here is the js-fiddle:
http://jsfiddle.net/dehil/Vy4pu/1/
$('ul').sortable({ //
connectWith: $('ul'),
items: 'li',
placeholder: 'pf_sortable-placeholder',
tolerance: 'pointer',
cursor: 'pointer',
cursorAt: {
top: -20
},
zIndex: 20000,
placeholder: 'pf_sortable-placeholder',
})
Nested lists are always a bit awkward with jQuery UI. Recently I found http://johnny.github.com/jquery-sortable/ which may be used to sort bootstrap navs.
See http://johnny.github.com/jquery-sortable/#bootstrap.

Sortable, draggable, lovable, squeezable, huggable

I have an unordered list that needs to be sortable, so
$('#myID ul').sortable({ placeholder: 'ui-state-highlight' });
works. Now, the problem is that the user also wants to be able to drag the elements...
I don't think I can have it sortable, AND do
$('#myID li').draggable({
revert: 'invalid',
})
Can I?

Resources