Permalink
Browse files

Correct constraints for draggable if contents is too big

  • Loading branch information...
Koen Bok
Koen Bok committed Feb 8, 2016
1 parent 0564c0e commit 36482509c670d71c1396df2787a451b2b53095f5
Showing with 9 additions and 1 deletion.
  1. +9 −1 framer/LayerDraggable.coffee
@@ -55,7 +55,9 @@ class exports.LayerDraggable extends BaseClass
get: -> @_constraints
set: (value) ->
if value and _.isObject(value)
@_constraints = _.defaults(value, {x:0, y:0, width:0, height:0})
value = _.pick(value, ["x", "y", "width", "height"])
value = _.defaults(value, {x:0, y:0, width:0, height:0})
@_constraints = value
else
@_constraints = {x:0, y:0, width:0, height:0}
@_updateSimulationConstraints(@_constraints) if @_constraints
@@ -310,6 +312,12 @@ class exports.LayerDraggable extends BaseClass
minY: Infinity
maxY: Infinity
# Correct the constraints if the layer size exceeds the constraints
bounds.width = @layer.width if bounds.width < @layer.width
bounds.height = @layer.height if bounds.height < @layer.height
#bounds.width = _.max([bounds.width, @layer.width])
constraints =
minX: Utils.frameGetMinX(bounds)
maxX: Utils.frameGetMaxX(bounds)

0 comments on commit 3648250

Please sign in to comment.