Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

fix conditional styling, close modal on orientation change, reposition embed mobile anim minimized

Ed Platoc5b48af79f20
diff --git a/web/css/embed.css b/web/css/embed.css
index 68a81e0b9..dc17f3ba1 100644
--- a/web/css/embed.css
+++ b/web/css/embed.css
@@ -202,3 +202,9 @@
}
}
}
+
+/* MODAL (outside of main page #app ) */
+.modal-embed .modal-content {
+ transform: scale(0.85);
+ transform-origin: left;
+}
diff --git a/web/js/containers/map-interactions/ol-vector-interactions.js b/web/js/containers/map-interactions/ol-vector-interactions.js
index 504a268c5..496ccdbc7 100644
--- a/web/js/containers/map-interactions/ol-vector-interactions.js
+++ b/web/js/containers/map-interactions/ol-vector-interactions.js
@@ -69,9 +69,9 @@ export class VectorInteractions extends React.Component {
singleClick(e, map) {
const {
- lastSelected, openVectorDialog, onCloseModal, selectVectorFeatures,
- modalState, getDialogObject, measureIsActive, isMobile, activeLayers,
- activateVectorAlert, proj,
+ browser, lastSelected, openVectorDialog, onCloseModal, selectVectorFeatures,
+ modalState, getDialogObject, measureIsActive, activeLayers,
+ activateVectorAlert, proj, isEmbedModeActive,
} = this.props;
if (measureIsActive) return;
@@ -90,7 +90,7 @@ export class VectorInteractions extends React.Component {
}
if (metaArray.length) {
- openVectorDialog(dialogId, metaArray, offsetLeft, offsetTop, isMobile);
+ openVectorDialog(dialogId, metaArray, offsetLeft, offsetTop, browser, isEmbedModeActive);
} else {
const mapRes = map.getView().getResolution();
const hasNonClickableVectorLayerType = hasNonClickableVectorLayer(activeLayers, mapRes, proj.id);
@@ -114,7 +114,7 @@ export class VectorInteractions extends React.Component {
function mapStateToProps(state) {
const {
- modal, map, measure, vectorStyles, browser, compare, proj, ui,
+ modal, map, measure, vectorStyles, browser, compare, proj, ui, embed,
} = state;
let swipeOffset;
const activeLayers = getActiveLayers(state);
@@ -124,19 +124,22 @@ function mapStateToProps(state) {
}
return {
- modalState: modal,
- isShowingClick: map.isClickable,
- isDistractionFreeModeActive: ui.isDistractionFreeModeActive,
+ activeLayers,
+ browser,
+ compareState: compare,
getDialogObject: (pixels, olMap) => onMapClickGetVectorFeatures(pixels, olMap, state, swipeOffset),
+ isDistractionFreeModeActive: ui.isDistractionFreeModeActive,
+ isEmbedModeActive: embed.isEmbedModeActive,
+ isShowingClick: map.isClickable,
lastSelected: vectorStyles.selected,
measureIsActive: measure.isActive,
- isMobile: browser.lessThan.medium,
- compareState: compare,
- swipeOffset,
+ modalState: modal,
proj,
- activeLayers,
+ swipeOffset,
};
-} const mapDispatchToProps = (dispatch) => ({
+}
+
+const mapDispatchToProps = (dispatch) => ({
selectVectorFeatures: (features) => {
setTimeout(() => {
dispatch(selectVectorFeaturesActionCreator(features));
@@ -152,8 +155,11 @@ function mapStateToProps(state) {
dispatch(onClose());
},
activateVectorAlert: () => dispatch({ type: ACTIVATE_VECTOR_ALERT }),
- openVectorDialog: (dialogId, metaArray, offsetLeft, offsetTop, isMobile) => {
+ openVectorDialog: (dialogId, metaArray, offsetLeft, offsetTop, browser, isEmbedModeActive) => {
+ const { screenHeight, screenWidth } = browser;
+ const isMobile = browser.lessThan.medium;
const dialogKey = new Date().getUTCMilliseconds();
+ const modalClassName = isEmbedModeActive && !isMobile ? 'vector-modal light modal-embed' : 'vector-modal light';
dispatch(openCustomContent(dialogId,
{
backdrop: false,
@@ -161,15 +167,15 @@ function mapStateToProps(state) {
desktopOnly: false,
isDraggable: !isMobile,
wrapClassName: 'vector-modal-wrap',
- modalClassName: 'vector-modal light',
+ modalClassName,
CompletelyCustomModal: vectorDialog,
isResizable: !isMobile,
dragHandle: '.modal-header',
dialogKey,
key: dialogKey,
vectorMetaObject: lodashGroupBy(metaArray, 'id'),
- width: isMobile ? 320 : 445,
- height: 300,
+ width: isMobile ? screenWidth : 445,
+ height: isMobile ? screenHeight : 300,
offsetLeft: isMobile ? 0 : offsetLeft,
offsetTop: isMobile ? 40 : offsetTop,
timeout: 0,
@@ -191,13 +197,14 @@ VectorInteractions.propTypes = {
onCloseModal: PropTypes.func.isRequired,
openVectorDialog: PropTypes.func.isRequired,
selectVectorFeatures: PropTypes.func.isRequired,
+ activateVectorAlert: PropTypes.func,
+ activeLayers: PropTypes.array,
+ browser: PropTypes.object,
compareState: PropTypes.object,
- isMobile: PropTypes.bool,
+ isEmbedModeActive: PropTypes.bool,
lastSelected: PropTypes.object,
proj: PropTypes.object,
swipeOffset: PropTypes.number,
- activeLayers: PropTypes.array,
- activateVectorAlert: PropTypes.func,
};
export default connect(
diff --git a/web/js/containers/modal.js b/web/js/containers/modal.js
index 3fd11a31e..03592a6f0 100644
--- a/web/js/containers/modal.js
+++ b/web/js/containers/modal.js
@@ -36,12 +36,13 @@ class ModalContainer extends Component {
this.onResize = this.onResize.bind(this);
}
- componentDidUpdate() {
+ componentDidUpdate(prevProps) {
const {
isCustom,
id,
isOpen,
customProps,
+ orientation,
isMobile,
} = this.props;
// Populate props from custom obj
@@ -52,33 +53,23 @@ class ModalContainer extends Component {
desktopOnly,
} = newProps;
+ const orientationChanged = orientation !== prevProps.orientation;
const toggleFunction = toggleWithClose(onToggle, onClose, isOpen);
- if (isMobile && isOpen && desktopOnly) {
+ if ((isMobile && isOpen) && (desktopOnly || orientationChanged)) {
toggleFunction();
}
}
getStyle() {
const {
- isEmbedModeActive, screenHeight, screenWidth, isMobile,
+ isMobile,
} = this.props;
const {
offsetLeft, offsetRight, offsetTop, width, height,
} = this.state;
- const top = (isMobile || isEmbedModeActive) && height ? screenHeight - height : offsetTop;
- if (isEmbedModeActive) {
- return {
- left: 10,
- top,
- width: screenWidth - 10,
- height,
- maxHeight: height,
- transform: 'scale(0.75)',
- transformOrigin: 'left',
- };
- }
-
+ const top = isMobile ? 0 : offsetTop;
+ const margin = isMobile ? 0 : '0.5rem';
return {
left: offsetLeft,
right: offsetRight,
@@ -86,6 +77,7 @@ class ModalContainer extends Component {
width,
height,
maxHeight: height,
+ margin,
};
}
@@ -263,22 +255,22 @@ function mapStateToProps(state) {
bodyTemplate = state[template];
isTemplateModal = true;
}
- const { screenHeight, screenWidth, lessThan } = browser;
+ const { screenHeight, lessThan, orientation } = browser;
const isMobile = lessThan.medium;
const { isEmbedModeActive } = embed;
return {
- isOpen,
+ bodyTemplate,
bodyText,
+ customProps,
headerText,
- isCustom,
id,
+ isCustom,
isEmbedModeActive,
isMobile,
- screenHeight,
- screenWidth,
- bodyTemplate,
+ isOpen,
isTemplateModal,
- customProps,
+ orientation,
+ screenHeight,
};
}
const mapDispatchToProps = (dispatch) => ({
@@ -291,9 +283,11 @@ export default connect(
mapStateToProps,
mapDispatchToProps,
)(ModalContainer);
+
ModalContainer.defaultProps = {
customProps: {},
};
+
ModalContainer.propTypes = {
bodyTemplate: PropTypes.object,
customProps: PropTypes.object,
@@ -304,6 +298,6 @@ ModalContainer.propTypes = {
isMobile: PropTypes.bool,
isOpen: PropTypes.bool,
isTemplateModal: PropTypes.bool,
+ orientation: PropTypes.string,
screenHeight: PropTypes.number,
- screenWidth: PropTypes.number,
};