{"action":"created","issue":{"url":"https://api.github.com/repos/flesler/jquery.scrollTo/issues/111","labels_url":"https://api.github.com/repos/flesler/jquery.scrollTo/issues/111/labels{/name}","comments_url":"https://api.github.com/repos/flesler/jquery.scrollTo/issues/111/comments","events_url":"https://api.github.com/repos/flesler/jquery.scrollTo/issues/111/events","html_url":"https://github.com/flesler/jquery.scrollTo/issues/111","id":63242382,"number":111,"title":"scroll event fires after onAfter","user":{"login":"SlightlyCyborg","id":1966377,"avatar_url":"https://avatars.githubusercontent.com/u/1966377?v=3","gravatar_id":"","url":"https://api.github.com/users/SlightlyCyborg","html_url":"https://github.com/SlightlyCyborg","followers_url":"https://api.github.com/users/SlightlyCyborg/followers","following_url":"https://api.github.com/users/SlightlyCyborg/following{/other_user}","gists_url":"https://api.github.com/users/SlightlyCyborg/gists{/gist_id}","starred_url":"https://api.github.com/users/SlightlyCyborg/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SlightlyCyborg/subscriptions","organizations_url":"https://api.github.com/users/SlightlyCyborg/orgs","repos_url":"https://api.github.com/users/SlightlyCyborg/repos","events_url":"https://api.github.com/users/SlightlyCyborg/events{/privacy}","received_events_url":"https://api.github.com/users/SlightlyCyborg/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-03-20T14:52:31Z","updated_at":"2015-05-14T05:19:50Z","closed_at":null,"body":"If I scroll to an item and put a .selected on it in the onAfter function and then also bind a scroll event handler to remove all .selected what should happen is that scrollTo will scroll to the element, remove all .selected classes and then put .selected on the item scrolled to. What ends up happening is that the scroll event fires AFTER the onAfter thereby removing .selected that was just set on the item."},"comment":{"url":"https://api.github.com/repos/flesler/jquery.scrollTo/issues/comments/101916230","html_url":"https://github.com/flesler/jquery.scrollTo/issues/111#issuecomment-101916230","issue_url":"https://api.github.com/repos/flesler/jquery.scrollTo/issues/111","id":101916230,"user":{"login":"brewster1134","id":217428,"avatar_url":"https://avatars.githubusercontent.com/u/217428?v=3","gravatar_id":"","url":"https://api.github.com/users/brewster1134","html_url":"https://github.com/brewster1134","followers_url":"https://api.github.com/users/brewster1134/followers","following_url":"https://api.github.com/users/brewster1134/following{/other_user}","gists_url":"https://api.github.com/users/brewster1134/gists{/gist_id}","starred_url":"https://api.github.com/users/brewster1134/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brewster1134/subscriptions","organizations_url":"https://api.github.com/users/brewster1134/orgs","repos_url":"https://api.github.com/users/brewster1134/repos","events_url":"https://api.github.com/users/brewster1134/events{/privacy}","received_events_url":"https://api.github.com/users/brewster1134/received_events","type":"User","site_admin":false},"created_at":"2015-05-14T05:19:50Z","updated_at":"2015-05-14T05:19:50Z","body":"it seems to work as expected if you use `requestAnimationFrame`.  if that turns out to be an actual fix, and you decide to integrate it into the scrollTo source, its worth mentioning the [browser support](http://caniuse.com/#feat=requestanimationframe).  personally i like the idea of integrating it and documenting that if you use onAfter, you may need to load a polyfill.\r\n\r\n```coffee\r\n$(window).on 'scroll', =>\r\n  if @enableScrollEvent\r\n    console.log 'scroll event'\r\n  else\r\n    console.log 'no scroll event'\r\n\r\n@enableScrollEvent = false\r\n\r\n$.scrollTo 100,\r\n  onAfter: =>\r\n    requestAnimationFrame =>\r\n      @enableScrollEvent = true\r\n```"}}