Skip to content
This repository
Browse code

Add support for -pie-track-hover property to allow disabling of autom…

…atic :hover tracking
  • Loading branch information...
commit 7f94811e098295566c54adbeb81e658230590f28 1 parent e7d3630
Jason Johnston authored

Showing 2 changed files with 63 additions and 2 deletions. Show diff stats Hide diff stats

  1. +8 2 sources/Element.js
  2. +55 0 tests/track-hover_track-active.html
10 sources/Element.js
@@ -5,6 +5,7 @@ PIE.Element = (function() {
5 5 lazyInitCssProp = PIE.CSS_PREFIX + 'lazy-init',
6 6 pollCssProp = PIE.CSS_PREFIX + 'poll',
7 7 trackActiveCssProp = PIE.CSS_PREFIX + 'track-active',
  8 + trackHoverCssProp = PIE.CSS_PREFIX + 'track-hover',
8 9 hoverClass = PIE.CLASS_PREFIX + 'hover',
9 10 activeClass = PIE.CLASS_PREFIX + 'active',
10 11 focusClass = PIE.CLASS_PREFIX + 'focus',
@@ -78,6 +79,7 @@ PIE.Element = (function() {
78 79 cs = el.currentStyle,
79 80 lazy = cs.getAttribute( lazyInitCssProp ) === 'true',
80 81 trackActive = cs.getAttribute( trackActiveCssProp ) !== 'false',
  82 + trackHover = cs.getAttribute( trackHoverCssProp ) !== 'false',
81 83 childRenderers;
82 84
83 85 // Polling for size/position changes: default to on in IE8, off otherwise, overridable by -pie-poll
@@ -180,8 +182,12 @@ PIE.Element = (function() {
180 182 }
181 183 addListener( el, 'onresize', handleMoveOrResize );
182 184 addListener( el, 'onpropertychange', propChanged );
183   - addListener( el, 'onmouseenter', mouseEntered );
184   - addListener( el, 'onmouseleave', mouseLeft );
  185 + if( trackHover ) {
  186 + addListener( el, 'onmouseenter', mouseEntered );
  187 + }
  188 + if( trackHover || trackActive ) {
  189 + addListener( el, 'onmouseleave', mouseLeft );
  190 + }
185 191 if( trackActive ) {
186 192 addListener( el, 'onmousedown', mousePressed );
187 193 }
55 tests/track-hover_track-active.html
... ... @@ -0,0 +1,55 @@
  1 +<!DOCTYPE html>
  2 +
  3 +<html>
  4 +<head>
  5 + <title>-pie-png-fix test</title>
  6 +
  7 + <style>
  8 +
  9 + div {
  10 + behavior: url(../build/PIE.htc);
  11 + border-radius: 20px;
  12 + box-shadow: 0 0 10px blue;
  13 + background: white;
  14 + width: 200px;
  15 + height: 50px;
  16 + padding: 30px;
  17 + margin: 50px;
  18 + }
  19 +
  20 + div.hover:hover {
  21 + border-radius: 30px;
  22 + box-shadow: 0 0 10px green;
  23 + }
  24 + #hover-false {
  25 + -pie-track-hover: false;
  26 + }
  27 +
  28 + div.active:active {
  29 + border-radius: 50px;
  30 + box-shadow: 0 0 20px red;
  31 + }
  32 + #active-false {
  33 + -pie-track-active: false;
  34 + }
  35 +
  36 + </style>
  37 +</head>
  38 +<body>
  39 +
  40 + <div class="hover" id="hover-true">
  41 + -pie-track-hover: true;
  42 + </div>
  43 + <div class="hover" id="hover-false">
  44 + -pie-track-hover: false;
  45 + </div>
  46 +
  47 + <div class="active" id="active-true">
  48 + -pie-track-active: true;
  49 + </div>
  50 + <div class="active" id="active-false">
  51 + -pie-track-active: false;
  52 + </div>
  53 +
  54 +</body>
  55 +</html>

0 comments on commit 7f94811

Please sign in to comment.
Something went wrong with that request. Please try again.