Skip to content

Commit

Permalink
0.1.6 - fix percentage sizes + wrapper blocking clicks
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jan 14, 2014
1 parent 942ca9d commit a992101
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 8 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
.DS_Store
.DS_Store
test
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zoomerang",
"version": "0.1.5",
"version": "0.1.6",
"description": "drop-in zoomer for anything",
"main": "zoomerang.js",
"ignore": [
Expand Down
2 changes: 1 addition & 1 deletion component.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zoomerang",
"version": "0.1.5",
"version": "0.1.6",
"description": "drop-in zoomer for anything",
"main": "zoomerang.js",
"scripts": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "zoomerang",
"version": "0.1.5",
"version": "0.1.6",
"description": "drop-in zoomer for anything",
"main": "zoomerang.js",
"repository": {
Expand Down
18 changes: 14 additions & 4 deletions zoomerang.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@

(function () {

// regex
var percentageRE = /^([\d\.]+)%$/

// elements
var overlay = document.createElement('div'),
wrapper = document.createElement('div'),
Expand Down Expand Up @@ -186,10 +189,16 @@
}, true)

// deal with % width and height
setStyle(wrapper, {
width: p.width + 'px',
height: p.height + 'px'
})
var wPctMatch = target.style.width.match(percentageRE),
hPctMatch = target.style.height.match(percentageRE)
if (wPctMatch || hPctMatch) {
var wPct = wPctMatch ? +wPctMatch[1] / 100 : 1,
hPct = hPctMatch ? +hPctMatch[1] / 100 : 1
setStyle(wrapper, {
width: ~~(p.width / wPct) + 'px',
height: ~~(p.height / hPct) + 'px'
})
}

// insert overlay & placeholder
parent.appendChild(overlay)
Expand Down Expand Up @@ -269,6 +278,7 @@
}

overlay.addEventListener('click', api.close)
wrapper.addEventListener('click', api.close)

// umd expose
if (typeof exports == "object") {
Expand Down

0 comments on commit a992101

Please sign in to comment.