jquery自定义滚动条插件示例分享


Posted in Javascript onFebruary 21, 2014
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>自定义滚动条插件</title>
<style type="text/css">
<!--
html,body{height:100%;}
body {margin:0; padding:0; background:#111 url(mcs_demo_bg.jpg) no-repeat; min-width:1100px; min-height:940px;}
a:link,a:visited,a:hover{color:#C30;}
.info{position:absolute; left:40px; top:20px; width:260px; color:#CCC; font-family:"Lobster",Arial, Helvetica, sans-serif; font-size:18px; padding:5px;}
.info .big{font-size:34px;}
.postURL{position:absolute; top:20px; right:20px; display:block; width:100px; height:100px; background:url(plugin_homepage.png) no-repeat; z-index:10;}
.blue{color:#09C;}
h1{padding:10px 5px; margin:10px 0; color:#fff; font-family:"Yanone Kaffeesatz", Georgia, "Times New Roman", Times, serif; font-size:36px; font-weight:normal; line-height:34px;}
h2{font-family:"Lobster",Arial, Helvetica, sans-serif; font-size:22px; font-weight:normal; color:#09C; margin-left:5px;}
h3{font-family:"Lobster",Arial, Helvetica, sans-serif; font-size:26px; font-weight:normal; color:#31231E; margin-left:10px;}
h4{font-family:"Lobster",Arial, Helvetica, sans-serif; font-size:18px; font-weight:normal; color:#C30; margin:5px 10px;}
-->
</style>
<link href="jquery.mCustomScrollbar.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript" src="jquery.easing.1.3.js"></script>
<script type="text/javascript" src="jquery.mousewheel.min.js"></script>
</head>
<body>
<div class="info"><span class="blue">malihu </span><br /><span class="big">Custom Scrollbar </span>plugin</div>
<!-- content block -->
<div id="mcs_container">
 <div class="customScrollBox">
  <div class="container">
      <div class="content">
          <h1>Adjustable scroller height with easing</h1>
    <p><a href="#" onclick="LoadNewContent('mcs_container','dynamic_content.html');return false">Load new content dynamically</a></p>
             <p style="color:#C96;">Aliquam erat volutpat. Maecenas non tortor nulla, non malesuada velit. Nullam felis tellus, tristique nec egestas in, luctus sed diam. Suspendisse potenti. </p>
             <p class="alt"><em>consectetur adipiscing elit. Nulla consectetur libero consectetur quam consequat nec tincidunt massa feugiat. Donec egestas mi turpis. Fusce adipiscing dui eu metus gravida vel facilisis ligula iaculis. Cras a rhoncus massa. Donec sed purus eget nunc placerat consequat.</em></p>
             <img src="mcsImg1.jpg" />
             <p>Aliquam erat volutpat. Maecenas non tortor nulla, non malesuada velit. Nullam felis tellus, tristique nec egestas in, luctus sed diam. Suspendisse potenti. Cras venenatis condimentum nibh a mollis. Duis id sapien nibh. Vivamus porttitor, felis quis blandit tincidunt, erat magna scelerisque urna, a faucibus erat nisl eget nisl. Aliquam consequat turpis id velit egestas a posuere orci semper. Mauris suscipit erat quis urna adipiscing ultricies. In hac habitasse platea dictumst. Nulla scelerisque lorem quis dui sagittis egestas.</p> 
                <p class="alt">Etiam sed massa felis, aliquam pellentesque est. Quisque quis ante tortor, sed egestas risus. Maecenas varius adipiscing nulla, nec rhoncus est mattis id. Aenean blandit convallis nisi at fringilla. Nunc id massa eu sapien fringilla posuere.</p>
             <img src="mcsImg2.jpg" />
             <p style="color:#C96;">Nam eu arcu at purus tincidunt pharetra ultrices at ipsum. Mauris urna nunc, vulputate quis gravida in, pharetra id mauris. Ut sit amet mi dictum nulla lobortis adipiscing quis a nulla. Etiam diam ante, imperdiet vel scelerisque eget, venenatis non eros. Praesent ipsum sem, eleifend ut gravida eget, tristique id orci. Nam adipiscing, sem in mattis vulputate, risus libero adipiscing risus, eu molestie mi justo eget nulla.</p> 
                <p>Cras venenatis metus et urna egestas non laoreet orci rutrum. Pellentesque ullamcorper dictum nisl a tincidunt. Quisque et lacus quam, sed hendrerit mi. Mauris pretium, sapien et malesuada pulvinar, lorem leo viverra leo, et egestas mi nisl quis odio. </p>
                <p>Aliquam erat volutpat. Sed urna arcu, tempus eu vulputate adipiscing, consectetur et orci. Vivamus congue, nunc vitae fringilla convallis, libero massa lacinia lorem, id convallis mauris elit ut leo. Nulla vel odio sem. Duis lorem urna, congue vitae rutrum sed, tincidunt vel tortor. In hac habitasse platea dictumst. Nunc vitae enim ante, vitae facilisis massa. Etiam sagittis sapien at nibh fermentum consectetur convallis lacus blandit.</p>
             <h1>the end.</h1>
   </div>
  </div>
  <div class="dragger_container">
      <div class="dragger"></div>
  </div>
 </div>
    <a href="#" class="scrollUpBtn"></a> <a href="#" class="scrollDownBtn"></a>
</div>
<!-- content block -->
<div id="mcs2_container">
 <div class="customScrollBox">
  <div class="container">
      <div class="content">
          <h1>Adjustable scroller height without easing</h1>
    <p><a href="#" onclick="LoadNewContent('mcs2_container','dynamic_content.html');return false">Load new content dynamically</a></p>
             <p class="alt">Aliquam erat volutpat. Maecenas non tortor nulla, non malesuada velit. Nullam felis tellus, tristique nec egestas in, luctus sed diam.</p>
             <p><em>consectetur adipiscing elit. Nulla consectetur libero consectetur quam consequat nec tincidunt massa feugiat. Fusce adipiscing dui eu metus gravida vel facilisis ligula iaculis.</em></p>
                <img src="mcsImg2.jpg" />
             <p>In hac habitasse platea dictumst. Aliquam erat volutpat. Maecenas non tortor nulla, non malesuada velit. Nullam felis tellus, tristique nec egestas in, luctus sed diam. Suspendisse potenti. Cras venenatis condimentum nibh a mollis. Duis id sapien nibh. Vivamus porttitor, felis quis blandit tincidunt, erat magna scelerisque urna, a faucibus erat nisl eget nisl. Aliquam consequat turpis id velit egestas a posuere orci semper.</p>
             <h1>the end.</h1>
   </div>
  </div>
  <div class="dragger_container">
      <div class="dragger">▒</div>
  </div>
 </div>
</div>
<!-- content block -->
<div id="mcs3_container">
 <div class="customScrollBox">
  <div class="container">
      <div class="content">
          <h3>Adjustable scroller height with 1/3 range and greater easing, without mouse-wheel support</h3>
             <p>Aliquam erat volutpat. Maecenas non tortor nulla, non malesuada velit. Nullam felis tellus, tristique nec egestas in, luctus sed diam. Suspendisse potenti. </p>
             <p>consectetur adipiscing elit. Nulla consectetur libero consectetur quam consequat nec tincidunt massa feugiat. Donec egestas mi turpis. Fusce adipiscing dui eu metus gravida vel facilisis ligula iaculis. Cras a rhoncus massa. Donec sed purus eget nunc placerat consequat. Nulla facilisi. Nam vel augue odio, dignissim mattis dolor. Nullam at mi aliquet quam interdum consectetur. Duis tempus mauris in lorem dictum eget euismod urna aliquet. In vestibulum tempor porta.</p>
             <p>Morbi porttitor rhoncus nisi, eget vehicula quam sodales at. Maecenas ipsum tellus, mollis quis faucibus id, feugiat molestie lacus. Sed nec quam purus, at condimentum quam. Integer imperdiet faucibus urna tempus consectetur. Nullam non purus ligula, et tincidunt nulla. Aenean tincidunt, dui at elementum egestas, sem turpis volutpat turpis, nec congue purus quam quis ligula. Nam dictum rutrum pulvinar. Aenean sed cursus purus. Curabitur non dui eu nibh fermentum interdum a id dui. Fusce iaculis blandit tellus, nec tincidunt massa adipiscing id. Aliquam dui massa, porttitor eget molestie at, semper eu libero. Suspendisse sit amet velit et elit viverra convallis vitae ut turpis. Maecenas vehicula blandit odio sollicitudin eleifend. Curabitur molestie porta neque ac imperdiet. Phasellus nec nisl non lectus pharetra porttitor sit amet tristique mi. Integer vehicula vestibulum sem vitae varius. Ut scelerisque semper posuere.</p>
                <img src="mcsImg1.jpg" />
             <p>Aliquam erat volutpat. Maecenas non tortor nulla, non malesuada velit. Nullam felis tellus, tristique nec egestas in, luctus sed diam. Suspendisse potenti. Cras venenatis condimentum nibh a mollis. Duis id sapien nibh. Vivamus porttitor, felis quis blandit tincidunt, erat magna scelerisque urna, a faucibus erat nisl eget nisl. Aliquam consequat turpis id velit egestas a posuere orci semper. Mauris suscipit erat quis urna adipiscing ultricies. In hac habitasse platea dictumst. Nulla scelerisque lorem quis dui sagittis egestas. Etiam sed massa felis, aliquam pellentesque est. Quisque quis ante tortor, sed egestas risus. Maecenas varius adipiscing nulla, nec rhoncus est mattis id. Aenean blandit convallis nisi at fringilla. Nunc id massa eu sapien fringilla posuere.</p>
             <img src="mcsImg2.jpg" />
             <p>Nam eu arcu at purus tincidunt pharetra ultrices at ipsum. Mauris urna nunc, vulputate quis gravida in, pharetra id mauris. Ut sit amet mi dictum nulla lobortis adipiscing quis a nulla. Etiam diam ante, imperdiet vel scelerisque eget, venenatis non eros. Praesent ipsum sem, eleifend ut gravida eget, tristique id orci. Nam adipiscing, sem in mattis vulputate, risus libero adipiscing risus, eu molestie mi justo eget nulla. Cras venenatis metus et urna egestas non laoreet orci rutrum. Pellentesque ullamcorper dictum nisl a tincidunt. Quisque et lacus quam, sed hendrerit mi. Mauris pretium, sapien et malesuada pulvinar, lorem leo viverra leo, et egestas mi nisl quis odio. Aliquam erat volutpat. Sed urna arcu, tempus eu vulputate adipiscing, consectetur et orci. Vivamus congue, nunc vitae fringilla convallis, libero massa lacinia lorem, id convallis mauris elit ut leo. Nulla vel odio sem. Duis lorem urna, congue vitae rutrum sed, tincidunt vel tortor. In hac habitasse platea dictumst. Nunc vitae enim ante, vitae facilisis massa. Etiam sagittis sapien at nibh fermentum consectetur convallis lacus blandit.</p>
                <img src="mcsImg1.jpg" />
             <p>Aliquam erat volutpat. Maecenas non tortor nulla, non malesuada velit. Nullam felis tellus, tristique nec egestas in, luctus sed diam. Suspendisse potenti. Cras venenatis condimentum nibh a mollis. Duis id sapien nibh. Vivamus porttitor, felis quis blandit tincidunt, erat magna scelerisque urna, a faucibus erat nisl eget nisl. Aliquam consequat turpis id velit egestas a posuere orci semper. Mauris suscipit erat quis urna adipiscing ultricies. In hac habitasse platea dictumst. Nulla scelerisque lorem quis dui sagittis egestas. Etiam sed massa felis, aliquam pellentesque est. Quisque quis ante tortor, sed egestas risus. Maecenas varius adipiscing nulla, nec rhoncus est mattis id. Aenean blandit convallis nisi at fringilla. Nunc id massa eu sapien fringilla posuere.</p>
             <img src="mcsImg2.jpg" />
             <p>Nam eu arcu at purus tincidunt pharetra ultrices at ipsum. Mauris urna nunc, vulputate quis gravida in, pharetra id mauris. Ut sit amet mi dictum nulla lobortis adipiscing quis a nulla. Etiam diam ante, imperdiet vel scelerisque eget, venenatis non eros. Praesent ipsum sem, eleifend ut gravida eget, tristique id orci. Nam adipiscing, sem in mattis vulputate, risus libero adipiscing risus, eu molestie mi justo eget nulla. Cras venenatis metus et urna egestas non laoreet orci rutrum. Pellentesque ullamcorper dictum nisl a tincidunt. Quisque et lacus quam, sed hendrerit mi. Mauris pretium, sapien et malesuada pulvinar, lorem leo viverra leo, et egestas mi nisl quis odio. Aliquam erat volutpat. Sed urna arcu, tempus eu vulputate adipiscing, consectetur et orci. Vivamus congue, nunc vitae fringilla convallis, libero massa lacinia lorem, id convallis mauris elit ut leo. Nulla vel odio sem. Duis lorem urna, congue vitae rutrum sed, tincidunt vel tortor. In hac habitasse platea dictumst. Nunc vitae enim ante, vitae facilisis massa. Etiam sagittis sapien at nibh fermentum consectetur convallis lacus blandit.</p>
             <p>the end.</p>
   </div>
  </div>
  <div class="dragger_container">
      <div class="dragger"></div>
  </div>
 </div>
</div>
<!-- content block -->
<div id="mcs4_container">
 <div class="customScrollBox">
  <div class="container">
      <div class="content">
          <h2>Non-adjustable scroller height with minor easing</h2>
             <p>Lorem ipsum dolor sit amet. Aliquam erat volutpat. Maecenas non tortor nulla, non malesuada velit. Nullam felis tellus, tristique nec egestas in, luctus sed diam. Suspendisse potenti. </p>
             <p>consectetur adipiscing elit. Nulla consectetur libero consectetur quam consequat nec tincidunt massa feugiat. Donec egestas mi turpis. Fusce adipiscing dui eu metus gravida vel facilisis ligula iaculis. Cras a rhoncus massa. Donec sed purus eget nunc placerat consequat. Nulla facilisi. Nam vel augue odio, dignissim mattis dolor. Nullam at mi aliquet quam interdum consectetur. Duis tempus mauris in lorem dictum eget euismod urna aliquet. In vestibulum tempor porta.</p>
             <p>Aliquam erat volutpat. Maecenas non tortor nulla, non malesuada velit. Nullam felis tellus, tristique nec egestas in, luctus sed diam. Suspendisse potenti. Cras venenatis condimentum nibh a mollis. Duis id sapien nibh. Vivamus porttitor, felis quis blandit tincidunt, erat magna scelerisque urna, a faucibus erat nisl eget nisl. Aliquam consequat turpis id velit egestas a posuere orci semper. Mauris suscipit erat quis urna adipiscing ultricies. In hac habitasse platea dictumst. Nulla scelerisque lorem quis dui sagittis egestas. Etiam sed massa felis, aliquam pellentesque est. Quisque quis ante tortor, sed egestas risus. Maecenas varius adipiscing nulla, nec rhoncus est mattis id. Aenean blandit convallis nisi at fringilla. Nunc id massa eu sapien fringilla posuere.</p>
             <h2>the end.</h2>
   </div>
  </div>
  <div class="dragger_container">
      <div class="dragger"></div>
  </div>
 </div>
</div>
<!-- content block -->
<div id="mcs5_container">
 <div class="customScrollBox">
  <!-- horWrapper div is important for horizontal scrollers! -->
  <div class="horWrapper"> 
  <div class="container">
      <div class="content">
          <h4>Horizontal non-adjustable image scroller with easing</h4>
             <p><img src="mcsThumb1.jpg" /><img src="mcsThumb2.jpg" /><img src="mcsThumb3.jpg" /><img src="mcsThumb4.jpg" /><img src="mcsThumb5.jpg" /><img src="mcsThumb6.jpg" /><img src="mcsThumb7.jpg" /><img src="mcsThumb8.jpg" /><img src="mcsThumb1.jpg" /><img src="mcsThumb2.jpg" /><img src="mcsThumb3.jpg" /><img src="mcsThumb4.jpg" /></p>
   </div>
  </div>
  <div class="dragger_container">
      <div class="dragger"></div>
  </div>
  </div>
 </div>
    <a href="#" class="scrollUpBtn">⇦</a> <a href="#" class="scrollDownBtn">⇨</a>
    <p align="center"><font color="#FFFFFF">适用浏览器:IE8、360、FireFox、Chrome、Safari、Opera、傲游、搜狗、世界之窗. 
 </font> </p>
<div style=" width:100%; margin:0 auto; float:left; padding-top:20px;">
<div style=" width:700px; margin:0 auto;text-align:center">
</div>
</div>
</div>
<!-- content to show if javascript is disabled -->
<noscript>
 <style type="text/css">
  #mcs_container .customScrollBox,#mcs2_container .customScrollBox,#mcs3_container .customScrollBox,#mcs4_container .customScrollBox,#mcs5_container .customScrollBox{overflow:auto;}
  #mcs_container .dragger_container,#mcs2_container .dragger_container,#mcs3_container .dragger_container,#mcs4_container .dragger_container,#mcs5_container .dragger_container{display:none;}
 </style>
</noscript>
<script>
$(window).load(function() {
 mCustomScrollbars();
});
function mCustomScrollbars(){
 /* 
 malihu custom scrollbar function parameters: 
 1) scroll type (values: "vertical" or "horizontal")
 2) scroll easing amount (0 for no easing) 
 3) scroll easing type 
 4) extra bottom scrolling space for vertical scroll type only (minimum value: 1)
 5) scrollbar height/width adjustment (values: "auto" or "fixed")
 6) mouse-wheel support (values: "yes" or "no")
 7) scrolling via buttons support (values: "yes" or "no")
 8) buttons scrolling speed (values: 1-20, 1 being the slowest)
 */
 $("#mcs_container").mCustomScrollbar("vertical",400,"easeOutCirc",1.05,"auto","yes","yes",10); 
 $("#mcs2_container").mCustomScrollbar("vertical",0,"easeOutCirc",1.05,"auto","yes","no",0); 
 $("#mcs3_container").mCustomScrollbar("vertical",900,"easeOutCirc",1.05,"auto","no","no",0); 
 $("#mcs4_container").mCustomScrollbar("vertical",200,"easeOutCirc",1.25,"fixed","yes","no",0); 
 $("#mcs5_container").mCustomScrollbar("horizontal",500,"easeOutCirc",1,"fixed","yes","yes",20); 
}
/* function to fix the -10000 pixel limit of jquery.animate */
$.fx.prototype.cur = function(){
    if ( this.elem[this.prop] != null && (!this.elem.style || this.elem.style[this.prop] == null) ) {
      return this.elem[ this.prop ];
    }
    var r = parseFloat( jQuery.css( this.elem, this.prop ) );
    return typeof r == 'undefined' ? 0 : r;
}
/* function to load new content dynamically */
function LoadNewContent(id,file){
 $("#"+id+" .customScrollBox .content").load(file,function(){
  mCustomScrollbars();
 });
}
</script>
<script src="jquery.mCustomScrollbar.js"></script>
</body>
</html>
Javascript 相关文章推荐
capacityFixed 基于jquery的类似于新浪微博新消息提示的定位框
May 24 Javascript
深入理解JavaScript系列(15) 函数(Functions)
Apr 12 Javascript
JavaScript中“基本类型”之争小结
Jan 03 Javascript
使用jQuery异步加载 JavaScript脚本解决方案
Apr 20 Javascript
JavaScript实现三阶幻方算法谜题解答
Dec 29 Javascript
JavaScript函数详解
Feb 27 Javascript
基于jquery实现的自动补全功能
Mar 12 Javascript
JS动态显示表格上下frame的方法
Mar 31 Javascript
jQuery实现漂亮实用的商品图片tips提示框效果(无图片箭头+阴影)
Apr 16 Javascript
jQuery简单倒计时效果完整示例
Sep 20 Javascript
微信小程序前端自定义分享的实现方法
Jun 13 Javascript
Vue实现可移动水平时间轴
Jun 29 Javascript
jquery制作搜狐快站页面效果示例分享
Feb 21 #Javascript
利用Jquery实现可多选的下拉框
Feb 21 #Javascript
jquery 无限级下拉菜单的简单实现代码
Feb 21 #Javascript
jQuery 无限级菜单的简单实例
Feb 21 #Javascript
js控制table合并具体实现
Feb 20 #Javascript
js文件Cookie存取值示例代码
Feb 20 #Javascript
js中array的sort()方法使用介绍
Feb 20 #Javascript
You might like
用PHP调用Oracle存储过程的方法
2008/09/12 PHP
PHP 正则表达式小结
2015/02/12 PHP
PHP数组遍历的几种常见方式总结
2019/02/15 PHP
Prototype 学习 工具函数学习($A方法)
2009/07/12 Javascript
javascript 用原型继承来实现对象系统
2010/03/22 Javascript
基于JQuery的数字改变的动画效果--可用来做计数器
2010/08/11 Javascript
基于jQuery实现文本框缩放以及上下移动功能
2014/11/24 Javascript
JS实现漂亮的窗口拖拽效果(可改变大小、最大化、最小化、关闭)
2015/10/10 Javascript
三个js循环的关键字示例(for与while)
2016/02/16 Javascript
谈一谈JS消息机制和事件机制的理解
2016/04/14 Javascript
VUE中v-model和v-for指令详解
2017/06/23 Javascript
解决vue 路由变化页面数据不刷新的问题
2018/03/13 Javascript
微信小程序实现文件、图片上传功能
2020/08/18 Javascript
在Vue中使用antv的示例代码
2020/06/29 Javascript
vue全局使用axios的操作
2020/09/08 Javascript
JS相册图片抖动放大展示效果的示例代码
2021/01/29 Javascript
使用Python编写提取日志中的中文的脚本的方法
2015/04/30 Python
Python入门_浅谈逻辑判断与运算符
2017/05/16 Python
django manage.py扩展自定义命令方法
2018/05/27 Python
解决Python 中英文混输格式对齐的问题
2018/07/16 Python
python: 判断tuple、list、dict是否为空的方法
2018/10/22 Python
对Python发送带header的http请求方法详解
2019/01/02 Python
python-opencv 将连续图片写成视频格式的方法
2019/01/08 Python
python 随机生成10位数密码的实现代码
2019/06/27 Python
python对csv文件追加写入列的方法
2019/08/01 Python
k-means 聚类算法与Python实现代码
2020/06/01 Python
python logging模块的使用
2020/09/07 Python
Python模拟登录和登录跳转的参考示例
2020/10/30 Python
世界领先的以旅馆为主的在线预订平台:Hostelworld
2016/10/09 全球购物
代办委托书怎么写
2014/08/01 职场文书
酒店周年庆活动方案
2014/08/21 职场文书
滞留工资返还协议书
2014/10/19 职场文书
2014年小学教研工作总结
2014/12/06 职场文书
领导欢迎词致辞
2015/01/23 职场文书
教学反思怎么写
2016/02/24 职场文书
用Python实现一个打字速度测试工具来测试你的手速
2021/05/28 Python