Skip to content

Commit

Permalink
fix for #2
Browse files Browse the repository at this point in the history
  • Loading branch information
disjunction committed Feb 10, 2015
1 parent 31e3f72 commit 1559eec
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
11 changes: 6 additions & 5 deletions dist/fabricjs_viewport.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions src/fabric/viewport.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,11 @@ class fabric.Viewport
@zoom = newZoom

_adjustPositionAfterZoom: (newZoom) ->
width = @canvas.width
height = @canvas.height
@position.x += ((@zoom * width) - (newZoom * width)) / 2;
@position.y += ((@zoom * height) - (newZoom * height)) / 2;
halfWidth = @canvas.width / 2
halfHeight = @canvas.height / 2
k = newZoom / @zoom
@position.x = halfWidth - k * (halfWidth - @position.x)
@position.y = halfHeight - k * (halfHeight - @position.y)

translate: () ->
{
Expand Down

0 comments on commit 1559eec

Please sign in to comment.