mirror of
https://github.com/teampoltergeist/poltergeist.git
synced 2022-11-09 12:05:00 -05:00
Fix screenshot feature
This commit is contained in:
parent
4ac77ae72e
commit
3074487885
2 changed files with 27 additions and 13 deletions
|
@ -122,17 +122,19 @@ class Poltergeist.Browser
|
|||
|
||||
render: (path, full) ->
|
||||
if full
|
||||
@page.setClipRect({})
|
||||
else
|
||||
size = @page.documentSize()
|
||||
scroll = @page.scrollPosition()
|
||||
|
||||
@page.setScrollPosition(left: 0, top: 0)
|
||||
@page.setClipRect(left: 0, top: 0, width: size.width, height: size.height)
|
||||
@page.render(path)
|
||||
@page.setScrollPosition(scroll)
|
||||
else
|
||||
size = @page.viewportSize()
|
||||
|
||||
@page.setClipRect(
|
||||
left: scroll.left, top: scroll.top,
|
||||
width: size.width, height: size.height
|
||||
)
|
||||
@page.setClipRect(left: 0, top: 0, width: size.width, height: size.height)
|
||||
@page.render(path)
|
||||
|
||||
@page.render(path)
|
||||
@owner.sendResponse(true)
|
||||
|
||||
resize: (width, height) ->
|
||||
|
|
|
@ -115,18 +115,30 @@ Poltergeist.Browser = (function() {
|
|||
Browser.prototype.render = function(path, full) {
|
||||
var scroll, size;
|
||||
if (full) {
|
||||
this.page.setClipRect({});
|
||||
} else {
|
||||
size = this.page.documentSize();
|
||||
scroll = this.page.scrollPosition();
|
||||
size = this.page.viewportSize();
|
||||
this.page.setScrollPosition({
|
||||
left: 0,
|
||||
top: 0
|
||||
});
|
||||
this.page.setClipRect({
|
||||
left: scroll.left,
|
||||
top: scroll.top,
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: size.width,
|
||||
height: size.height
|
||||
});
|
||||
this.page.render(path);
|
||||
this.page.setScrollPosition(scroll);
|
||||
} else {
|
||||
size = this.page.viewportSize();
|
||||
this.page.setClipRect({
|
||||
left: 0,
|
||||
top: 0,
|
||||
width: size.width,
|
||||
height: size.height
|
||||
});
|
||||
this.page.render(path);
|
||||
}
|
||||
this.page.render(path);
|
||||
return this.owner.sendResponse(true);
|
||||
};
|
||||
Browser.prototype.resize = function(width, height) {
|
||||
|
|
Loading…
Add table
Reference in a new issue