Mobile adjustments

This commit is contained in:
Edin Dazdarevic
2017-04-14 02:00:38 +02:00
parent 1c133d21bc
commit 7c40035f6f
5 changed files with 110 additions and 19 deletions

View File

@@ -49,8 +49,16 @@ const setMaxSize = ({type, action}, component) => {
})
}
const getScrollElem = (component) => {
const {mobileView} = component.state
const scrollElem = mobileView === 'LIST' ?
document.querySelector('.map-list-view') : document.querySelector('.right-content')
return scrollElem
}
const viewListingDetails = ({type, action}, component) => {
const scrollElem = document.querySelector('.right-content')
const scrollElem = getScrollElem(component)
component.savedScrollTop = scrollElem.scrollTop
component.setState(
@@ -224,7 +232,8 @@ const backToResults = ({type, action}, component) => {
prevSelected.marker.setIcon(component.visitedMarkerIcon())
}
const scrollElem = document.querySelector('.right-content')
//const scrollElem = document.querySelector('.right-content')
const scrollElem = getScrollElem(component)
scrollElem.scrollTop = component.savedScrollTop
}
)
@@ -251,7 +260,8 @@ const mapIdle = ({type, action}, component) => {
page: 0
},
() => {
const scrollElem = document.querySelector('.right-content')
const scrollElem = getScrollElem(component)
//const scrollElem = document.querySelector('.right-content')
scrollElem.scrollTop = 0
component.refreshListings()
}
@@ -345,6 +355,23 @@ const submitContactEnd = ({type, action}, component) => {
})
}
const mobileMapView = ({type, action}, component) => {
component.setState({
mobileView: 'MAP'
}, () => {
backToResults({type, action}, component)
})
}
const mobileListView = ({type, action}, component) => {
component.setState({
mobileView: 'LIST'
}, () => {
backToResults({type, action}, component)
})
}
const handlers = {
SET_MIN_PRICE: setMinPrice,
SET_MAX_PRICE: setMaxPrice,
@@ -372,7 +399,9 @@ const handlers = {
UPDATE_CONTACT_INFO: updateContactInfo,
SUBMIT_CONTACT_START: submitContactStart,
SUBMIT_CONTACT_END: submitContactEnd,
INVALID_CONTACT: invalidContact
INVALID_CONTACT: invalidContact,
MOBILE_MAP_VIEW: mobileMapView,
MOBILE_LIST_VIEW: mobileListView
}
export const handleMessage = ({type, action}, component) => {