将 slimbox(灯箱)图像限制为窗口大小
大家好,
有人知道如何将 slimbox 的覆盖窗口大小限制为用户窗口大小的百分比(就像 Prettyphoto 那样)
谢谢
,这是模块代码: http://paste.ly/3Kz
和 slimbox js: http://paste.ly/3L0
HI all,
Anyone know how to limit the overlay window size of slimbox to be a percentage of the user's window size (like prettyphoto does)
Thanks
Here's the module code:
http://paste.ly/3Kz
And the slimbox js:
http://paste.ly/3L0
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
实际上,你的解决方案都没有完全适合我,所以我必须将它们放入搅拌机中,并通过这样做来混合结果:
正如他所说,在 slimbox2.js 中查找这一行
并将其替换为以下块:
*友善一点,我是早期阶段的业余开发者;)
Actually neither of your solutions quite did it for me , so i had to put them in a blender and sorta mix the result by doing this:
as he said, look out for this lines in slimbox2.js
and replace them with this block:
*be kind, i'm an amateur developer on early stage ;)
我试图使用 Redscouse 的解决方案,但我认为他使用的是旧版本的 slimbox。这是一个基于 v2.04 的解决方案,它将限制图像以适合当前浏览器窗口。
找到 animateBox() 函数。在顶部附近,您应该找到如下所示的线条:
将这些线条替换为以下线条:
-20 和 -104 调整是为了考虑 slimbox 在图像周围使用的额外空间。请随意根据需要调整它们。
I was trying to use Redscouse's solution but I think his used an older version of slimbox. Here is a solution based on v2.04 that will constrain the image to fit inside the current browser window.
Locate the animateBox() function. Near the top you should find lines that look like this:
Replace those lines with these:
The -20 and -104 adjustments are to take into account extra space that slimbox uses around the image. Feel free to tweak those as needed.
我遇到了类似的问题,图像扩展超出了窗口的大小。我知道我可以通过限制上传图像的大小来解决这个问题,但我不想这样做,我宁愿能够设置 slimbox 窗口的大小,所以我设置了任务,这就是我来的和它一起工作完美! :)
为了将来更容易调整,您需要将 userDefinedWidth 和 userDefinedHeight 行添加到选项中对 slimbox 的调用中:
示例:
接下来,打开 slimbox.js (或 slimbox2.js)并再次查找选项,这次添加没有值的 userDefinedWidth 和 userDefinedHeight,如下所示:
接下来找到名为 i 的函数。
在 i 函数中,将以下行: 替换
为以下行:
完成此操作后,您就可以开始操作了,并且应该能够将 slimbox 的大小调整为您选择的设置。
皮特.
PS:我是一个正在掌握 jquery/javascript 的 php 人员,所以如果有人可以做得更好/更快/更容易,请随意。哦,请随意在任何您喜欢的地方使用此代码。 ;)
I had a similar problem where the image was expanding beyond the size of the window. I know I could of solved this by restricting the size of the image on upload, but I didn't want to do that, I would rather be able to set the size of slimbox window so I set about the task, here's what I came up with and it works perfectly! :)
To make it easier to adjust in the future you want to add the userDefinedWidth and userDefinedHeight lines to your call to slimbox in the options:
Example:
Next, Open slimbox.js (or slimbox2.js) and look for the options again, this time add the userDefinedWidth and userDefinedHeight with no values like so:
Next find the function called i.
In the i function replace the following lines:
with these lines:
Once you have done that, you're good to go and should be able to resize the slimbox to a setting of your choice.
Pete.
PS: I'm a php guy getting to grips with jquery/javascript so if anyone can make this better/quicker/easier please feel free. Oh, and please feel free to use this code anywhere you like. ;)
虽然 Avinash 的响应有效,但它要简单得多:
上述字段中的百分比将其视为用户浏览器大小的百分比。
.pp_overlay 类是 PrettyPhoto 中的名称。您需要找到 slimbox 的等效项。
While Avinash's response works, this is much more simple:
The percent in the above fields takes it as a percent of the user's browser size.
The class .pp_overlay is what it is called in PrettyPhoto. You will need to find the equivalent for slimbox.
捕获用户窗口分辨率并根据捕获的信息设置覆盖层的宽度和高度...
capture the users window resolution and set the overlay's width and height according to captured info...