{"action":"created","issue":{"url":"https://api.github.com/repos/phetsims/scenery-phet/issues/142","labels_url":"https://api.github.com/repos/phetsims/scenery-phet/issues/142/labels{/name}","comments_url":"https://api.github.com/repos/phetsims/scenery-phet/issues/142/comments","events_url":"https://api.github.com/repos/phetsims/scenery-phet/issues/142/events","html_url":"https://github.com/phetsims/scenery-phet/issues/142","id":60877723,"number":142,"title":"Generalize MovableDragHandler to handle dynamical bounds","user":{"login":"bereaphysics","id":7633344,"avatar_url":"https://avatars.githubusercontent.com/u/7633344?v=3","gravatar_id":"","url":"https://api.github.com/users/bereaphysics","html_url":"https://github.com/bereaphysics","followers_url":"https://api.github.com/users/bereaphysics/followers","following_url":"https://api.github.com/users/bereaphysics/following{/other_user}","gists_url":"https://api.github.com/users/bereaphysics/gists{/gist_id}","starred_url":"https://api.github.com/users/bereaphysics/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bereaphysics/subscriptions","organizations_url":"https://api.github.com/users/bereaphysics/orgs","repos_url":"https://api.github.com/users/bereaphysics/repos","events_url":"https://api.github.com/users/bereaphysics/events{/privacy}","received_events_url":"https://api.github.com/users/bereaphysics/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"pixelzoom","id":3046552,"avatar_url":"https://avatars.githubusercontent.com/u/3046552?v=3","gravatar_id":"","url":"https://api.github.com/users/pixelzoom","html_url":"https://github.com/pixelzoom","followers_url":"https://api.github.com/users/pixelzoom/followers","following_url":"https://api.github.com/users/pixelzoom/following{/other_user}","gists_url":"https://api.github.com/users/pixelzoom/gists{/gist_id}","starred_url":"https://api.github.com/users/pixelzoom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixelzoom/subscriptions","organizations_url":"https://api.github.com/users/pixelzoom/orgs","repos_url":"https://api.github.com/users/pixelzoom/repos","events_url":"https://api.github.com/users/pixelzoom/events{/privacy}","received_events_url":"https://api.github.com/users/pixelzoom/received_events","type":"User","site_admin":false},"milestone":null,"comments":3,"created_at":"2015-03-12T19:02:24Z","updated_at":"2015-03-16T23:53:00Z","closed_at":null,"body":"For charges-and-fields, the drag bounds are dynamical and set by the size of the window. By having dragBounds as property, it is possible to constrain the location to be within the dynamical dragBounds.\r\n\r\nHere is how it is done in charges-an-fields: https://github.com/phetsims/charges-and-fields/blob/master/js/charges-and-fields/view/MovableDragHandler.js\r\n\r\nIt would be good if this capability could live in the common-code.\r\n\r\nOne consideration that arises is how to deal with a location that is no longer within the dragBounds\r\n(due a change of  the dragBounds). For charges and fields the dragBoundListener constrains the location to be within the dragBounds \r\n\r\n````\r\n    // constrain the location to always be within the dragBounds\r\n    this.dragBoundsPropertyListener = function( bounds ) {\r\n      locationProperty.set( constrainLocation( locationProperty.value, bounds ) );\r\n    };\r\n    this.dragBoundsProperty.link( this.dragBoundsPropertyListener );\r\n````\r\nThis is probably the most common scenario but different behavior might be wanted (for instance the location could be set  to its initial position if it is caught outside of the dragBounds). I don't know if it is best to include this behavior  in the MovableDragHandler as an options or to let the client deal with it.\r\n\r\nAssigning to @pixelzoom since he wrote the original MovableDragHandler"},"comment":{"url":"https://api.github.com/repos/phetsims/scenery-phet/issues/comments/81998055","html_url":"https://github.com/phetsims/scenery-phet/issues/142#issuecomment-81998055","issue_url":"https://api.github.com/repos/phetsims/scenery-phet/issues/142","id":81998055,"user":{"login":"pixelzoom","id":3046552,"avatar_url":"https://avatars.githubusercontent.com/u/3046552?v=3","gravatar_id":"","url":"https://api.github.com/users/pixelzoom","html_url":"https://github.com/pixelzoom","followers_url":"https://api.github.com/users/pixelzoom/followers","following_url":"https://api.github.com/users/pixelzoom/following{/other_user}","gists_url":"https://api.github.com/users/pixelzoom/gists{/gist_id}","starred_url":"https://api.github.com/users/pixelzoom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pixelzoom/subscriptions","organizations_url":"https://api.github.com/users/pixelzoom/orgs","repos_url":"https://api.github.com/users/pixelzoom/repos","events_url":"https://api.github.com/users/pixelzoom/events{/privacy}","received_events_url":"https://api.github.com/users/pixelzoom/received_events","type":"User","site_admin":false},"created_at":"2015-03-16T23:53:00Z","updated_at":"2015-03-16T23:53:00Z","body":"Since Bounds2 is mutable, we may want to make a copy of the dragBounds in the constructor and setDragBounds, in case the client is ill-behaved and mutates the dragBounds."}}