Skip to content

Instantly share code, notes, and snippets.

Created January 16, 2018 19:27
Show Gist options
  • Save anonymous/de54230553497cee59e5b15b640f9535 to your computer and use it in GitHub Desktop.
Save anonymous/de54230553497cee59e5b15b640f9535 to your computer and use it in GitHub Desktop.
(function () {
var mrg = 0;
var id = 'slider';
var klass = 'slider';
var interval = 2000;
var mainEl = document.getElementById(id)
if (!mainEl) {
console.error('Failed to find El#' + id);
return;
}
var insideEl = mainEl.getElementsByClassName(klass)[0]
if (!insideEl) {
console.error('Failed to find El.' + klass + ' inside El#' + id);
return;
}
var hdl = setInterval(function() {
mrg++;
var marginPx = (mrg % 5) * 1000
insideEl.style = 'margin-left: -' + marginPx + 'px'
}, interval);
})()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment