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 @@ ...@@ -3499,6 +3499,21 @@
delete this.__set__; delete this.__set__;
return out; 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 * Paper.setSize
[ method ] [ method ]
......
...@@ -1290,7 +1290,8 @@ window.Raphael && window.Raphael.svg && function(R) { ...@@ -1290,7 +1290,8 @@ window.Raphael && window.Raphael.svg && function(R) {
}; };
R._engine.setViewBox = function (x, y, w, h, fit) { R._engine.setViewBox = function (x, y, w, h, fit) {
eve("raphael.setViewBox", this, this._viewBox, [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, top = this.top,
aspectRatio = fit ? "xMidYMid meet" : "xMinYMin", aspectRatio = fit ? "xMidYMid meet" : "xMinYMin",
vb, vb,
......
...@@ -885,9 +885,9 @@ window.Raphael && window.Raphael.vml && function(R) { ...@@ -885,9 +885,9 @@ window.Raphael && window.Raphael.vml && function(R) {
}; };
R._engine.setViewBox = function (x, y, w, h, fit) { R._engine.setViewBox = function (x, y, w, h, fit) {
R.eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]); R.eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]);
var width = this.width, var paperSize = this.getSize(),
height = this.height, width = paperSize.width,
size = 1 / mmax(w / width, h / height), height = paperSize.height,
H, W; H, W;
if (fit) { if (fit) {
H = height / h; 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 @@ ...@@ -3878,6 +3878,21 @@
delete this.__set__; delete this.__set__;
return out; 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 * Paper.setSize
[ method ] [ method ]
...@@ -7090,7 +7105,8 @@ ...@@ -7090,7 +7105,8 @@
}; };
R._engine.setViewBox = function (x, y, w, h, fit) { R._engine.setViewBox = function (x, y, w, h, fit) {
eve("raphael.setViewBox", this, this._viewBox, [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, top = this.top,
aspectRatio = fit ? "xMidYMid meet" : "xMinYMin", aspectRatio = fit ? "xMidYMid meet" : "xMinYMin",
vb, vb,
...@@ -8084,9 +8100,9 @@ ...@@ -8084,9 +8100,9 @@
}; };
R._engine.setViewBox = function (x, y, w, h, fit) { R._engine.setViewBox = function (x, y, w, h, fit) {
R.eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]); R.eve("raphael.setViewBox", this, this._viewBox, [x, y, w, h, fit]);
var width = this.width, var paperSize = this.getSize(),
height = this.height, width = paperSize.width,
size = 1 / mmax(w / width, h / height), height = paperSize.height,
H, W; H, W;
if (fit) { if (fit) {
H = height / h; 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