This repository was archived by the owner on Mar 21, 2022. It is now read-only.
- Notifications
You must be signed in to change notification settings - Fork0
Zooming based on windows width
License
NotificationsYou must be signed in to change notification settings
howion/viewRatio
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
0.833 kb JS library to zoom page based on window width.
Download and includeviewRatio.min.js
<scriptsrc="viewRatio.min.js"></script>
Name | Takes | Optional | Defaults To |
---|---|---|---|
width | Int | -- | |
zoomRatio | Float undefined | ✔️ | 1 |
maxWidth | Int undefined | ✔️ | INF |
minWidth | Int undefined | ✔️ | 0 |
.enable()
Enables.scale()
method
.disable()
Disables.scale()
method
.scale()
Scales based onchoices & winWidth
.resetScale()
Removes scale
.scaleTo( $customRatio )
Scales to specified ratio
// CREATE VIEW RATIO OBJECTvar$viewRatio=viewRatio({maxWidth:1920,// STOP ZOOMING IF WIDTH IS BIGGER THAN 1920pxminWidth:480,// STOP ZOOMING IF WIDTH IS SMALLER THAN 480pxwidth:1920,// ZOOM WILL BE BASED ON THIS WIDTHzoomRatio:0.5,// ZOOM WILL BE 0.5 SLOWERzoomRatio:2// ZOOM WILL BE 2x FASTER});// INITAL ZOOM$viewRatio.scale();// FIRE SCALE EVENT ON WINDOW RESIZEwindow.addEventListener('resize',$viewRatio.scale,false);
First of all making something like this was hard due to cross browser support and it still has some problems so itsin development stage for now.
- Edge & IE shows scrollbars on both sides
- Using
fixed
position in scaled element causes element to be not fixed. ( SeeIssue )
About
Zooming based on windows width
Topics
Resources
License
Stars
Watchers
Forks
Packages0
No packages published