Created
January 13, 2016 16:39
-
-
Save zwily/20fb827f74771a5c4d1e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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