From a52d55957d0833b31f301bb13cc4ece57cd79400 Mon Sep 17 00:00:00 2001 From: maoziliang Date: Tue, 11 Jun 2013 23:44:36 +0800 Subject: [PATCH] Add hover handlers for ie6. Use scripts to add '.hover' class on the `.ps-container` and both scrollbars when then mouse is over them because :hover is not supported except 'a' element. --- src/perfect-scrollbar.css | 12 ++++++++---- src/perfect-scrollbar.js | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/src/perfect-scrollbar.css b/src/perfect-scrollbar.css index 52c5087..1467f41 100644 --- a/src/perfect-scrollbar.css +++ b/src/perfect-scrollbar.css @@ -14,12 +14,14 @@ transition: opacity .2s linear; } -.ps-container:hover .ps-scrollbar-x { +.ps-container:hover .ps-scrollbar-x, +.ps-container.hover .ps-scrollbar-x { opacity: 0.6; filter: alpha(opacity = 60); } -.ps-container .ps-scrollbar-x:hover { +.ps-container .ps-scrollbar-x:hover, +.ps-container .ps-scrollbar-x.hover { opacity: 0.9; filter: alpha(opacity = 90); cursor:default; @@ -46,12 +48,14 @@ transition: opacity .2s linear; } -.ps-container:hover .ps-scrollbar-y { +.ps-container:hover .ps-scrollbar-y, +.ps-container.hover .ps-scrollbar-y { opacity: 0.6; filter: alpha(opacity = 60); } -.ps-container .ps-scrollbar-y:hover { +.ps-container .ps-scrollbar-y:hover, +.ps-container .ps-scrollbar-y.hover { opacity: 0.9; filter: alpha(opacity = 90); cursor: default; diff --git a/src/perfect-scrollbar.js b/src/perfect-scrollbar.js index 9bf04f3..91e93bd 100644 --- a/src/perfect-scrollbar.js +++ b/src/perfect-scrollbar.js @@ -309,6 +309,22 @@ var ieSupport = function (version) { $this.addClass('ie').addClass('ie' + version); + + var bindHoverHandlers = function () { + var mouseenter = function () { + $(this).addClass('hover'); + }; + var mouseleave = function () { + $(this).removeClass('hover'); + }; + $this.bind('mouseenter.perfect-scroll', mouseenter).bind('mouseleave.perfect-scroll', mouseleave); + $scrollbarX.bind('mouseenter.perfect-scroll', mouseenter).bind('mouseleave.perfect-scroll', mouseleave); + $scrollbarY.bind('mouseenter.perfect-scroll', mouseenter).bind('mouseleave.perfect-scroll', mouseleave); + }; + + if (version === 6) { + bindHoverHandlers(); + } }; var isMobile = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent);