使用JQuery获取视口宽度并在处理JS中使用 [英] Get Viewport Width With JQuery and Use In Processing JS

查看:75
本文介绍了使用JQuery获取视口宽度并在处理JS中使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个我想根据用户视口宽度调整大小的Processing.js脚本.据我所知,在处理中没有任何功能,因此我一直在研究JQuery并使用$(window).width();.

I'm writing a processingjs script that I want to resize depending on the users viewport width. As far as I know there's no functionality for this in processing, so I've been looking at JQuery and using $(window).width();.

只有我不知道如何在处理中将该值放入大小(宽度,高度)函数中.

Only I don't know how to get that value into the size(width, height) function in processing.

有什么想法吗?

谢谢

链接(如果需要): http://processingjs.org/ http://api.jquery.com/width/

Links if you need them: http://processingjs.org/ http://api.jquery.com/width/

推荐答案

您可以调用$(window).width();在大小功能中.在process.js中将js和p5代码混合在一起是可以的.

You can call $(window).width(); in the size function. Mixing js and p5 code is fine in processing.js.

void setup() {
    size( $(window).width(),
        $(window).height() );
    ...
}

这篇关于使用JQuery获取视口宽度并在处理JS中使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆