Commit 5f08cf50 authored by Tomas Alabes's avatar Tomas Alabes

setViewBox() does not work properly for papers, having size in percents

parent ab5fa489
......@@ -3499,6 +3499,21 @@
delete this.__set__;
return out;
};
/*\
* Paper.getSize
[ method ]
**
* Obtains current paper actual size.
**
= (object)
\*/
paperproto.getSize = function () {
var container = this.canvas.parentNode;
return {
width: container.offsetWidth,
height: container.offsetHeight
};
};
/*\
* Paper.setSize
[ method ]
......
......@@ -1290,7 +1290,8 @@ window.Raphael && window.Raphael.svg && function(R) {
};
R._engine.setViewBox = function (x, y, w, h, fit) {
eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]);
var size = mmax(w / this.width, h / this.height),
var paperSize = this.getSize(),
size = mmax(w / paperSize.width, h / paperSize.height),
top = this.top,
aspectRatio = fit ? "xMidYMid meet" : "xMinYMin",
vb,
......
......@@ -885,9 +885,9 @@ window.Raphael && window.Raphael.vml && function(R) {
};
R._engine.setViewBox = function (x, y, w, h, fit) {
R.eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]);
var width = this.width,
height = this.height,
size = 1 / mmax(w / width, h / height),
var paperSize = this.getSize(),
width = paperSize.width,
height = paperSize.height,
H, W;
if (fit) {
H = height / h;
......
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -3878,6 +3878,21 @@
delete this.__set__;
return out;
};
/*\
* Paper.getSize
[ method ]
**
* Obtains current paper actual size.
**
= (object)
\*/
paperproto.getSize = function () {
var container = this.canvas.parentNode;
return {
width: container.offsetWidth,
height: container.offsetHeight
};
};
/*\
* Paper.setSize
[ method ]
......@@ -7090,7 +7105,8 @@
};
R._engine.setViewBox = function (x, y, w, h, fit) {
eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]);
var size = mmax(w / this.width, h / this.height),
var paperSize = this.getSize(),
size = mmax(w / paperSize.width, h / paperSize.height),
top = this.top,
aspectRatio = fit ? "xMidYMid meet" : "xMinYMin",
vb,
......@@ -8084,9 +8100,9 @@
};
R._engine.setViewBox = function (x, y, w, h, fit) {
R.eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]);
var width = this.width,
height = this.height,
size = 1 / mmax(w / width, h / height),
var paperSize = this.getSize(),
width = paperSize.width,
height = paperSize.height,
H, W;
if (fit) {
H = height / h;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment