mirror of
https://github.com/Karaka-Management/oms-Draw.git
synced 2026-01-27 13:28:41 +00:00
Auto adjust image/canvas size to image
This commit is contained in:
parent
8bb52a3c40
commit
265f38f5c2
|
|
@ -104,10 +104,19 @@
|
|||
|
||||
jsOMS.Modules.Draw.Editor.prototype.initCanvas = function()
|
||||
{
|
||||
const img = this.editor.getElementsByTagName('img');
|
||||
const img = this.canvas.getAttribute('data-src'),
|
||||
self = this;
|
||||
|
||||
if(img.length > 0) {
|
||||
this.canvas.getContext("2d").drawImage(img[0], 0, 0);
|
||||
if(typeof img !== 'undefined' && img.length > 0) {
|
||||
let imgObj = new Image();
|
||||
|
||||
imgObj.addEventListener('load', function() {
|
||||
self.canvas.width = imgObj.width;
|
||||
self.canvas.height = imgObj.height;
|
||||
self.canvas.getContext("2d").drawImage(imgObj, 0, 0);
|
||||
});
|
||||
|
||||
imgObj.src = img;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -75,8 +75,7 @@ echo $this->getData('nav')->render(); ?>
|
|||
<div class="m-draw">
|
||||
<section class="box wf-100" style="height: 30%;">
|
||||
<div class="inner resizable">
|
||||
<img class="hidden" src="<?= $this->request->getUri()->getBase() . $image->getMedia()->getPath(); ?>">
|
||||
<canvas id="canvasImage resizable" name="image" form="drawForm"></canvas>
|
||||
<canvas data-src="<?= $this->request->getUri()->getBase() . $image->getMedia()->getPath(); ?>" id="canvasImage resizable" name="image" form="drawForm"></canvas>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user