在窗口调整大小时调整图像映射的大小
我正在尝试在窗口调整大小事件中调整图像映射的大小。我得到的最接近的是使用鼠标单击事件,但它需要根据我正在做的事情调整窗口大小。我正在使用 Firefox 3.5.5
我正在使用jquery。这是我的示例 - 我想要在窗口调整大小时调整大小的区域按钮位于左上角(单击它可以调整地图和区域按钮的大小):
http://www.whitebrickstudios.com/foghornstour/imagemap3.html
任何帮助将不胜感激! 谢谢你, 富有的
I'm trying to resize an image map on window resize event. The closest I've gotten is to use a mouseclick event, but it needs to be window resize for what I'm doing. I'm using Firefox 3.5.5
I'm using jquery somewhat. Here's my example - the area button I want to resize on window resize is in the top left (click on it to resize map and area button):
http://www.whitebrickstudios.com/foghornstour/imagemap3.html
Any help would be appreciated!
Thank you,
Rich
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(8)
我编写了一些简单的函数来重建每个事件的所有地图点。试试这个
scaleValue可以计算为oldWindowWidth/newWindowWidth。当然,您需要在窗口调整大小时保留 oldWindowWidth 的值。也许我的解决方案不及时,但我希望这对某人有用
I wrote some simple function to rebuild all map points on every event. Try this
scaleValue can be calculated as oldWindowWidth/newWindowWidth. Of course you need to keep the value of oldWindowWidth on window resize. Maybe my solution not on time, but i hope this is useful to someone
我想你想要的是
http://home.comcast.net/~urbanjost/semaphore.html
其中我展示了如何在图像显示尺寸发生变化时使图像地图坐标发生变化的不同示例。
I think what you want is at
http://home.comcast.net/~urbanjost/semaphore.html
where I show different examples of how to make your image map coordinates change when your image display size changes.
这是一个旧线程,但对于任何寻找类似甚至相同问题解决方案的人来说,ImageMapster jQuery 插件似乎提供了最简单的解决方案。您可以使用其调整大小方法(如果需要,甚至可以动画调整大小!),如下所示来调整图像及其图像贴图的大小:
您可以在 ImageMapster 的演示 页面到 jsFiddle演示调整图像大小和大小它的地图响应浏览器窗口的变化。
This is an old thread but for anyone looking for a solution for a similar or even identical problem, the ImageMapster jQuery plugin appears to provide the easiest solution. You can use its resize method (which can even animate the resizing if desired!) as follows to resize an image along with its image map:
You can find a link on ImageMapster's demo page to a jsFiddle that demonstrates resizing an image & its map in response to changing the browser window.
作为 Viktor 答案的修改版本,该版本可以处理多个调整大小。它存储初始值,以便与未来的任何调整大小进行比较。这也使用 waitForFinalEvent所以它不会在调整大小时一遍又一遍地运行。
As a modified version of Viktor's answer, this version can handle multiple resizes. It stores initial values for comparison against any future resize. This also uses waitForFinalEvent so it doesn't run over and over on resize.
这是一个不使用 jQuery 的解决方案。
首先,构建一个库函数:
然后,在页面初始加载时以及调整大小时调用调整大小函数:
将 500 替换为默认地图大小
Here is a solution that does not use jQuery.
First, build a library function:
Then, call the resize function when the page is initially loaded, and when it is resized:
Replace 500 with whatever your default map size is
加载或调整窗口大小时重新计算图像地图坐标的具体示例:
此图像为 1930 * 3360 :
并在正文后添加脚本:
a concret sample to recalculate coords of image map when window is loaded or resized:
this image is 1930 * 3360 :
and add the script after body as:
要在调整窗口大小时调用函数,请尝试以下操作:
此外,第 37 行缺少美元符号:
它应该是:
To call a function when the window is resized, try the following:
Also, line 37 is missing a dollar sign:
It should be:
如果您只需要调整图像大小,请使用以下技术:
http://www.cssplay.co.uk/layouts/background.html
感谢 CSSPlay。
If you only need to resize the image, use this technique:
http://www.cssplay.co.uk/layouts/background.html
Thanks to CSSPlay.