我这里有两个按钮,放大和缩小。我遇到的问题是当我点击几次时(+)它会坚持并继续缩放。
以下是HTML的代码:
<button id="zoom-in" class="btn-zoom-in" type="button" title="zoom in"></button>
<button id="zoom-out" class="btn-zoom-out" type="button" title="zoom out" onmouseup="this.blur();"></button>
<button id="zoom-default" class="btn-zoom-default" type="button" title="Default"></button>
放大功能:
function zoomIn()
{
var activeObject = canvas.getActiveObject();
if(activeObject!=null)
{
if(activeObject==textGroup)
{
if(nameTextObject!=null)
{
nameTextObject.setFontSize(parseInt(nameTextObject.fontSize)+1);
nameTextObject.setCoords();
wrapText(nameTextObject,true);
}
if(dedicationTextObject!=null)
{
dedicationTextObject.setFontSize(parseInt(dedicationTextObject.fontSize)+1);
dedicationTextObject.setCoords();
wrapText(dedicationTextObject,true);
}
if(signatureObject!=null)
{
signatureObject.setFontSize(parseInt(signatureObject.fontSize)+1);
signatureObject.setCoords();
}
setTextGroup();
textGroup.setCoords();
canvas.renderAll();
}
if(activeObject.type=='image')
{
var height = activeObject.getHeight();
activeObject.scaleToHeight(height+10);
activeObject.centerV();
activeObject.centerH();
//activeObject.setCoords();
canvas.renderAll();
}
if(activeObject.type=='text')
{
if(activeObject!=signatureObject)
{
activeObject.setFontSize(parseInt(activeObject.fontSize)+1);
canvas.renderAll();
wrapText(activeObject,true);
}
}
}
restrictScaling(false);
if(productType=='cylindrical')
{
getPreview();
}
}