Created
December 9, 2013 18:11
-
-
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 …
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
$("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