Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature multiple images (Issue #56) #57

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions js/imageMapResizer.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,19 @@

function scaleImageMap(){

function get_image() {
var imageList = document.querySelectorAll('img[usemap="#'+map.name+'"]');
var count = imageList.length;
for (var i = 0; i < count; i++){
var cImage = imageList[i].offsetParent;
if (typeof cImage != undefined && cImage) {
return imageList[i];
}
}
}

function resizeMap() {
var image = get_image();
function resizeAreaTag(cachedAreaCoords,idx){
function scale(coord){
var dimension = ( 1 === (isWidth = 1-isWidth) ? 'width' : 'height' );
Expand Down Expand Up @@ -44,13 +56,16 @@
}

function start(){
var image = get_image();
if ((image.width !== image.naturalWidth) || (image.height !== image.naturalHeight)) {
resizeMap();
}
}

function addEventListeners(){
var image = get_image(); //get current visible image
image.addEventListener('load', resizeMap, false); //Detect late image loads in IE11

window.addEventListener('focus', resizeMap, false); //Cope with window being resized whilst on another tab
window.addEventListener('resize', debounce, false);
window.addEventListener('readystatechange', resizeMap, false);
Expand Down