andy's php projects
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
Script and site usage:
All of the scripts on this site are provided free for non-commerical, personal or non-profit use. If you find these scripts useful to you, appreciate the free support, or are just an all round nice person, then why not donate a little dosh? If you wish to use any of these in a commercial system, please refer to the payment plan.


interface shifting

 
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Crop Canvas
View previous topic :: View next topic  
Author Message
jakob.henriksson
Newbie


Joined: 06 Aug 2006
Posts: 1

PostPosted: Sun Aug 06, 2006 11:29 pm    Post subject: interface shifting Reply with quote

For the example interface (test.cropinterface.php), if I put a:

<div style="position: absolute; top: 20px; left: 20px;">
... crop interface code ...
</div>

around the code, everythings works, but the background image (the image to be cropped) is shifted the same amount as specified in the <div> above, but shifted that much _extra_, which is not what I expect.

Anyone know how to solve this.

Jakob
Back to top
View user's profile Send private message
debtaaaabc
Guest





PostPosted: Mon Nov 27, 2006 11:10 am    Post subject: Ive experienced the same Problem Reply with quote

Hi, Iv experienced the same Problem when i included the cropCanvas in my Project. Every Div-Container with its Position is added in the Position of the BG-Image. Someone solved this Bug??

Thx for Help.
Back to top
amnuts
Site Admin


Joined: 01 Sep 2002
Posts: 662
Location: East Sussex, England

PostPosted: Tue Nov 28, 2006 6:08 pm    Post subject: Reply with quote

Hi,

This issue is to do with where some of the javascript is being called in to the web page. In this latest incarnation of the crop canvas I brought the javascript and interface together so they could be called in one go (as quite often people forgot to call in the javascript). However, talking to the javascript developer there seems to be an issue with it being called within elements such as <div> tags.

The easiest way to fix this is by simply moving some javascript in to a separate file which is then included after all your html but before the closing body tag. You'd then create a new function in the crop interface class to include this new file.

So you'd end up with a file - let's call it inc.cropjavascript.php - that looks like this:

Code:
<?php

list($w, $h) = $this->calculateCropDimensions($this->crop['default']);
list($x, $y) = $this->calculateCropPosition($w, $h);

?>
<script type="text/javascript">
    SET_DHTML("theCrop"+MAXOFFLEFT+0+MAXOFFRIGHT+<?php echo $this->img['sizes'][0]; ?>+MAXOFFTOP+0+MAXOFFBOTTOM+<?php echo $this->img['sizes'][1], ($this->crop['resize'] ? '+RESIZABLE' : ''); ?>+MAXWIDTH+<?php echo $this->img['sizes'][0]; ?>+MAXHEIGHT+<?php echo $this->img['sizes'][1]; ?>+MINHEIGHT+<?php echo $this->crop['min-height']; ?>+MINWIDTH+<?php echo $this->crop['min-width']; ?>,"theImage"+NO_DRAG,"cropDimensions"+NO_DRAG);

    dd.elements.theCrop.moveTo(dd.elements.theImage.x + <?php echo $x; ?>, dd.elements.theImage.y + <?php echo $y; ?>);
    dd.elements.theCrop.setZ(dd.elements.theImage.z+1);
    dd.elements.theImage.addChild("theCrop");
    dd.elements.theCrop.defx = dd.elements.theImage.x;
    dd.elements.theCrop.defy = dd.elements.theImage.y;
    dd.elements.theImage.setOpacity(0.3);

    <?php if ($this->crop['resize']) { echo 'cc_SetResizingType(', (string)$this->crop['type'], ');'; } ?>
    cc_showCropSize();
    cc_reposBackground();
</script>


Remove the javascript portion out of inc.cropinterface.php (leave in the two lines of php at the top, though).

Then create a method in class.cropinterface.php that looks like:

Code:
function loadJavascript()
{
        include('inc.cropjavascript.php');
}


And then simply call the loadJavascript method just before your closing body tag.

You might be able to do something clever with bringing in the wz_dragdrop.js file dynamically and only after the page has loaded, etc., but the above is the easy way. Wink

I'll be updating the code soon to fix this issue.

Andy
Back to top
View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger
Display posts from previous:   
This forum is locked: you cannot post, reply to, or edit topics.   This topic is locked: you cannot edit posts or make replies.    php.amnuts.com Forum Index -> Crop Canvas All times are GMT - 5 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group