deckgl = {
var ini_zoom_mode = 'Y'
let globalViewState = ({
'matrix': ({
target: [500, 500, 0],
zoom: [-1, -1]
}),
'rows': ({
target: [500, 500, 0],
zoom: [-1, -1]
}),
'cols': ({
target: [500, 500, 0],
zoom: [-1, -1]
})
})
const instance = new deck.DeckGL({
container,
views,
initialViewState: globalViewState,
// if (viewId === 'matrix') {
// // console.log('matrix')
// viewState.matrix = viewState;
// viewState.rows = viewState;
// viewState.cols = viewState;
// // // trying to set the target of the rows
// // viewState.rows.zoom = [0, 0]
// } else if (viewId === 'rows') {
// // console.log('rows')
// viewState.matrix = viewState;
// viewState.rows = viewState;
// viewState.cols = viewState;
// } else if (viewId === 'cols'){
// // console.log('cols')
// viewState.matrix = viewState;
// viewState.rows = viewState;
// viewState.cols = viewState;
// }
// // Update deck
// instance.setProps({viewState: {...viewState}});
// }
onViewStateChange: ({viewState, viewId}) => {
// mutable update_count = update_count + 1
// console.log(viewState, viewId)
// // Extract the pan and zoom values from the viewState object
// const {zoom, target, offset} = viewState;
// const {x, y} = offset || {x: 0, y: 0};
// // const {panX, panY} = viewState[viewId];
// const {panX, panY} = viewState[viewId];
// Extract the pan and zoom values from the viewState object
const {zoom, target} = viewState;
// const {x, y} = offset || {x: 0, y: 0};
console.log(viewState)
// Check that viewState[viewId] exists before extracting panX and panY
const {panX, panY} = viewState[viewId] || {panX: 0, panY: 0};
if (viewId === 'matrix') {
// // Update row and column views to move in the appropriate X and Y directions
// globalViewState = {
// ...globalViewState,
// row: {...globalViewState.row, panY},
// column: {...globalViewState.column, panX},
// };
globalViewState = {
matrix: viewState,
rows: viewState,
cols: viewState,
}
}
// } else {
// // // Update matrix view to move in the appropriate X or Y direction
// // const newTarget = [
// // viewId === 'row' ? target[0] : target[0] + panX,
// // viewId === 'column' ? target[1] : target[1] + panY,
// // target[2],
// // ];
// // globalViewState = {
// // ...globalViewState,
// // matrix: {...globalViewState.matrix, target: newTarget},
// // };
// globalViewState = {
// matrix: viewState,
// rows: viewState,
// cols: viewState,
// }
// }
else if (viewId === 'rows') {
globalViewState = {
matrix: viewState,
rows: {zoom: viewState.zoom, target: [0, 0]},
cols: viewState,
}
} else if (viewId === 'cols') {
globalViewState = {
matrix: viewState,
rows: viewState,
cols: viewState,
}
}
// Update deck with the new global view state
instance.setProps({viewState: {...globalViewState}});
},
})
return instance;
}