JSFiddle - React, Tailwind, and code Playground
by oms02
HTML
<script src="https://raw.github.com/jamesflorentino/nanoScrollerJS/master/bin/javascripts/jquery.nanoscroller.min.js"></script>
<html>
<head>
</head>
<body>
<div class="nano">
<div class="content">
<textarea id="loq">Lorem ipsum dolor sit amet, consectetur adipisicing eli, sed do eiusmodcia deserunt mollit anim id est laborum
</textarea>
<div id="trigger"></div>
</div>
</div>
</body>
</html>
CSS
/** initial setup **/
.nano {
position : relative;
width : 100%;
height : 100%;
overflow : hidden;
}
.nano .content {
position : absolute;
overflow : scroll;
overflow-x : hidden;
top : 0;
right : 0;
bottom : 0;
left : 0;
}
.nano .content:focus {
outline: thin dotted;
}
.nano .content::-webkit-scrollbar {
visibility: hidden;
}
.has-scrollbar .content::-webkit-scrollbar {
visibility: visible;
}
.nano > .pane {
background : rgba(0,0,0,.25);
position : absolute;
width : 10px;
right : 0;
top : 0;
bottom : 0;
visibility : hidden\9; /* Target only IE7 and IE8 with this hack */
opacity : .01;
-webkit-transition : .2s;
-moz-transition : .2s;
-o-transition : .2s;
transition : .2s;
-moz-border-radius : 5px;
-webkit-border-radius : 5px;
border-radius : 5px;
}
.nano > .pane > .slider {
background: rgba(0,0,0,.5);
position : relative;
margin : 0 1px;
-moz-border-radius : 3px;
-webkit-border-radius : 3px;
border-radius : 3px;
}
.nano:hover > .pane, .pane.active, .pane.flashed {
visibility : visible\9; /* Target only IE7 and IE8 with this hack */
opacity : 0.99;
}
.nano { background: #bba; }
.nano .content { padding: 20px; }
.nano .pane { background: #888; }
.nano .slider { background: #111; }
.nano{width:310px;height:300px;}
.content{border:1px solid blue;}
#loq{width:270px;height:280px;border:1px solid red;}
JavaScript
$(document).ready(function() {
$(".nano").nanoScroller();
$("#loq").keyup(function(){
var lht = parseInt($(this).css('lineHeight'));
var l1 = $(this).attr('scrollHeight');
//var lines = $(this).attr('scrollHeight')/lht;
/*if(lines>7){
$(".nano").nanoScroller();
}*/
$("#trigger").html());
});
$.fn.hasScrollBar = function() { return this.get(0).scrollHeight > this.height(); }
})(jQuery);
$('#loq').hasScrollBar();
});