Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to trigger zoom out upon page scrolling #29

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ This is largely inspired by [Medium](http://medium.com)'s avatar zoom in effect,

- CSS Transform required. (basically, IE10+)
- Works best on fixed size elements such as `display: block`, `display: inline-block` and `img` elements.
- When zooming out due to page scrolling, element jumps to its proper spot in the document after zooming out to its previous absolute position.
- Avoid using it on long inline text that has natural line wraps.
- When used on mobile, it's best to avoid auto font size adjustments (e.g. set scale fixed to 1).
- Elements with non-rectangular shape will have pixelated edge in Firefox.
Expand All @@ -41,12 +42,13 @@ This is largely inspired by [Medium](http://medium.com)'s avatar zoom in effect,

- #### Zoomerang.config(options)

Takes an options object. Available options (all options take valid CSS values):
Takes an options object. Available options (all style options take valid CSS values):

- `transitionDuration` - default: `'.4s'`
- `transitionTimingFunction` - default: `'cubic-bezier(.4,0,0,1)'`
- `bgColor` - default: `'#fff'`
- `bgOpacity` - default: `1`
- `closeOnScroll` - scrolling triggers zoom-out. default: `false`
- `maxWidth` - max element width when zoomed-in. default: `300`
- `maxHeight` - max element height when zoomed-in. default: `300`
- `deepCopy` - whether to copy innerHTML. If target element has complicated inner structure you might need this to make it work. default: `false`
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ <h1><span class="zoom">Zoomerang.js</span> <a class="gh" href="https://github.co
maxWidth: 400,
bgColor: '#000',
bgOpacity: .85,
closeOnScroll: true,
onOpen: openCallback,
onClose: closeCallback,
onBeforeOpen: beforeOpenCallback,
Expand Down
5 changes: 5 additions & 0 deletions zoomerang.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
bgOpacity: 1,
maxWidth: 300,
maxHeight: 300,
closeOnScroll: false,
onOpen: null,
onClose: null,
onBeforeClose: null,
Expand Down Expand Up @@ -309,6 +310,10 @@
}
})

if (!shown && options.closeOnScroll) {
document.addEventListener('scroll', api.close)
}

return this
}
}
Expand Down