Skip to content

Commit 037d99f

Browse files
pouu69MASNathan
authored andcommitted
Set a Element Top,Left Position (#79)
we can set a element top,left position.
1 parent 0428533 commit 037d99f

File tree

1 file changed

+42
-2
lines changed

1 file changed

+42
-2
lines changed

src/Capture.php

Lines changed: 42 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,18 @@ class Capture
2828
*/
2929
protected $url;
3030

31+
/**
32+
* dom element top position
33+
* @var string
34+
*/
35+
protected $top;
36+
37+
/**
38+
* dom element left position
39+
* @var string
40+
*/
41+
protected $left;
42+
3143
/**
3244
* Width of the page to render
3345
*
@@ -191,8 +203,8 @@ public function save($imageLocation, $deleteFileIfExists = true)
191203
if ($this->clipWidth && $this->clipHeight) {
192204
$data['clipOptions']['width'] = $this->clipWidth;
193205
$data['clipOptions']['height'] = $this->clipHeight;
194-
$data['clipOptions']['top'] = 0;
195-
$data['clipOptions']['left'] = 0;
206+
$data['clipOptions']['top'] = $this->top;
207+
$data['clipOptions']['left'] = $this->left;
196208
}
197209

198210
if ($this->backgroundColor) {
@@ -316,6 +328,34 @@ public function setUrl($url)
316328
$this->url = new Url($url);
317329
}
318330

331+
/**
332+
* Sets the dom top position
333+
*
334+
* @param int $top dom top position
335+
*
336+
* @return Capture
337+
*/
338+
public function setTop($top)
339+
{
340+
$this->top = $top;
341+
342+
return $this;
343+
}
344+
345+
/**
346+
* Sets the page width
347+
*
348+
* @param int $left dom left position
349+
*
350+
* @return Capture
351+
*/
352+
public function setLeft($left)
353+
{
354+
$this->left = $left;
355+
356+
return $this;
357+
}
358+
319359
/**
320360
* Sets the page width
321361
*

0 commit comments

Comments
 (0)