Skip to content

Commit

Permalink
disable map interactions while exporting so potential interaction fea…
Browse files Browse the repository at this point in the history
…tures won't be exported
  • Loading branch information
ludoholic committed Jul 31, 2024
1 parent 1a3ddbc commit 81fddfb
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/plugins/Export/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

- Fix: PDF export with download:false now works correctly.
- Fix: Adjust documentation to properly describe optionality of configuration parameters.
- Fix: Map interactions are now disabled during the export process so potential interaction features won't be exported
- Chore: Update dependencies to latest versions.

## 1.2.0
Expand Down
12 changes: 12 additions & 0 deletions packages/plugins/Export/src/store/actions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { jsPDF } from 'jspdf'
import { PolarActionTree } from '@polar/lib-custom-types'
import { Interaction } from 'ol/interaction'
import { ExportFormat, ExportGetters, ExportState } from '../types'

const actions: PolarActionTree<ExportState, ExportGetters> = {
Expand All @@ -25,6 +26,13 @@ const actions: PolarActionTree<ExportState, ExportGetters> = {
// Screenshot canvas
const CANVAS_ID = 'export-canvas'

const disabledInteractions: Array<Interaction> = []

map.getInteractions().forEach((interaction) => {
disabledInteractions.push(interaction)
interaction.setActive(false)
})

map.once('postrender', function () {

Check warning on line 36 in packages/plugins/Export/src/store/actions.ts

View workflow job for this annotation

GitHub Actions / lint-test

Function has too many lines (83). Maximum allowed is 50
// Map properties
const size = map.getSize()
Expand Down Expand Up @@ -102,6 +110,10 @@ const actions: PolarActionTree<ExportState, ExportGetters> = {
}
}

disabledInteractions.forEach((interaction) => {
interaction.setActive(true)
})

commit('setExportedMap', src)
})
map.renderSync()
Expand Down

0 comments on commit 81fddfb

Please sign in to comment.