Skip to content

alphatr/detect-zoom

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 

Repository files navigation

跨浏览器实现检测浏览器缩放


基于 https://github.com/yonran/detect-zoom 修改

主要修改一下几点。

  1. 增加对 IE7 的支持
  2. 增加支持检测字体缩放的
  3. 修改 Webkit 在 Chrome 27+ 上面失效的问题
  4. 增加 Demo 演示

Demo

http://alphatr.github.io/detect-zoom/

Usage

Detect-zoom 提供了三个方法:

  • zoom() 返回当前屏幕缩放比.
  • device() 返回在当前屏幕缩放比下的设备像素比 (Read more about devicePixelRatio at QuirksMode)
  • 'zoomText()' 返回文字的缩放比
<script src="detect-zoom.js"></script>
<script>
    var zoom = detectZoom.zoom();
    var device = detectZoom.device();
    console.log(zoom, device);
</script>

AMD Usage

    require(['detect-zoom'], function(detectZoom){
        var zoom = detectZoom.zoom();
    });

Changelog

2013/11/16

  • 增加对 IE7 的支持
  • 增加支持检测字体缩放的
  • 修改 Webkit 在 Chrome 27+ 上面失效的问题
  • 增加 Demo 演示

2013/1/26

  • Repository moved here
  • Refactored most of the code
  • Removed support for older browsers
  • Added support for AMD and CommonJS

2013/1/27

2013/2/05

  • Merged a pull request that fixed zoom on IE being returned X100 (thanks @kreymerman)
  • Refactored the code some more, changed some function names
  • Browser dependent main function is created only on initialization (thanks @jsmaker)
  • Open Issue: Firefox returns zoom and devicePixelRatio the same. Still looking for a solution here.
  • Started versioning - this is version 1.0.0

Bug

在 Retina 屏幕的 FireFox 浏览器会出现问题。

License

Detect-zoom is dual-licensed under the WTFPL and MIT license, at the recipient's choice.

About

Cross Browser Zoom and Pixel Ratio Detector

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%