Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Honor padding on img elements

  • Loading branch information...
commit 2a6ae13d82040f9cf91dec26d2cd0b8f8a1c6e35 1 parent 767eed5
Jason Johnston authored
Showing with 9 additions and 4 deletions.
  1. +6 −4 sources/ImgRenderer.js
  2. +3 −0  tests/img.html
View
10 sources/ImgRenderer.js
@@ -35,6 +35,8 @@ PIE.ImgRenderer = PIE.RendererBase.newRenderer( {
el = this.targetElement,
src = el.src,
round = Math.round,
+ cs = el.currentStyle,
+ getLength = PIE.getLength,
s;
shape.stroked = false;
@@ -44,10 +46,10 @@ PIE.ImgRenderer = PIE.RendererBase.newRenderer( {
shape.coordsize = w * 2 + ',' + h * 2;
shape.coordorigin = '1,1';
shape.path = this.getBoxPath( borderWidths ? {
- t: round( borderWidths['t'].pixels( el ) ),
- r: round( borderWidths['r'].pixels( el ) ),
- b: round( borderWidths['b'].pixels( el ) ),
- l: round( borderWidths['l'].pixels( el ) )
+ t: round( borderWidths['t'].pixels( el ) + getLength( cs.paddingTop ).pixels( el ) ),
+ r: round( borderWidths['r'].pixels( el ) + getLength( cs.paddingRight ).pixels( el ) ),
+ b: round( borderWidths['b'].pixels( el ) + getLength( cs.paddingBottom ).pixels( el ) ),
+ l: round( borderWidths['l'].pixels( el ) + getLength( cs.paddingLeft ).pixels( el ) )
} : 0, 2 );
s = shape.style;
s.width = w;
View
3  tests/img.html
@@ -56,6 +56,9 @@
<h2>With border</h2>
<img src="border.png" style="border:10px solid red;" />
+ <h2>With padding</h2>
+ <img src="border.png" style="border:10px solid red; padding: 5px;" />
+
<h2>Rollover</h2>
<img src="icon-safari.png" onmouseover="this.src='icon-chrome.png'" onmouseout="this.src='icon-safari.png'" />
Please sign in to comment.
Something went wrong with that request. Please try again.