{"action":"created","issue":{"url":"https://api.github.com/repos/Masonry/Snap/issues/39","labels_url":"https://api.github.com/repos/Masonry/Snap/issues/39/labels{/name}","comments_url":"https://api.github.com/repos/Masonry/Snap/issues/39/comments","events_url":"https://api.github.com/repos/Masonry/Snap/issues/39/events","html_url":"https://github.com/Masonry/Snap/pull/39","id":54064300,"number":39,"title":"Replace constraints when update to different relationship.","user":{"login":"devxoul","id":931655,"avatar_url":"https://avatars.githubusercontent.com/u/931655?v=3","gravatar_id":"","url":"https://api.github.com/users/devxoul","html_url":"https://github.com/devxoul","followers_url":"https://api.github.com/users/devxoul/followers","following_url":"https://api.github.com/users/devxoul/following{/other_user}","gists_url":"https://api.github.com/users/devxoul/gists{/gist_id}","starred_url":"https://api.github.com/users/devxoul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/devxoul/subscriptions","organizations_url":"https://api.github.com/users/devxoul/orgs","repos_url":"https://api.github.com/users/devxoul/repos","events_url":"https://api.github.com/users/devxoul/events{/privacy}","received_events_url":"https://api.github.com/users/devxoul/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-01-12T15:13:33Z","updated_at":"2015-02-13T02:54:15Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Masonry/Snap/pulls/39","html_url":"https://github.com/Masonry/Snap/pull/39","diff_url":"https://github.com/Masonry/Snap/pull/39.diff","patch_url":"https://github.com/Masonry/Snap/pull/39.patch"},"body":"There are needs to replace existing constraints to another relationship.\r\n\r\nFor example:\r\n\r\n![](http://s21.postimg.org/m7c5bss4n/cells.png)\r\n\r\n<sup>[Image from Stack Overflow - \"How to use auto-layout to move other views when a view is hidden?\"](http://stackoverflow.com/questions/18065938/how-to-use-auto-layout-to-move-other-views-when-a-view-is-hidden)</sup>\r\n\r\nWe can make `UIView`'s width to 0, but it's not a good solution if there are lots of UI elements in the screen and have various cases.\r\n\r\nIn this case, the most expected code should be:\r\n\r\n```swift\r\nlabel1.snp_makeConstraints { make in\r\n    make.left.equalTo(view.snp_right).with.offset(10)\r\n}\r\n\r\nlabel1.snp_updateConstraints { make in\r\n    make.left.equalTo(10)\r\n}\r\n```\r\n\r\n\r\n`updateConstraints()` currently provides updating **constant** only, so this code wouldn't be executed.\r\n\r\nThis PR makes `updateConstraints()` to replace existing constraints if needed. Some test codes are included.\r\n"},"comment":{"url":"https://api.github.com/repos/Masonry/Snap/issues/comments/74196943","html_url":"https://github.com/Masonry/Snap/pull/39#issuecomment-74196943","issue_url":"https://api.github.com/repos/Masonry/Snap/issues/39","id":74196943,"user":{"login":"cloudkite","id":598870,"avatar_url":"https://avatars.githubusercontent.com/u/598870?v=3","gravatar_id":"","url":"https://api.github.com/users/cloudkite","html_url":"https://github.com/cloudkite","followers_url":"https://api.github.com/users/cloudkite/followers","following_url":"https://api.github.com/users/cloudkite/following{/other_user}","gists_url":"https://api.github.com/users/cloudkite/gists{/gist_id}","starred_url":"https://api.github.com/users/cloudkite/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cloudkite/subscriptions","organizations_url":"https://api.github.com/users/cloudkite/orgs","repos_url":"https://api.github.com/users/cloudkite/repos","events_url":"https://api.github.com/users/cloudkite/events{/privacy}","received_events_url":"https://api.github.com/users/cloudkite/received_events","type":"User","site_admin":false},"created_at":"2015-02-13T02:54:15Z","updated_at":"2015-02-13T02:54:15Z","body":"It could also open up the possibility of sub-groupings like\r\n\r\nself.view1ConstraintGroup = view1.snp_prepareConstraints { make in\r\n  make.top.equalTo(superview.snp_top).offset(padding.top)\r\n  self.view1Sides = make.group {\r\n    make.left.equalTo(superview.snp_left).offset(padding.left)\r\n    make.right.equalTo(superview.snp_right).offset(padding.right)\r\n  }\r\n}"}}