Skip to content

Instantly share code, notes, and snippets.

@zwily
Created January 13, 2016 16:39
Show Gist options
  • Save zwily/20fb827f74771a5c4d1e to your computer and use it in GitHub Desktop.
Save zwily/20fb827f74771a5c4d1e to your computer and use it in GitHub Desktop.
var setupLTIScrollRequest = function() {
window.addEventListener('message', function(e) {
try {
var message = JSON.parse(e.data);
if (message.subject === 'lti.scrollTop') {
$('html,body').animate({
scrollTop: $('.tool_content_wrapper').offset().top + message.scrollTop
}, message.animate);
}
} catch(err) {
(console.error || console.log)('invalid lti message from ' + e.origin);
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment