Skip to content

Commit

Permalink
Merge pull request #329 from oat-sa/hotfix/AUT-1910/coords-on-scale
Browse files Browse the repository at this point in the history
Hotfix/AUT-1910/coords on scale
  • Loading branch information
bziondik authored Oct 19, 2022
2 parents d823ba3 + f56b777 commit 1775b04
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@oat-sa/tao-item-runner-qti",
"version": "1.5.2",
"version": "1.5.3",
"displayName": "TAO Item Runner QTI",
"description": "TAO QTI Item Runner modules",
"files": [
Expand Down
26 changes: 13 additions & 13 deletions src/qtiCommonRenderer/helpers/Graphic.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ var GraphicHelper = {
var imgWidth = options.width || $container.innerWidth();
var imgHeight = options.height || $container.innerHeight();


paper = scaleRaphael(id, imgWidth, imgHeight);
image = paper.image(options.img, 0, 0, imgWidth, imgHeight);
image.id = options.imgId || image.id;
Expand Down Expand Up @@ -225,23 +226,20 @@ var GraphicHelper = {
* @private
*/
function resizePaper(e, givenWidth) {
var diff, maxWidth, containerWidth, containerHeight, factor;
var maxWidth, containerWidth, containerHeight, factor;

if (e) {
e.stopPropagation();
}

diff = $editor.outerWidth() - $editor.width() + ($container.outerWidth() - $container.width()) + 1;
maxWidth = $body.width();
containerWidth = $container.innerWidth();
containerWidth = $editor.innerWidth();

if (containerWidth > 0 || givenWidth > 0) {
if (givenWidth < containerWidth && givenWidth < maxWidth) {
containerWidth = givenWidth - diff;
if (givenWidth > 0 || containerWidth > maxWidth) {
if (givenWidth > 0 && givenWidth < maxWidth) {
containerWidth = givenWidth;
} else if (containerWidth > maxWidth) {
containerWidth = maxWidth - diff;
} else {
containerWidth -= diff;
containerWidth = maxWidth;
}

factor = containerWidth / imgWidth;
Expand All @@ -254,9 +252,8 @@ var GraphicHelper = {
if (typeof options.resize === 'function') {
options.resize(containerWidth, factor);
}

$container.trigger('resized.qti-widget');
}
$container.trigger('resized.qti-widget');
}

return paper;
Expand Down Expand Up @@ -465,15 +462,18 @@ var GraphicHelper = {
/**
* Get the QTI coordinates from a Raphael Element
* @param {Raphael.Element} element - the shape to get the coords from
* @param {Raphael.Element} paper - the interaction paper
* @param {number} width - width of background image
* @returns {String} the QTI coords
*/
qtiCoords: function qtiCoords(element) {
qtiCoords: function qtiCoords(element, paper, width) {
var mapper = raph2qtiCoordsMapper[element.type];
var result = '';
var factor = paper && width ? width / paper.w : 1;

if (_.isFunction(mapper)) {
result = _.map(mapper.call(raph2qtiCoordsMapper, element.attr()), function(coord) {
return _.parseInt(coord);
return Math.round(coord * factor);
}).join(',');
}

Expand Down

0 comments on commit 1775b04

Please sign in to comment.