{"action":"created","issue":{"url":"https://api.github.com/repos/sgr-ksmt/PullToDismiss/issues/42","repository_url":"https://api.github.com/repos/sgr-ksmt/PullToDismiss","labels_url":"https://api.github.com/repos/sgr-ksmt/PullToDismiss/issues/42/labels{/name}","comments_url":"https://api.github.com/repos/sgr-ksmt/PullToDismiss/issues/42/comments","events_url":"https://api.github.com/repos/sgr-ksmt/PullToDismiss/issues/42/events","html_url":"https://github.com/sgr-ksmt/PullToDismiss/issues/42","id":260109096,"number":42,"title":"ios 11 jerky on trying to dismiss","user":{"login":"vargarobert","id":1752085,"avatar_url":"https://avatars1.githubusercontent.com/u/1752085?v=4","gravatar_id":"","url":"https://api.github.com/users/vargarobert","html_url":"https://github.com/vargarobert","followers_url":"https://api.github.com/users/vargarobert/followers","following_url":"https://api.github.com/users/vargarobert/following{/other_user}","gists_url":"https://api.github.com/users/vargarobert/gists{/gist_id}","starred_url":"https://api.github.com/users/vargarobert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vargarobert/subscriptions","organizations_url":"https://api.github.com/users/vargarobert/orgs","repos_url":"https://api.github.com/users/vargarobert/repos","events_url":"https://api.github.com/users/vargarobert/events{/privacy}","received_events_url":"https://api.github.com/users/vargarobert/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2017-09-24T19:27:41Z","updated_at":"2018-05-24T07:41:16Z","closed_at":null,"author_association":"NONE","body":"There is an issue on ios11. The nav bar gets jerky when pulling to dismiss.\r\nCan be seen in the demo as well."},"comment":{"url":"https://api.github.com/repos/sgr-ksmt/PullToDismiss/issues/comments/391619999","html_url":"https://github.com/sgr-ksmt/PullToDismiss/issues/42#issuecomment-391619999","issue_url":"https://api.github.com/repos/sgr-ksmt/PullToDismiss/issues/42","id":391619999,"user":{"login":"ElectroBuddha","id":8009319,"avatar_url":"https://avatars0.githubusercontent.com/u/8009319?v=4","gravatar_id":"","url":"https://api.github.com/users/ElectroBuddha","html_url":"https://github.com/ElectroBuddha","followers_url":"https://api.github.com/users/ElectroBuddha/followers","following_url":"https://api.github.com/users/ElectroBuddha/following{/other_user}","gists_url":"https://api.github.com/users/ElectroBuddha/gists{/gist_id}","starred_url":"https://api.github.com/users/ElectroBuddha/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ElectroBuddha/subscriptions","organizations_url":"https://api.github.com/users/ElectroBuddha/orgs","repos_url":"https://api.github.com/users/ElectroBuddha/repos","events_url":"https://api.github.com/users/ElectroBuddha/events{/privacy}","received_events_url":"https://api.github.com/users/ElectroBuddha/received_events","type":"User","site_admin":false},"created_at":"2018-05-24T07:41:16Z","updated_at":"2018-05-24T07:41:16Z","author_association":"NONE","body":"As far as I could investigate the 'jumpiness' is caused by two things when drag animation starts:\r\n\r\n- the `safeAreaLayoutGuide.topAnchor` decreases by the height of the status bar (causing the tableView/collectionView/scrollView content to slightly jump up)\r\n\r\n- the navigationBar height shrinks by the height of the status bar (causing the navigationBar content to slightly jump up)\r\n\r\nTo solve the first issue I override the `viewSafeAreaInsetsDidChange()`  method inside my viewController to compensate for lost safeArea topAnchor height by increasing `additionalSafeAreaInsets.top` value, like this:\r\n\r\n```\r\n    var navBarHeight: CGFloat {\r\n        return self.navigationController?.navigationBar.frame.size.height ?? 0.0\r\n    }\r\n\r\n    var statusBarHeight: CGFloat {\r\n        let statusBarSize = UIApplication.shared.statusBarFrame.size\r\n        return min(statusBarSize.width, statusBarSize.height)\r\n    }\r\n    \r\n    @available(iOS 11, *)\r\n    override func viewSafeAreaInsetsDidChange() {\r\n        super.viewSafeAreaInsetsDidChange()\r\n        \r\n        let totalNavBarHeight = navBarHeight + statusBarHeight\r\n        \r\n        if (self.view.safeAreaInsets.top < totalNavBarHeight) {\r\n            self.additionalSafeAreaInsets.top = totalNavBarHeight - self.view.safeAreaInsets.top\r\n        }\r\n        else if (self.view.safeAreaInsets.top > totalNavBarHeight) {\r\n            self.additionalSafeAreaInsets.top = 0\r\n        }\r\n    }\r\n```\r\n\r\nTo solve the navigationBar shrinking height problem, I've modified `updateViewPosition(offset: CGFloat)` method inside `PullToDismiss.swift` file, and changed values where it says `avoid statusbar gone` like this:\r\n\r\n```\r\n    if viewPositionY >= 0 && viewPositionY < 0.005 {\r\n        addOffset = min(max(-0.001, addOffset), 0.001)\r\n    }\r\n```\r\nTo avoid triggering navBar shrinking, I made the drag animation move even more slowly in the beginning, I've changed value `0.05` to `0.005`, and values `-0.01` and `0.01` to `-0.001` and `0.001`.\r\n\r\n\r\nThis could probably be fixed more elegantly but for now this is what works for me.\r\n\r\n"}}
{"actor":{"display_login":"ElectroBuddha"}}