{"action":"created","issue":{"url":"https://api.github.com/repos/Dogfalo/materialize/issues/2351","repository_url":"https://api.github.com/repos/Dogfalo/materialize","labels_url":"https://api.github.com/repos/Dogfalo/materialize/issues/2351/labels{/name}","comments_url":"https://api.github.com/repos/Dogfalo/materialize/issues/2351/comments","events_url":"https://api.github.com/repos/Dogfalo/materialize/issues/2351/events","html_url":"https://github.com/Dogfalo/materialize/pull/2351","id":118280778,"number":2351,"title":"scrollFire: callback function, repeat fire option","user":{"login":"kielni","id":1649528,"avatar_url":"https://avatars.githubusercontent.com/u/1649528?v=3","gravatar_id":"","url":"https://api.github.com/users/kielni","html_url":"https://github.com/kielni","followers_url":"https://api.github.com/users/kielni/followers","following_url":"https://api.github.com/users/kielni/following{/other_user}","gists_url":"https://api.github.com/users/kielni/gists{/gist_id}","starred_url":"https://api.github.com/users/kielni/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kielni/subscriptions","organizations_url":"https://api.github.com/users/kielni/orgs","repos_url":"https://api.github.com/users/kielni/repos","events_url":"https://api.github.com/users/kielni/events{/privacy}","received_events_url":"https://api.github.com/users/kielni/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2015-11-22T18:44:09Z","updated_at":"2016-10-19T04:38:04Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/Dogfalo/materialize/pulls/2351","html_url":"https://github.com/Dogfalo/materialize/pull/2351","diff_url":"https://github.com/Dogfalo/materialize/pull/2351.diff","patch_url":"https://github.com/Dogfalo/materialize/pull/2351.patch"},"body":"Currently, the callback option of scrollFire has to be a string, which gets called like this:\r\n\r\n    var callbackFunc = new Function(callback);\r\n    callbackFunc();\r\n\r\nThis means the function must be global, and there's no way to pass it any context. 7861638 checks if the callback is a function, and then calls it.  \r\n\r\nI wanted to use th scrollFire for infinite scroll.  I put my trigger element at the bottom of the list, and my callback renders more content when the trigger element comes into view.  Currently, there's no way get it to invoke the callback more than once.  d7999ea adds `repeat` option, which will invoke the callback each time the trigger element comes into view.  \r\n\r\nHere's an example of how I used a callback function and the `repeat` option to set up infinite scroll in a React component:\r\n\r\n    showMore: function() {\r\n        this.setState({to: Math.min(this.state.items.length, this.state.to+pageSize)});\r\n    },\r\n    componentDidMount() {\r\n        // ... load content\r\n        Materialize.scrollFire([\r\n            { selector: '#moreMarker', offset: 0, callback: this.showMore, repeat: true }\r\n        ]);\r\n    },\r\n    render() {\r\n        return (\r\n            <div>\r\n                <ItemList items={this.state.items.slice(0, this.state.to)} />\r\n                <div id=\"moreMarker\" className=\"chip\">More...</div>\r\n            </div>\r\n        );\r\n    }\r\n"},"comment":{"url":"https://api.github.com/repos/Dogfalo/materialize/issues/comments/254708502","html_url":"https://github.com/Dogfalo/materialize/pull/2351#issuecomment-254708502","issue_url":"https://api.github.com/repos/Dogfalo/materialize/issues/2351","id":254708502,"user":{"login":"Redmega","id":662951,"avatar_url":"https://avatars.githubusercontent.com/u/662951?v=3","gravatar_id":"","url":"https://api.github.com/users/Redmega","html_url":"https://github.com/Redmega","followers_url":"https://api.github.com/users/Redmega/followers","following_url":"https://api.github.com/users/Redmega/following{/other_user}","gists_url":"https://api.github.com/users/Redmega/gists{/gist_id}","starred_url":"https://api.github.com/users/Redmega/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Redmega/subscriptions","organizations_url":"https://api.github.com/users/Redmega/orgs","repos_url":"https://api.github.com/users/Redmega/repos","events_url":"https://api.github.com/users/Redmega/events{/privacy}","received_events_url":"https://api.github.com/users/Redmega/received_events","type":"User","site_admin":false},"created_at":"2016-10-19T04:38:04Z","updated_at":"2016-10-19T04:38:04Z","body":"Is there a reason this was not approved from last year? It's a good option to have."}}
{"actor":{"display_login":"Redmega"}}