Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
This repository was archived by the owner on Mar 21, 2022. It is now read-only.
/viewRatioPublic archive

Zooming based on windows width

License

NotificationsYou must be signed in to change notification settings

howion/viewRatio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

0.833 kb JS library to zoom page based on window width.

Usage

Download and includeviewRatio.min.js

<scriptsrc="viewRatio.min.js"></script>

Options

NameTakesOptionalDefaults To
widthInt--
zoomRatioFloatundefined✔️1
maxWidthIntundefined✔️INF
minWidthIntundefined✔️0

Methods

.enable() Enables.scale() method

.disable() Disables.scale() method

.scale() Scales based onchoices & winWidth

.resetScale() Removes scale

.scaleTo( $customRatio ) Scales to specified ratio

Example Usage

// 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);

Last Words

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.

Known Bugs

  • Edge & IE shows scrollbars on both sides
  • Usingfixed position in scaled element causes element to be not fixed. ( SeeIssue )

License

MIT


[8]ページ先頭

©2009-2025 Movatter.jp