Skip to content

Commit

Permalink
[google-maps-input] Disable scroll-wheel zoom on diff
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Oct 6, 2020
1 parent c6798ac commit 61b0dc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,14 @@ function GeopointDiff({api, diff}: DiffProps & {api: typeof window.google.maps})
const bounds = fromValue && toValue ? getBounds(fromValue, toValue, api) : undefined

return (
<GoogleMap api={api} location={center} mapTypeControl={false} controlSize={20} bounds={bounds}>
<GoogleMap
api={api}
location={center}
mapTypeControl={false}
controlSize={20}
bounds={bounds}
scrollWheel={false}
>
{map => <GeopointMove api={api} map={map} diff={diff} />}
</GoogleMap>
)
Expand Down
7 changes: 5 additions & 2 deletions packages/@sanity/google-maps-input/src/map/Map.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ interface MapProps {
bounds?: google.maps.LatLngBounds
defaultZoom?: number
mapTypeControl?: boolean
scrollWheel?: boolean
controlSize?: number
onClick?: (event: google.maps.MouseEvent) => void
children?: (map: google.maps.Map) => React.ReactElement
Expand All @@ -20,7 +21,8 @@ interface MapState {

export class GoogleMap extends React.PureComponent<MapProps, MapState> {
static defaultProps = {
defaultZoom: 8
defaultZoom: 8,
scrollWheel: true
}

state: MapState = {map: undefined}
Expand Down Expand Up @@ -83,11 +85,12 @@ export class GoogleMap extends React.PureComponent<MapProps, MapState> {
}

constructMap(el: HTMLDivElement) {
const {defaultZoom, api, mapTypeControl, controlSize, bounds} = this.props
const {defaultZoom, api, mapTypeControl, controlSize, bounds, scrollWheel} = this.props

const map = new api.Map(el, {
zoom: defaultZoom,
center: this.getCenter(),
scrollwheel: scrollWheel,
streetViewControl: false,
mapTypeControl,
controlSize
Expand Down

0 comments on commit 61b0dc0

Please sign in to comment.