Coder Social home page Coder Social logo

detect-zoom's Introduction

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


基于 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.

detect-zoom's People

Contributors

alphatr avatar asadnauman avatar devinrhode2 avatar iangilman avatar kreymerman avatar l-p avatar matthias-m avatar qtax avatar seyd avatar skeltoac avatar tombigel avatar yonran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.