gm-util 5.12.3 → 5.12.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "gm-util",
3
- "version": "5.12.3",
3
+ "version": "5.12.6",
4
4
  "description": "",
5
5
  "main": "src/index.js",
6
6
  "scripts": {
7
7
  "test": "echo \"Error: no test specified\" && exit 1",
8
- "precommit": "eslint ./src/",
8
+ "precommit": "eslint --fix ./src/",
9
9
  "publishpatch": "git add --all; git commit -m 'c'; npm version patch; git push origin HEAD:master; npm publish --registry='https://registry.npmjs.org'; cnpm sync gm-util; npm version;"
10
10
  },
11
11
  "repository": {
package/src/index.js CHANGED
@@ -36,6 +36,7 @@ import to from './to'
36
36
  import formatNumber from './formatNumber'
37
37
  import { getLocale, setLocale } from '../locales'
38
38
  import isZoom from './isZoom'
39
+ import isZoom2 from './isZoom2'
39
40
  import { devWarnForHook, devWarn, warn } from './warn'
40
41
 
41
42
  export {
@@ -60,7 +61,7 @@ export {
60
61
  isElementOverViewport,
61
62
  getElementPosition,
62
63
  isZoom,
63
-
64
+ isZoom2,
64
65
  isPathMatch,
65
66
  setTitle, setIco,
66
67
  getScrollTop,
package/src/isZoom.js CHANGED
@@ -1,5 +1,6 @@
1
1
  /**
2
2
  * 检测浏览器缩放. 文章: https://www.yuque.com/iyum9i/uur0qi/cup15r
3
+ * @deprecated 现在不起作用了
3
4
  */
4
5
  export default function isZoom () {
5
6
  const div = document.createElement('div')
package/src/isZoom2.js ADDED
@@ -0,0 +1,85 @@
1
+ /**
2
+ * 检测浏览器缩放
3
+ */
4
+ export default function isZoom2 () {
5
+ const detectZoomFunc = {
6
+ ie: () => { return window.screen.deviceXDPI / window.screen.logicalXDPI },
7
+ firefox: () => { return window.devicePixelRatio ? window.devicePixelRatio : n('min--moz-device-pixel-ratio', '', 0, 10, 20, 1e-4) },
8
+ opera: () => { return window.outerWidth / window.innerWidth },
9
+ chrome: () => {
10
+ if (window.devicePixelRatio) {
11
+ return window.devicePixelRatio
12
+ }
13
+ const o = window.document
14
+ const t = o.createElement('div')
15
+ t.innerHTML = '1'
16
+ t.setAttribute('style', 'font:100px/1em sans-serif-webkit-text-size-adjust:noneposition: absolutetop:-100%')
17
+ o.body.appendChild(t)
18
+ let n = 1e3 / t.clientHeight
19
+ n = Math.round(100 * n) / 100
20
+ o.body.removeChild(t)
21
+ return n
22
+ },
23
+ safari: () => { return window.outerWidth / window.innerWidth }
24
+ }
25
+
26
+ function round2 (number, fractionDigits) {
27
+ return Math.round(number * Math.pow(10, fractionDigits)) / Math.pow(10, fractionDigits)
28
+ }
29
+
30
+ function n (t, n, i, a, s, c) {
31
+ function l (e, o, i) {
32
+ const a = (e + o) / 2
33
+ if (i <= 0 || o - e < c) return a
34
+ const s = '(' + t + ':' + a + n + ')'
35
+ return r(s).matches ? l(a, o, i - 1) : l(e, a, i - 1)
36
+ }
37
+ let r, d, m, p
38
+ let e = window; let o = window.document
39
+ if (e.matchMedia) {
40
+ r = e.matchMedia
41
+ } else {
42
+ d = o.getElementsByTagName('head')[0]
43
+ m = o.createElement('style')
44
+ d.appendChild(m)
45
+ p = o.createElement('div')
46
+ p.className = 'mediaQueryBinarySearch'
47
+ p.style.display = 'none'
48
+ o.body.appendChild(p)
49
+ r = function (e) {
50
+ m.sheet.insertRule('@media ' + e + '{.mediaQueryBinarySearch {text-decoration: underline} }', 0)
51
+ const t = window.getComputedStyle(p, null).textDecoration === 'underline'
52
+ m.sheet.deleteRule(0)
53
+ return { matches: t }
54
+ }
55
+ }
56
+
57
+ let u = l(i, a, s)
58
+ if (p) {
59
+ d.removeChild(m)
60
+ o.body.removeChild(p)
61
+ }
62
+ return u
63
+ }
64
+
65
+ function system () {
66
+ let ua = navigator.userAgent.toLowerCase()
67
+ return ua.indexOf('win') >= 0 ? 'win' : ua.indexOf('mac') >= 0 ? 'mac' : false
68
+ }
69
+
70
+ function getBrowser () {
71
+ let ua = navigator.userAgent.toLowerCase()
72
+ return window.ActiveXObject || 'ActiveXObject' in window ? 'ie' : ua.indexOf('firefox') >= 0 ? 'firefox' : ua.indexOf('chrome') >= 0 ? 'chrome' : ua.indexOf('opera') >= 0 ? 'opera' : ua.indexOf('safari') >= 0 ? 'safari' : void 0
73
+ }
74
+
75
+ function detectZoom () {
76
+ return detectZoomFunc[getBrowser()]()
77
+ }
78
+
79
+ function iszoom (e) {
80
+ return (e.system === 'win' && e.zoom !== 1) || (e.system === 'mac' && e.zoom % 1 !== 0 && e.zoom % 2 !== 0)
81
+ }
82
+
83
+ const zoomData = { zoom: round2(detectZoom(), 2), system: system() }
84
+ return iszoom(zoomData)
85
+ }
@@ -1,7 +0,0 @@
1
- [2019-11-07T21:41:25.027] [INFO] default - 执行命令 git rev-parse --git-dir
2
- [2019-11-07T21:41:25.117] [INFO] default - 切换目录 /Users/liyatang/gm/gm-util
3
- [2019-11-07T21:41:25.120] [INFO] default - 执行命令 git diff
4
- [2019-11-07T21:41:25.195] [INFO] default - 执行命令 git branch | sed -n '/\* /s///p'
5
- [2019-11-07T21:41:25.273] [INFO] default - 执行命令 cat package.json
6
- [2019-11-07T21:41:25.344] [INFO] default - 执行命令 npm version patch && git push origin master:master --tags
7
- [2019-11-07T21:41:39.695] [INFO] default - 执行命令 npm publish