1
I’m having trouble positioning an element in the center when I click on a zoom method, an element UI Jquery Draggable is dragged off to the corner, and I click on a zoom tool, it ends up disappearing from the screen... because it was dragged to the corner of the screen...
function zoomIn() {
var scale = 1.0;
scale=+.1;
$('.objeto').css({'transform':'scale('+scale+')'});
}
function limitPage(ui, vh, vw, content_vh) {
if ((ui.position.left + (ui.position.left / 4)) > vw) {
ui.position.left=-(ui.position.left - 30);
return false;
} else if ((Math.abs(ui.position.left) + (Math.abs(ui.position.left) / 4)) > vw) {
ui.position.left=+(ui.position.left + 30);
return false;
} else if ((ui.position.top + (ui.position.top / 4)) > vh) {
ui.position.top=-(ui.position.top - 30);
return false;
} else if ((Math.abs(ui.position.top) + (Math.abs(ui.position.top) / 4)) > content_vh) {
ui.position.top=+(ui.position.top + 30);
return false;
}
}
$('.objeto').draggable({
height :'auto',
cursor: 'grabbing',
// revertDuration: 250,
zIndex: 3,
start: function (event, ui) {
},
drag: function (event, ui) {
var vw = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0);
var content_vh = (vw * 2) - (vw / 2);
var vh = Math.max(document.documentElement.clientHeight || 0, window.innerHeight || 0);
return limitPage(ui, vh, vw, content_vh);
},
stop: function (event, ui) {
}
});
Good morning Ivan, I do not know if you have solved, if you can put a testable example on some online platform I think would be better. Here complained about $('.object'). css('Transform':'Scale('+Scale+')'); in the zoom function, I switched to 1 parameter only $('.object'). css('Transform: Scale('+Scale+')'); for to pass two parameters would be comma.
– Cleverson
@Cleverson, my fault, was supposed to be an object parameter.
– Ivan Ferrer