Swipe in openlayers with group layers - controls

I'm using the example https://viglino.github.io/ol-ext/examples/control/map.control.swipe.html to create my swipe and it worked. However, I want to use a group of layers to choose which one to show, as per the code below.
var swipe_control = new ol.control.Swipe();
// Group of layers - menu
var overlays = new ol.layer.Group({
title: 'Maps',
fold: 'open',
layers: [
new ol.layer.Group({
title: 'Group 1',
fold: 'open',
layers: [
swipe_control.addLayer(layer1),
swipe_control.addLayer(layer2, true)
]
}),
new ol.layer.Group({
title: 'Group 2',
fold: 'open',
layers: [
swipe_control.addLayer(layer3),
swipe_control.addLayer(layer4, true)
]
})
]
});
map.addControl(swipe_control);
My question is: how to use swipe in the group, so that, if I check an option, I set the layer on the right and left? Thanks

Swipe only applies to the layer itself not on a layer group.
Layers inside the layer group must be added/removed from the control when you check the option.

Related

How to Unmount a screen when moving to another in React Native

I'm developing a React Native app using React Navigation v4, React Hooks and ES6.
I have 2 bottom tabs (Movies, Shows) and 4 screens with the following Stack structure:
**Movies**
-- MovieList
-- MovieDetail
**Shows**
-- ShowList
-- ShowDetail
My scenario
1) Moving from Movie list to an individual movie page
MovieList contains a list of movies, when I click on one of them, I first fetch some API data then move to the MovieDetail screen like this
dispatch(apiFetchActions.fetchMovies(movieId)).then((response) => {
props.navigation.navigate({
routeName: "MovieDetail",
params: {
assetId: movieId,
assetName: movieTitle,
},
});
MovieDetail is now on top of the Movies stack and MovieList at the bottom
2) Moving to a different tab (navigation stack)
I then click on Shows (2nd Tab) which takes me to the ShowList using props.navigation.navigate('ShowList')
3) The problem
If I click on the Movies Tab, I expect to be moved back to MovieList but since MovieDetail was never unmounted, it is still at the top of the Movies stack meaning that I see an old screen. I have to click twice to go back to the MovieList screen.
I've read quite a few suggestions on how to use onFocus/onBlur subscription however I could not found a solution using React Hooks.
My ideal solution would be to find a way to listen to the onBlur status in MovieDetail screen possibly using useEffect hook and somehow unmount it before leaving.
I found a way to make it easier to always move to the initial top of the stack when you click on any bottom tab icons.
You simply need to add the on Press and the screen reference like this
Stars: {
screen: StarsNavigator,
navigationOptions: ({ navigation }) => ({
tabBarIcon: (tabInfo) => {
return (
<Ionicons name="ios-people" size={22} color={tabInfo.tintColor} />
);
},
tabBarLabel: Platform.OS === "android" ? <Text>Stars</Text> : "Stars",
tabBarOnPress: () => {
navigation.navigate("StarsList");
},
}),
},
Star is one of my screens in BottomTabNavigator and using navigation.navigate("You Screen") does the trick. So regardless in which level of the stack you find yourself, every time you click on the Star tab you always end up to the original top level.

Stack two Sencha Ext.Lists vertically

I want to stack two Sencha Touch Ext.List's vertically. I want both of these lists to belong to a container that is scrollable. The problem I'm having is that I'm not sure how I can configure these lists to be fully expanded components (the containing container should take care of the scrolling).
I.e. you would have to scroll down the entire contents of the first list to get to the second list.
Additionally, the containing container should also be possible to fill with other stacked components, such as a form.
Example:
-> Container (should show scroll bars if contained content doesn't fit in the container)
-> Form (should not show any scrollbars, thus fully expanded)
-> List (should not show any scrollbars, thus fully expanded)
-> List (should not show any scrollbars, thus fully expanded)
UPDATE
I've managed to get something working by setting scrollable to null for the lists. However, it only works with Sencha Touch versions prior to 2.1.0, thus 2.0.1 works fine.
var mainPanel = Ext.create("Ext.Container",
{
fullscreen: true,
layout: 'vbox'
});
var subPanel = Ext.create("Ext.Container", {
flex: 1,
layout: 'vbox'
});
Ext.define('MyList', {
extend: 'Ext.List',
config: {
scrollable: null,
fullscreen: false
}
});
var itemName = 'MyItem';
Ext.define(itemName, {
extend: 'Ext.data.Model',
config: {
fields: ["title"]
}
});
var store = Ext.create('Ext.data.Store', {
model: itemName,
data: [
{ title: 'row1' },
{ title: 'row2' }
]
});
var list1 = Ext.create('MyList');
list1.setItemTpl('<div>List 1 - {title}</div>');
list1.setStore(store);
var list2 = Ext.create('MyList');
list2.setItemTpl('<div>List 2 - {title}</div>');
list2.setStore(store);
subPanel.add(list1);
subPanel.add(list2);
mainPanel.add(subPanel);
Ext.Viewport.add(mainPanel);
Any ideas why it's not working in 2.1.0+?
Have you tried setting the scrollable config of the lists to false?
I recommend extending Ext.dataview.DataView rather than starting from Ext.dataview.List. You will have to build up some of your own styling, but I've found that's usually easier than trying to remove unwanted functionality from Ext.List.

Kendo Grid - Edit mode when templated column is clicked

I am using a template for the edit popup. I am trying to force the grid to go into edit mode and show the edit template popup when a link within one of the columns is clicked.
I tried using a command but I am unable to data bind the hyperlink's text to a field declared in the model, in this case to 'CourseType'. Is data binding supported within command columns?
columns: [
{
command: [
{
id: "edit",
title: "School Item",
template: '#=CourseType#',
width: 120
}
]
}
]
If data binding is not supported within a command column, then how do I put the grid into edit mode when the templated field is clicked?
columns: [
{
field: "CourseType",
title: "School Item",
template: '#=CourseType#'
}
]
I'm not sure why do you want to define the cell as an HTML anchor but there is no problem on making it enter on popup edit mode when clicking on the anchor.
1) Add to your template a class that would allow us to find those cells. Something like:
columns: [
{
field: "CourseType",
title: "School Item",
template: '#=CourseType#'
}
]
where I have include class="ob-edit-popup" to the template.
2) add to your grid definition the option editable: "popup".
3) add the following JavaScript code after the initialization.
$(".ob-edit-popup", grid.tbody).on("click", function (e) {
var row = $(this).closest("tr");
grid.editRow(row);
})
Where grid is the result of:
var grid = $("#grid").kendoGrid({...}).data("kendoGrid");

extjs adding form contents to another form

I have 2 forms,
var f1 = new Ext.form.FormPanel({
items: [{ xtype: 'label', text: 'form1'}]
});
var f2 = new Ext.form.FormPanel({
items: [{ xtype: 'label', text: 'form2'}]
});
I want to send form1 's items to form2 so that i only need 1 submit call. Is there any way to do that?
Keep only One submit button and add these two panels by using card or border layout.
On click of submit you collect all the details and if any validation needed do in Submit button click handler and go ahead.
I don't think its so difficult.
Have a look on layout examples and how to add forms as items.

Sencha Touch 2: auto center item in list after scrolling

I'm trying to implement a carousel (or tabs with srcoll) in a similar fashion to the http://zite.com/ application. The main goal is to implement autocentered scrolling of closest to the center item after the scroll end.
Do you have any ideas?
Of course, if you want centered a Ext.Carousel into main Ext.Panel write something like this,
new Ext.Panel({
fullscreen: true,
...
layout: {
type: 'vbox',
align: 'center',
pack: 'center'
},
items: [
new Ext.Carousel({
...
})
]
})
and have fun Carousel centered. I hope this helps. :)
Didn't find any other way than calculating the center manually in the scroll end event and scroll to it.

Resources