{"action":"opened","issue":{"url":"https://api.github.com/repos/fahidattique55/FAPaginationLayout/issues/7","repository_url":"https://api.github.com/repos/fahidattique55/FAPaginationLayout","labels_url":"https://api.github.com/repos/fahidattique55/FAPaginationLayout/issues/7/labels{/name}","comments_url":"https://api.github.com/repos/fahidattique55/FAPaginationLayout/issues/7/comments","events_url":"https://api.github.com/repos/fahidattique55/FAPaginationLayout/issues/7/events","html_url":"https://github.com/fahidattique55/FAPaginationLayout/issues/7","id":349798417,"node_id":"MDU6SXNzdWUzNDk3OTg0MTc=","number":7,"title":"Scroll by cells","user":{"login":"Evyasafmordechai","id":38878538,"node_id":"MDQ6VXNlcjM4ODc4NTM4","avatar_url":"https://avatars1.githubusercontent.com/u/38878538?v=4","gravatar_id":"","url":"https://api.github.com/users/Evyasafmordechai","html_url":"https://github.com/Evyasafmordechai","followers_url":"https://api.github.com/users/Evyasafmordechai/followers","following_url":"https://api.github.com/users/Evyasafmordechai/following{/other_user}","gists_url":"https://api.github.com/users/Evyasafmordechai/gists{/gist_id}","starred_url":"https://api.github.com/users/Evyasafmordechai/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Evyasafmordechai/subscriptions","organizations_url":"https://api.github.com/users/Evyasafmordechai/orgs","repos_url":"https://api.github.com/users/Evyasafmordechai/repos","events_url":"https://api.github.com/users/Evyasafmordechai/events{/privacy}","received_events_url":"https://api.github.com/users/Evyasafmordechai/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-08-12T09:31:23Z","updated_at":"2018-08-12T09:31:23Z","closed_at":null,"author_association":"NONE","body":"In FAPaginationLayout just modify the `targetContentOffset`    method:\r\n\r\n\r\n ```\r\n override public func targetContentOffset(forProposedContentOffset proposedContentOffset: CGPoint, withScrollingVelocity velocity: CGPoint) -> CGPoint {\r\n        var layoutAttributes: Array = layoutAttributesForElements(in: collectionView!.bounds)!\r\n\r\n        if layoutAttributes.count == 0 {\r\n            return proposedContentOffset\r\n        }\r\n        var targetIndex = layoutAttributes.count / 2\r\n        \r\n        // Skip to the next cell, if there is residual scrolling velocity left.\r\n        // This helps to prevent glitches\r\n        let vX = velocity.x\r\n        if vX > 0 {\r\n            targetIndex += 1\r\n        } else if vX < 0 {\r\n            targetIndex -= 1\r\n        }\r\n        \r\n        if targetIndex >= layoutAttributes.count {\r\n            targetIndex = layoutAttributes.count - 1\r\n        }\r\n        if targetIndex < 0 {\r\n            targetIndex = 0\r\n        }\r\n        let targetAttribute = layoutAttributes[targetIndex]\r\n        return CGPoint(x: targetAttribute.center.x - collectionView!.bounds.size.width * 0.5, y: proposedContentOffset.y)\r\n        \r\n    }\r\n\r\n```"}}
{"actor":{"display_login":"Evyasafmordechai"}}