简体   繁体   English

如何使此响应(刷新窗口大小调整)Raphaeljs

[英]How do I make this responsive (refresh on window resize) Raphaeljs

So I have this script 所以我有这个脚本

var wide = window.innerWidth;
var high = window.innerHeight;

var paper = Raphael(0, 0, wide, high);
for (var j = 0; j < (wide / 10); j += 1) {
var multi = j * 10;
paper.path(["M", multi + 0.5, 0, "v", high]);
};

for (var j = 0; j < (high / 10); j += 1) {
var multi = j * 10;
paper.path(["M", 0,multi + 0.5, "h", wide]);
};

and I want the grid to draw to the size of the window when it is resized, if thats at all possible, plus how do i change the color of the lines? 并且我希望网格在调整大小时能够绘制到窗口的大小,如果可以的话,再加上如何更改线条的颜色?

heres a fiddle 小提琴

http://jsfiddle.net/zhirkovski/7DXJ4/2/ http://jsfiddle.net/zhirkovski/7DXJ4/2/

thanks 谢谢

Using JQuery, you can attach it to a "resize" event, like this: 使用JQuery,可以将其附加到“调整大小”事件,如下所示:

window.onresize = function(event) {
    /* Do something */
}

Using mootools, you can attach it using the addEvent() method, something like this: 使用mootools,您可以使用addEvent()方法将其附加,如下所示:

$(window).addEvent('resize', function() { /* Do something */ });

And in native javascript, it's very similar to mootools. 在原生javascript中,它与mootools非常相似。 Something like: 就像是:

window.addEvent('resize', function() { /* Do something */ }, false);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM