Skip to content

Commit

Permalink
Correct constraints for draggable if contents is too big
Browse files Browse the repository at this point in the history
  • Loading branch information
Koen Bok committed Feb 8, 2016
1 parent 0564c0e commit 3648250
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion framer/LayerDraggable.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 3648250

Please sign in to comment.