I do know that this jquery from David J. Bradshaw works as anticipated to resize an image-map on resizing the complete browser window.
I ponder if it may very well be doable to change the code to resize the image-map on resizing not of the entire window, however of a given component (a div, i.g.) containing the picture.
It might be doable?
/*! Picture Map Resizer
* Desc: Resize HTML imageMap to scaled picture.
* Copyright: (c) 2014-15 David J. Bradshaw - [email protected]
* License: MIT
*/
;(operate() {
'use strict'
operate scaleImageMap()
operate resizeMap()
operate resizeAreaTag(cachedAreaCoords, idx)
operate scale(coord)
var dimension = 1 === (isWidth = 1 - isWidth) ? 'width' : 'peak'
return (
padding[dimension] +
Math.flooring(Quantity(coord) * scalingFactor[dimension])
)
var isWidth = 0
areas[idx].coords = cachedAreaCoords
.break up(',')
.map(scale)
.be a part of(',')
var scalingFactor =
width: picture.width / picture.naturalWidth,
peak: picture.peak / picture.naturalHeight,
var padding =
width: parseInt(
window.getComputedStyle(picture, null).getPropertyValue('padding-left'),
10
),
peak: parseInt(
window.getComputedStyle(picture, null).getPropertyValue('padding-top'),
10
),
cachedAreaCoordsArray.forEach(resizeAreaTag)
operate getCoords(e)
//Normalize coord-string to csv format with none area chars
return e.coords.change(/ *, */g, ',').change(/ +/g, ',')
operate debounce()
clearTimeout(timer)
timer = setTimeout(resizeMap, 250)
operate begin()
if (
picture.width !== picture.naturalWidth
operate addEventListeners()
picture.addEventListener('load', resizeMap, false) //Detect late picture masses in IE11
window.addEventListener('focus', resizeMap, false) //Address window being resized while on one other tab
window.addEventListener('resize', debounce, false)
window.addEventListener('readystatechange', resizeMap, false)
doc.addEventListener('fullscreenchange', resizeMap, false)
operate beenHere()
return 'operate' === typeof map._resize
operate getImg(identify)
return doc.querySelector('img[usemap="' + name + '"]')
operate setup()
areas = map.getElementsByTagName('space')
cachedAreaCoordsArray = Array.prototype.map.name(areas, getCoords)
picture = getImg('#' + map.identify)
var /*jshint validthis:true */
map = this,
areas = null,
cachedAreaCoordsArray = null,
picture = null,
timer = null
if (!beenHere())
setup()
addEventListeners()
begin()
else
map._resize() //Already setup, so simply resize map
operate manufacturing unit()
operate chkMap(component)
if (!component.tagName)
throw new TypeError('Object will not be a sound DOM component')
else if ('MAP' !== component.tagName.toUpperCase())
throw new TypeError(
'Anticipated <MAP> tag, discovered <' + component.tagName + '>.'
)
operate init(component)
if (component)
chkMap(component)
scaleImageMap.name(component)
maps.push(component)
var maps
return operate imageMapResizeF(goal)
maps = [] // Solely return maps from this name
change (typeof goal) 'map'),
init
)
break
case 'object':
init(goal)
break
default:
throw new TypeError('Surprising knowledge sort (' + typeof goal + ').')
return maps
if (typeof outline === 'operate' && outline.amd)
outline([], manufacturing unit)
else if (typeof module === 'object' && typeof module.exports === 'object')
module.exports = manufacturing unit() //Node for browserfy
else
window.imageMapResize = manufacturing unit()
if ('jQuery' in window)
window.jQuery.fn.imageMapResize = operate $imageMapResizeF()
return this.filter('map')
.every(scaleImageMap)
.finish()
})()
It appears to do this already until I’m mistaken.