Skip to content

Commit

Permalink
compatibility fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
ivictbor committed Jun 28, 2017
1 parent 892743b commit 4e2c104
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 15 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ or [build it by yourself](#building-painterro).

Then insert `<script>` e.g:
```html
<script src="https://github.com/ivictbor/painterro/releases/download/0.1.7/painterro-0.1.7.min.js"></script>
<script src="/static/painterro-x.x.x.min.js"></script>
```
Then in your code:
```html
Expand Down
13 changes: 7 additions & 6 deletions css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,8 @@
margin-left: 4px;
font-family: "Open Sans", sans-serif;
position: relative;
top:-5px
top:-5px;
font-size: 14px;
}

.ptro-icon-btn:focus,
Expand Down Expand Up @@ -217,7 +218,7 @@
}

.ptro-wrapper .ptro-resize-widget {
width: 220px;
width: 200px;
height: 145px;
position: absolute;
top: 50%;
Expand Down Expand Up @@ -321,15 +322,15 @@
.ptro-text-tool-input {
position: absolute;
background-color: rgba(0,0,0,0);
border: 1px solid;
border-style: dashed;
border: 1px dashed;
width: auto;
display: block;
min-width: 5px;
padding: 0 1px;
overflow-x: hidden;
word-wrap: normal;
overflow-y: hidden;
box-sizing: content-box;
}

.ptro-text-tool-input:focus {
Expand All @@ -343,8 +344,8 @@

.ptro-link {
float: left;
margin-right: 5px;
margin-top: -24px;
margin-right: -12px;
margin-top: -20px;
}

.ptro-resize-link-wrapper {
Expand Down
5 changes: 4 additions & 1 deletion js/cropper.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { clearSelection } from './utils';

export class PainterroCropper {

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

console.log('recalced cords', ratio, this.cropper.topl, this.cropper.bottoml);
// console.log('recalced cords', ratio, this.cropper.topl, this.cropper.bottoml);
}

handleMouseDown(event) {
Expand Down Expand Up @@ -187,6 +189,7 @@ export class PainterroCropper {
this.cropper.resizingR = false;
this.cropper.resizingB = false;
this.cropper.resizingL = false;
clearSelection();
}

draw() {
Expand Down
6 changes: 3 additions & 3 deletions js/text.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class TextTool {

setFontSize(size) {
this.fontSize = size;
this.input.style['font-size'] = size;
this.input.style['font-size'] = `${size}px`;
//if (this.active) {
// this.input.focus();
//}
Expand Down Expand Up @@ -97,8 +97,8 @@ export class TextTool {
];
const scale = this.main.getScale();
this.scaledCord = [this.crd[0] * scale, this.crd[1] * scale];
this.input.style.left = this.crd[0];
this.input.style.top = this.crd[1];
this.input.style.left = `${this.crd[0]}px`;
this.input.style.top = `${this.crd[1]}px`;
this.input.style.display = 'inline';
this.input.focus();
this.reLimit();
Expand Down
16 changes: 16 additions & 0 deletions js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,22 @@ export function addDocumentObjectHelpers() {

}

export function clearSelection() {
let selection = null;
if(window.getSelection){
selection = window.getSelection();
} else if(document.selection){
selection = document.selection;
}
if(selection){
if(selection.empty){
selection.empty();
}
if(selection.removeAllRanges){
selection.removeAllRanges();
}
}
}

export function distance(p1, p2) {
const a = p1.x - p2.x;
Expand Down
5 changes: 2 additions & 3 deletions js/zoomHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,8 +70,8 @@ export class ZoomHelper {
}
}
}
this.zomer.style.left = e.clientX - this.wrapper.documentOffsetLeft - this.halfFullW;
this.zomer.style.top = e.clientY - this.wrapper.documentOffsetTop - this.halfFullW;
this.zomer.style.left = `${e.clientX - this.wrapper.documentOffsetLeft - this.halfFullW}px`;
this.zomer.style.top = `${e.clientY - this.wrapper.documentOffsetTop - this.halfFullW}px`;
} else {
if (this.shown) {
this.zomer.style.display = "none";
Expand All @@ -81,7 +81,6 @@ export class ZoomHelper {
}
}


static html() {
return '<canvas class="ptro-zoomer" width="" height="0"></canvas>'
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "painterro",
"version": "0.2.1",
"version": "0.2.2",
"description": "Embуedded html image editor",
"main": "build/painterro.commonjs2.js",
"scripts": {
Expand Down

0 comments on commit 4e2c104

Please sign in to comment.