Skip to content

Instantly share code, notes, and snippets.

@joepreludian
Created December 9, 2013 18:11
Show Gist options
  • Save joepreludian/7877101 to your computer and use it in GitHub Desktop.
Save joepreludian/7877101 to your computer and use it in GitHub Desktop.
Script para atuar como um scroller estilo terminal do linux. basta jogar o seguinte código. Chega na div que quer que scroll funcione e adicione 'terminal' na propriedade 'class'; crie um checkbox e coloque nele a tag 'data-scroller' com o valor igual ao id da div que você elegeu para ser o scroller. Este checkbox habilitará/desabilitará o modo …
$("div[class~=terminal]").on('DOMNodeInserted', function(){
var current_scroll = this.scrollHeight;
var element_height = $(this).height();
var this_element_id = $(this).attr('id');
var is_allowed_to_scroll = $('input[data-scroller='+ this_element_id +']:checked',0).length;
if (is_allowed_to_scroll)
if (current_scroll > element_height)
this.scrollTop = current_scroll
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment