Skip to content

Commit

Permalink
Merge pull request #1 from origo-map/master
Browse files Browse the repository at this point in the history
Merge from upstream
  • Loading branch information
steff-o authored Mar 26, 2021
2 parents 41d0186 + ad41a46 commit 9de6ffc
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 13 deletions.
6 changes: 6 additions & 0 deletions scss/_print.scss
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,12 @@ $print-scale-line-color: $grey-darker;
$print-scale-line-inner-border-radius: $print-control-border-radius;
$print-scale-line-font-size: $font-size-smallest;

#o-print-tools-left > .collapse-scroll.expanded {
background-color: white;
border-radius: 0.25rem;
overflow: hidden;
}

// scale-line
.print-scale-line {
background: $print-control-bg-color;
Expand Down
7 changes: 5 additions & 2 deletions src/controls/editor/drawtools.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,10 @@ const drawToolsSelector = function drawToolsSelector(tools, defaultLayer, v) {
if (state) {
if (drawTools.length > 1) {
active = true;
document.getElementById(target).getElementsByTagName('ul')[0].parentNode.removeChild(document.getElementById(target).getElementsByTagName('ul')[0]);
const ul = document.getElementById(target).getElementsByTagName('ul');
if (ul.length > 0) {
ul[0].parentNode.removeChild(document.getElementById(target).getElementsByTagName('ul')[0]);
}
addDropDown(createDropDownOptions());
document.getElementById(target).classList.add(activeCls);
map.once('click', close);
Expand All @@ -81,7 +84,7 @@ const drawToolsSelector = function drawToolsSelector(tools, defaultLayer, v) {
cls: 'o-popover'
});
const { body: popoverHTML } = new DOMParser().parseFromString(popover, 'text/html');
document.getElementById('o-editor-draw').insertAdjacentElement('afterend', popoverHTML);
document.getElementById('o-editor-draw').insertAdjacentElement('afterend', popoverHTML.firstElementChild);
setActive(false);
}

Expand Down
2 changes: 1 addition & 1 deletion src/controls/editor/editdispatcher.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
function emitChangeEdit(tool, state) {
const changeEdit = new CustomEvent('', {
const changeEdit = new CustomEvent('changeEdit', {
detail: {
tool,
active: state
Expand Down
2 changes: 1 addition & 1 deletion src/controls/editor/edithandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ function cancelDraw() {
}

function onChangeShape(e) {
setInteractions(e.shape);
setInteractions(e.detail.shape);
startDraw();
}

Expand Down
2 changes: 1 addition & 1 deletion src/controls/print/print-interaction-toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function PrintInteractionToggle(options = {}) {
return Component({
onInit() {
mapInteractionToggleButton = Button({
cls: 'padding-small icon-smaller rounded light box-shadow',
cls: 'padding-small icon-smaller round light box-shadow',
icon: toggleIcon,
tooltipText: 'Ändra kartans läge',
tooltipPlacement: 'east',
Expand Down
4 changes: 2 additions & 2 deletions src/controls/print/print-settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ const PrintSettings = function PrintSettings(options = {}) {
close,
onInit() {
openButton = Button({
cls: 'padding-small icon-smaller light text-normal',
cls: 'padding-small icon-smaller round light box-shadow',
icon: openIcon,
tooltipText: 'Visa inställningar',
tooltipPlacement: 'east',
Expand Down Expand Up @@ -182,7 +182,7 @@ const PrintSettings = function PrintSettings(options = {}) {
if (rotationControl) { components.push(rotationControl); }
contentComponent.addComponents(components);
printSettingsContainer = Collapse({
cls: 'flex column rounded box-shadow bg-white',
cls: 'flex column',
containerCls: 'collapse-container no-margin height-full',
collapseX: true,
collapseY: true,
Expand Down
7 changes: 4 additions & 3 deletions src/controls/print/print-settings.template.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default function printTemplate({
showScaleControl
}) {
return `
<div id="${id}" class="flex column no-print padding-large overflow-auto max-height-100">
<div id="${id}" class="flex column no-print padding-x overflow-auto max-height-100">
${titleControl.render()}
<div class="padding-top"></div>
${descriptionControl.render()}
Expand Down Expand Up @@ -51,7 +51,8 @@ export default function printTemplate({
<div class="grow text-normal">Visa norrpil</div>
${northArrowControl.render()}
</div>
${rotationControl ? rotationControl.render() : ''}
<div class="padding-bottom-large">&nbsp;</div>
<div class="padding-bottom-large">
${rotationControl ? rotationControl.render() : ''}
</div>
</div>`;
}
9 changes: 6 additions & 3 deletions src/utils/download.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ export const html2canvas = function html2canvas(el) {
backgroundColor: null,
logging: false,
height: el.offsetHeight,
width: el.offsetWidth,
scale: 4
width: el.offsetWidth
});
};

Expand All @@ -67,7 +66,11 @@ export const dom2image = function dom2image(el, exportOptions) {

export const getImageBlob = async function getImageBlob(el) {
if (el) {
const canvas = await html2canvas(el);
const transformScale = el.style.transform;
const printEl = el;
printEl.style.transform = 'scale(1)';
const canvas = await html2canvas(printEl);
printEl.style.transform = transformScale;
const blob = await canvasToBlob(canvas);
return blob;
}
Expand Down

0 comments on commit 9de6ffc

Please sign in to comment.