简体   繁体   中英

get coordinates of viewable image area

I have a working fiddle of the problem here: http://jsfiddle.net/thindery/ZHhBR/

I need to be able to grab the coordinates of the source image's viewable area and display it in the span.

Here is an example of what I mean by display the coordinates of the viewable area: http://thindery.com/jsfiddle/crop_move.html

In this example, after you zoom in and pan around, you can see four different coordinates update like this: (x,y)(x1,y1)

Does jQuery provide this functionality so I can implement it in the jsfiddle example?

I could'nt really find a good way to get the coordinates from that plugin, so I just used a jQuery solution instead:

$(document).ready(function() {
    var iv2 = $("#viewer2").iviewer({
        src: "http://thindery.com/jsfiddle/butterfly.jpg",
        onDrag: function() {
            var pos = $("img","#viewer2").position();
            $("#status").html('X : '+Math.abs(pos.left)+'<br>Y :'+Math.abs(pos.top));
        }
    });
});

FIDDLE

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM