openseadragon/test/util.js

33 lines
1.0 KiB
JavaScript
Raw Normal View History

2013-03-22 00:44:22 +04:00
(function() {
// ----------
window.Util = {
// ----------
simulateViewerClick: function(viewer, widthFactor, heightFactor) {
if (widthFactor === undefined) {
widthFactor = 0.5;
}
if (heightFactor === undefined) {
heightFactor = 0.5;
}
widthFactor = Math.min(1, Math.max(0, widthFactor));
heightFactor = Math.min(1, Math.max(0, heightFactor));
var $canvas = $(viewer.element).find('.openseadragon-canvas').not('.navigator .openseadragon-canvas');
var offset = $canvas.offset();
var event = {
clientX: offset.left + Math.floor($canvas.width() * widthFactor),
clientY: offset.top + Math.floor($canvas.height() * heightFactor)
};
$canvas
.simulate('mouseover', event)
.simulate('mousedown', event)
.simulate('mouseup', event);
}
};
})();