Skip to content

Commit 4e2c104

Browse files
committed
compatibility fixes
1 parent 892743b commit 4e2c104

File tree

7 files changed

+34
-15
lines changed

7 files changed

+34
-15
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ or [build it by yourself](#building-painterro).
7171

7272
Then insert `<script>` e.g:
7373
```html
74-
<script src="https://github.com/ivictbor/painterro/releases/download/0.1.7/painterro-0.1.7.min.js"></script>
74+
<script src="/static/painterro-x.x.x.min.js"></script>
7575
```
7676
Then in your code:
7777
```html

css/styles.css

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,8 @@
6363
margin-left: 4px;
6464
font-family: "Open Sans", sans-serif;
6565
position: relative;
66-
top:-5px
66+
top:-5px;
67+
font-size: 14px;
6768
}
6869

6970
.ptro-icon-btn:focus,
@@ -217,7 +218,7 @@
217218
}
218219

219220
.ptro-wrapper .ptro-resize-widget {
220-
width: 220px;
221+
width: 200px;
221222
height: 145px;
222223
position: absolute;
223224
top: 50%;
@@ -321,15 +322,15 @@
321322
.ptro-text-tool-input {
322323
position: absolute;
323324
background-color: rgba(0,0,0,0);
324-
border: 1px solid;
325-
border-style: dashed;
325+
border: 1px dashed;
326326
width: auto;
327327
display: block;
328328
min-width: 5px;
329329
padding: 0 1px;
330330
overflow-x: hidden;
331331
word-wrap: normal;
332332
overflow-y: hidden;
333+
box-sizing: content-box;
333334
}
334335

335336
.ptro-text-tool-input:focus {
@@ -343,8 +344,8 @@
343344

344345
.ptro-link {
345346
float: left;
346-
margin-right: 5px;
347-
margin-top: -24px;
347+
margin-right: -12px;
348+
margin-top: -20px;
348349
}
349350

350351
.ptro-resize-link-wrapper {

js/cropper.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { clearSelection } from './utils';
2+
13
export class PainterroCropper {
24

35
constructor(main, selectionCallback) {
@@ -48,7 +50,7 @@ export class PainterroCropper {
4850
Math.round( this.cropper.topl[0] + (this.cropper.rect.clientWidth) / ratio ),
4951
Math.round( this.cropper.topl[1] + (this.cropper.rect.clientHeight) / ratio )];
5052

51-
console.log('recalced cords', ratio, this.cropper.topl, this.cropper.bottoml);
53+
// console.log('recalced cords', ratio, this.cropper.topl, this.cropper.bottoml);
5254
}
5355

5456
handleMouseDown(event) {
@@ -187,6 +189,7 @@ export class PainterroCropper {
187189
this.cropper.resizingR = false;
188190
this.cropper.resizingB = false;
189191
this.cropper.resizingL = false;
192+
clearSelection();
190193
}
191194

192195
draw() {

js/text.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export class TextTool {
4949

5050
setFontSize(size) {
5151
this.fontSize = size;
52-
this.input.style['font-size'] = size;
52+
this.input.style['font-size'] = `${size}px`;
5353
//if (this.active) {
5454
// this.input.focus();
5555
//}
@@ -97,8 +97,8 @@ export class TextTool {
9797
];
9898
const scale = this.main.getScale();
9999
this.scaledCord = [this.crd[0] * scale, this.crd[1] * scale];
100-
this.input.style.left = this.crd[0];
101-
this.input.style.top = this.crd[1];
100+
this.input.style.left = `${this.crd[0]}px`;
101+
this.input.style.top = `${this.crd[1]}px`;
102102
this.input.style.display = 'inline';
103103
this.input.focus();
104104
this.reLimit();

js/utils.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,22 @@ export function addDocumentObjectHelpers() {
3939

4040
}
4141

42+
export function clearSelection() {
43+
let selection = null;
44+
if(window.getSelection){
45+
selection = window.getSelection();
46+
} else if(document.selection){
47+
selection = document.selection;
48+
}
49+
if(selection){
50+
if(selection.empty){
51+
selection.empty();
52+
}
53+
if(selection.removeAllRanges){
54+
selection.removeAllRanges();
55+
}
56+
}
57+
}
4258

4359
export function distance(p1, p2) {
4460
const a = p1.x - p2.x;

js/zoomHelper.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ export class ZoomHelper {
7070
}
7171
}
7272
}
73-
this.zomer.style.left = e.clientX - this.wrapper.documentOffsetLeft - this.halfFullW;
74-
this.zomer.style.top = e.clientY - this.wrapper.documentOffsetTop - this.halfFullW;
73+
this.zomer.style.left = `${e.clientX - this.wrapper.documentOffsetLeft - this.halfFullW}px`;
74+
this.zomer.style.top = `${e.clientY - this.wrapper.documentOffsetTop - this.halfFullW}px`;
7575
} else {
7676
if (this.shown) {
7777
this.zomer.style.display = "none";
@@ -81,7 +81,6 @@ export class ZoomHelper {
8181
}
8282
}
8383

84-
8584
static html() {
8685
return '<canvas class="ptro-zoomer" width="" height="0"></canvas>'
8786
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "painterro",
3-
"version": "0.2.1",
3+
"version": "0.2.2",
44
"description": "Embуedded html image editor",
55
"main": "build/painterro.commonjs2.js",
66
"scripts": {

0 commit comments

Comments
 (0)