forked from origo-map/origo
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Print - toggle between map and print layout interactions (origo-map#1181
) * Add map interaction control to top-left tools * Expose print control map interaction config option * Change to fa-map icon for interaction button * Change map interaction icon to Material Icons * More user friendly tooltip text
- Loading branch information
Showing
7 changed files
with
93 additions
and
9 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
import { | ||
Component, Button | ||
} from '../../ui'; | ||
import mapInteractions from '../../mapinteractions'; | ||
|
||
export default function PrintInteractionToggle(options = {}) { | ||
const { | ||
map, | ||
target, | ||
toggleIcon = '#ic_map_24px', | ||
mapInteractionsActive | ||
} = options; | ||
|
||
const interactions = mapInteractions({ target }); | ||
let mapInteractionToggleButton; | ||
|
||
const toggleState = function toggleState() { | ||
if (mapInteractionToggleButton.getState() === 'initial') { | ||
mapInteractionToggleButton.dispatch('change', { state: 'active' }); | ||
} else { | ||
mapInteractionToggleButton.dispatch('change', { state: 'initial' }); | ||
} | ||
}; | ||
|
||
const restoreInteractions = function restoreInteractions() { | ||
if (map.getInteractions() && map.getInteractions().getLength() > 0) { | ||
map.getInteractions().clear(); | ||
} | ||
if (interactions) { | ||
interactions.forEach(interaction => map.addInteraction(interaction)); | ||
} | ||
}; | ||
|
||
const onInitial = function onInitial() { | ||
map.getInteractions().clear(); | ||
}; | ||
|
||
const onActive = function onActive() { | ||
restoreInteractions(); | ||
}; | ||
|
||
return Component({ | ||
onInit() { | ||
mapInteractionToggleButton = Button({ | ||
cls: 'padding-small icon-smaller rounded light box-shadow', | ||
icon: toggleIcon, | ||
tooltipText: 'Ändra kartans läge', | ||
tooltipPlacement: 'east', | ||
state: 'initial', | ||
validStates: ['initial', 'active'], | ||
style: 'width: fit-content;', | ||
click() { | ||
toggleState(); | ||
}, | ||
methods: { | ||
active: onActive, | ||
initial: onInitial | ||
} | ||
}); | ||
this.addComponent(mapInteractionToggleButton); | ||
}, | ||
onRender() { | ||
this.dispatch('render'); | ||
}, | ||
render() { | ||
if (!mapInteractionsActive) { | ||
onInitial(); | ||
mapInteractionToggleButton.setState('initial'); | ||
} | ||
return mapInteractionToggleButton.render(); | ||
}, | ||
restoreInteractions | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters