Skip to content

Instantly share code, notes, and snippets.

@sangar82
Created July 17, 2018 09:27
Show Gist options
  • Save sangar82/c3df9bd8c50c86bdd602a22acfb448a5 to your computer and use it in GitHub Desktop.
Save sangar82/c3df9bd8c50c86bdd602a22acfb448a5 to your computer and use it in GitHub Desktop.
Vibrate DOM element
var vibrate = function() {
var shake= 3;
$(".actionsMode[mode='on']").stop(true, false)
.css({
position: 'relative',
left: Math.round(Math.random() * shake) - ((shake + 1) / 2) + 'px',
top: Math.round(Math.random() * shake) - ((shake + 1) / 2) + 'px'
});
};
var stop_vibrate = function() {
clearInterval(vibrateIndex);
$(".actionsMode[mode='on']").stop(true,false)
.css({position: 'static', left: '0px', top: '0px'});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment