@gx-design-vue/create-gx-cli 0.1.2 → 0.1.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (94) hide show
  1. package/package.json +1 -1
  2. package/src/main.js +9 -3
  3. package/template-mobile-vant-cli/.editorconfig +0 -19
  4. package/template-mobile-vant-cli/.env.development +0 -19
  5. package/template-mobile-vant-cli/.env.pro +0 -19
  6. package/template-mobile-vant-cli/.env.production +0 -19
  7. package/template-mobile-vant-cli/.eslintignore +0 -16
  8. package/template-mobile-vant-cli/.eslintrc.js +0 -64
  9. package/template-mobile-vant-cli/.prettierignore +0 -9
  10. package/template-mobile-vant-cli/.stylelintignore +0 -3
  11. package/template-mobile-vant-cli/build/cdn.ts +0 -5
  12. package/template-mobile-vant-cli/build/generateModifyVars.ts +0 -7
  13. package/template-mobile-vant-cli/build/optimizer.ts +0 -18
  14. package/template-mobile-vant-cli/build/plugin/autoImport.ts +0 -26
  15. package/template-mobile-vant-cli/build/plugin/html.ts +0 -26
  16. package/template-mobile-vant-cli/build/plugin/index.ts +0 -50
  17. package/template-mobile-vant-cli/build/plugin/mock.ts +0 -20
  18. package/template-mobile-vant-cli/build/script/postBuild.ts +0 -14
  19. package/template-mobile-vant-cli/index.html +0 -24
  20. package/template-mobile-vant-cli/mock/_createProductionServer.ts +0 -19
  21. package/template-mobile-vant-cli/mock/api/index.ts +0 -66
  22. package/template-mobile-vant-cli/mock/utils.ts +0 -9
  23. package/template-mobile-vant-cli/package.json +0 -64
  24. package/template-mobile-vant-cli/postcss.config.js +0 -8
  25. package/template-mobile-vant-cli/prettier.config.js +0 -18
  26. package/template-mobile-vant-cli/public/favicon.ico +0 -0
  27. package/template-mobile-vant-cli/public/js/flexible.js +0 -44
  28. package/template-mobile-vant-cli/src/App.vue +0 -5
  29. package/template-mobile-vant-cli/src/components/PageContainer/ProSkeleton.tsx +0 -30
  30. package/template-mobile-vant-cli/src/components/PageContainer/index.tsx +0 -114
  31. package/template-mobile-vant-cli/src/components/PageContainer/style.module.less +0 -14
  32. package/template-mobile-vant-cli/src/core/gx-design/index.ts +0 -7
  33. package/template-mobile-vant-cli/src/core/index.ts +0 -12
  34. package/template-mobile-vant-cli/src/core/vant-design/index.ts +0 -4
  35. package/template-mobile-vant-cli/src/design/config.less +0 -0
  36. package/template-mobile-vant-cli/src/design/index.less +0 -3
  37. package/template-mobile-vant-cli/src/design/reset.less +0 -155
  38. package/template-mobile-vant-cli/src/design/root.less +0 -3
  39. package/template-mobile-vant-cli/src/design/vant.less +0 -2
  40. package/template-mobile-vant-cli/src/global.less +0 -1
  41. package/template-mobile-vant-cli/src/hooks/web/index.ts +0 -5
  42. package/template-mobile-vant-cli/src/hooks/web/usePageLoading.ts +0 -55
  43. package/template-mobile-vant-cli/src/layout/BasicLayout.vue +0 -16
  44. package/template-mobile-vant-cli/src/layout/basicLayout.less +0 -11
  45. package/template-mobile-vant-cli/src/main.ts +0 -27
  46. package/template-mobile-vant-cli/src/pages/home.vue +0 -71
  47. package/template-mobile-vant-cli/src/router/index.ts +0 -24
  48. package/template-mobile-vant-cli/src/router/routes.ts +0 -20
  49. package/template-mobile-vant-cli/src/router/typings.ts +0 -8
  50. package/template-mobile-vant-cli/src/services/index.ts +0 -31
  51. package/template-mobile-vant-cli/src/settings/index.ts +0 -10
  52. package/template-mobile-vant-cli/src/store/index.ts +0 -17
  53. package/template-mobile-vant-cli/src/store/modules/global.ts +0 -30
  54. package/template-mobile-vant-cli/src/utils/cryptoJS.ts +0 -39
  55. package/template-mobile-vant-cli/src/utils/env.ts +0 -52
  56. package/template-mobile-vant-cli/src/utils/pageTitle.ts +0 -12
  57. package/template-mobile-vant-cli/src/utils/request/XHR.ts +0 -131
  58. package/template-mobile-vant-cli/src/utils/request/axiosCancel.ts +0 -60
  59. package/template-mobile-vant-cli/src/utils/request/checkStatus.ts +0 -11
  60. package/template-mobile-vant-cli/src/utils/request/index.ts +0 -143
  61. package/template-mobile-vant-cli/src/utils/request/typings.ts +0 -114
  62. package/template-mobile-vant-cli/src/utils/storage.ts +0 -191
  63. package/template-mobile-vant-cli/src/utils/util.ts +0 -32
  64. package/template-mobile-vant-cli/src/utils/validate.ts +0 -28
  65. package/template-mobile-vant-cli/stylelint.config.js +0 -106
  66. package/template-mobile-vant-cli/tsconfig.json +0 -43
  67. package/template-mobile-vant-cli/types/auto-imports.d.ts +0 -61
  68. package/template-mobile-vant-cli/types/components.d.ts +0 -15
  69. package/template-mobile-vant-cli/types/global.d.ts +0 -36
  70. package/template-mobile-vant-cli/types/gx-components.d.ts +0 -13
  71. package/template-mobile-vant-cli/types/module.d.ts +0 -7
  72. package/template-mobile-vant-cli/types/response.d.ts +0 -12
  73. package/template-mobile-vant-cli/vite.config.ts +0 -113
  74. package/template-mobile-vant-html/css/global.css +0 -293
  75. package/template-mobile-vant-html/css/global.css.map +0 -1
  76. package/template-mobile-vant-html/css/global.less +0 -293
  77. package/template-mobile-vant-html/css/index.css +0 -20
  78. package/template-mobile-vant-html/css/index.css.map +0 -1
  79. package/template-mobile-vant-html/css/index.less +0 -21
  80. package/template-mobile-vant-html/image/disconnected.svg +0 -60
  81. package/template-mobile-vant-html/image/empty.svg +0 -52
  82. package/template-mobile-vant-html/image/error.svg +0 -53
  83. package/template-mobile-vant-html/image/loading.svg +0 -1
  84. package/template-mobile-vant-html/index.html +0 -91
  85. package/template-mobile-vant-html/js/index.js +0 -29
  86. package/template-mobile-vant-html/js/plugin/day.min.js +0 -1
  87. package/template-mobile-vant-html/js/plugin/fastclick.js +0 -730
  88. package/template-mobile-vant-html/js/plugin/jquery.min.js +0 -2
  89. package/template-mobile-vant-html/js/plugin/rem.js +0 -28
  90. package/template-mobile-vant-html/js/utils/appUtil.js +0 -70
  91. package/template-mobile-vant-html/js/utils/config.js +0 -3
  92. package/template-mobile-vant-html/js/utils/request.js +0 -61
  93. package/template-mobile-vant-html/js/utils/utils.js +0 -65
  94. package/template-mobile-vant-html/js/utils/validate.js +0 -292
@@ -1,730 +0,0 @@
1
- ;(function () {
2
- 'use strict'
3
- /**
4
- * @preserve FastClick: polyfill to remove click delays on browsers with touch UIs.
5
- *
6
- * @codingstandard ftlabs-jsv2
7
- * @copyright The Financial Times Limited [All Rights Reserved]
8
- * @license MIT License (see LICENSE.txt)
9
- */
10
- /*jslint browser:true, node:true*/
11
-
12
- /*global define, Event, Node*/
13
- /**
14
- * Instantiate fast-clicking listeners on the specified layer.
15
- *
16
- * @constructor
17
- * @param {Element} layer The layer to listen on
18
- * @param {Object} [options={}] The options to override the defaults
19
- */
20
- function FastClick(layer, options) {
21
- var oldOnClick
22
- options = options || {}
23
- /**
24
- * Whether a click is currently being tracked.
25
- *
26
- * @type boolean
27
- */
28
- this.trackingClick = false
29
- /**
30
- * Timestamp for when click tracking started.
31
- *
32
- * @type number
33
- */
34
- this.trackingClickStart = 0
35
- /**
36
- * The element being tracked for a click.
37
- *
38
- * @type EventTarget
39
- */
40
- this.targetElement = null
41
- /**
42
- * X-coordinate of touch start event.
43
- *
44
- * @type number
45
- */
46
- this.touchStartX = 0
47
- /**
48
- * Y-coordinate of touch start event.
49
- *
50
- * @type number
51
- */
52
- this.touchStartY = 0
53
- /**
54
- * ID of the last touch, retrieved from Touch.identifier.
55
- *
56
- * @type number
57
- */
58
- this.lastTouchIdentifier = 0
59
- /**
60
- * Touchmove boundary, beyond which a click will be cancelled.
61
- *
62
- * @type number
63
- */
64
- this.touchBoundary = options.touchBoundary || 10
65
- /**
66
- * The FastClick layer.
67
- *
68
- * @type Element
69
- */
70
- this.layer = layer
71
- /**
72
- * The minimum time between tap(touchstart and touchend) events
73
- *
74
- * @type number
75
- */
76
- this.tapDelay = options.tapDelay || 200
77
- /**
78
- * The maximum time for a tap
79
- *
80
- * @type number
81
- */
82
- this.tapTimeout = options.tapTimeout || 700
83
- if (FastClick.notNeeded(layer)) {
84
- return
85
- }
86
-
87
- // Some old versions of Android don't have Function.prototype.bind
88
- function bind(method, context) {
89
- return function () { return method.apply(context, arguments) }
90
- }
91
-
92
- var methods = [
93
- 'onMouse',
94
- 'onClick',
95
- 'onTouchStart',
96
- 'onTouchMove',
97
- 'onTouchEnd',
98
- 'onTouchCancel'
99
- ]
100
- var context = this
101
- for (var i = 0, l = methods.length; i < l; i++) {
102
- context[methods[i]] = bind(context[methods[i]], context)
103
- }
104
- // Set up event handlers as required
105
- if (deviceIsAndroid) {
106
- layer.addEventListener('mouseover', this.onMouse, true)
107
- layer.addEventListener('mousedown', this.onMouse, true)
108
- layer.addEventListener('mouseup', this.onMouse, true)
109
- }
110
- layer.addEventListener('click', this.onClick, true)
111
- layer.addEventListener('touchstart', this.onTouchStart, false)
112
- layer.addEventListener('touchmove', this.onTouchMove, false)
113
- layer.addEventListener('touchend', this.onTouchEnd, false)
114
- layer.addEventListener('touchcancel', this.onTouchCancel, false)
115
- // Hack is required for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
116
- // which is how FastClick normally stops click events bubbling to callbacks registered on the FastClick
117
- // layer when they are cancelled.
118
- if (!Event.prototype.stopImmediatePropagation) {
119
- layer.removeEventListener = function (type, callback, capture) {
120
- var rmv = Node.prototype.removeEventListener
121
- if (type === 'click') {
122
- rmv.call(layer, type, callback.hijacked || callback, capture)
123
- } else {
124
- rmv.call(layer, type, callback, capture)
125
- }
126
- }
127
- layer.addEventListener = function (type, callback, capture) {
128
- var adv = Node.prototype.addEventListener
129
- if (type === 'click') {
130
- adv.call(layer, type, callback.hijacked || (callback.hijacked = function (event) {
131
- if (!event.propagationStopped) {
132
- callback(event)
133
- }
134
- }), capture)
135
- } else {
136
- adv.call(layer, type, callback, capture)
137
- }
138
- }
139
- }
140
- // If a handler is already declared in the element's onclick attribute, it will be fired before
141
- // FastClick's onClick handler. Fix this by pulling out the user-defined handler function and
142
- // adding it as listener.
143
- if (typeof layer.onclick === 'function') {
144
- // Android browser on at least 3.2 requires a new reference to the function in layer.onclick
145
- // - the old one won't work if passed to addEventListener directly.
146
- oldOnClick = layer.onclick
147
- layer.addEventListener('click', function (event) {
148
- oldOnClick(event)
149
- }, false)
150
- layer.onclick = null
151
- }
152
- }
153
-
154
- /**
155
- * Windows Phone 8.1 fakes user agent string to look like Android and iPhone.
156
- *
157
- * @type boolean
158
- */
159
- var deviceIsWindowsPhone = navigator.userAgent.indexOf('Windows Phone') >= 0
160
- /**
161
- * Android requires exceptions.
162
- *
163
- * @type boolean
164
- */
165
- var deviceIsAndroid = navigator.userAgent.indexOf('Android') > 0 && !deviceIsWindowsPhone
166
- /**
167
- * iOS requires exceptions.
168
- *
169
- * @type boolean
170
- */
171
- var deviceIsIOS = /iP(ad|hone|od)/.test(navigator.userAgent) && !deviceIsWindowsPhone
172
- /**
173
- * iOS 4 requires an exception for select elements.
174
- *
175
- * @type boolean
176
- */
177
- var deviceIsIOS4 = deviceIsIOS && (/OS 4_\d(_\d)?/).test(navigator.userAgent)
178
- /**
179
- * iOS 6.0-7.* requires the target element to be manually derived
180
- *
181
- * @type boolean
182
- */
183
- var deviceIsIOSWithBadTarget = deviceIsIOS && (/OS [6-7]_\d/).test(navigator.userAgent)
184
- /**
185
- * BlackBerry requires exceptions.
186
- *
187
- * @type boolean
188
- */
189
- var deviceIsBlackBerry10 = navigator.userAgent.indexOf('BB10') > 0
190
- /**
191
- * Determine whether a given element requires a native click.
192
- *
193
- * @param {EventTarget|Element} target Target DOM element
194
- * @returns {boolean} Returns true if the element needs a native click
195
- */
196
- FastClick.prototype.needsClick = function (target) {
197
- switch (target.nodeName.toLowerCase()) {
198
-
199
- // Don't send a synthetic click to disabled inputs (issue #62)
200
- case 'button':
201
- case 'select':
202
- case 'textarea':
203
- if (target.disabled) {
204
- return true
205
- }
206
- break
207
- case 'input':
208
- // File inputs need real clicks on iOS 6 due to a browser bug (issue #68)
209
- if ((deviceIsIOS && target.type === 'file') || target.disabled) {
210
- return true
211
- }
212
- break
213
- case 'label':
214
- case 'iframe': // iOS8 homescreen apps can prevent events bubbling into frames
215
- case 'video':
216
- return true
217
- }
218
- return (/\bneedsclick\b/).test(target.className)
219
- }
220
- /**
221
- * Determine whether a given element requires a call to focus to simulate click into element.
222
- *
223
- * @param {EventTarget|Element} target Target DOM element
224
- * @returns {boolean} Returns true if the element requires a call to focus to simulate native click.
225
- */
226
- FastClick.prototype.needsFocus = function (target) {
227
- switch (target.nodeName.toLowerCase()) {
228
- case 'textarea':
229
- return true
230
- case 'select':
231
- return !deviceIsAndroid
232
- case 'input':
233
- switch (target.type) {
234
- case 'button':
235
- case 'checkbox':
236
- case 'file':
237
- case 'image':
238
- case 'radio':
239
- case 'submit':
240
- return false
241
- }
242
- // No point in attempting to focus disabled inputs
243
- return !target.disabled && !target.readOnly
244
- default:
245
- return (/\bneedsfocus\b/).test(target.className)
246
- }
247
- }
248
- /**
249
- * Send a click event to the specified element.
250
- *
251
- * @param {EventTarget|Element} targetElement
252
- * @param {Event} event
253
- */
254
- FastClick.prototype.sendClick = function (targetElement, event) {
255
- var clickEvent, touch
256
- // On some Android devices activeElement needs to be blurred otherwise the synthetic click will have no effect (#24)
257
- if (document.activeElement && document.activeElement !== targetElement) {
258
- document.activeElement.blur()
259
- }
260
- touch = event.changedTouches[0]
261
- // Synthesise a click event, with an extra attribute so it can be tracked
262
- clickEvent = document.createEvent('MouseEvents')
263
- clickEvent.initMouseEvent(
264
- this.determineEventType(targetElement),
265
- true,
266
- true,
267
- window,
268
- 1,
269
- touch.screenX,
270
- touch.screenY,
271
- touch.clientX,
272
- touch.clientY,
273
- false,
274
- false,
275
- false,
276
- false,
277
- 0,
278
- null
279
- )
280
- clickEvent.forwardedTouchEvent = true
281
- targetElement.dispatchEvent(clickEvent)
282
- }
283
- FastClick.prototype.determineEventType = function (targetElement) {
284
- //Issue #159: Android Chrome Select Box does not open with a synthetic click event
285
- if (deviceIsAndroid && targetElement.tagName.toLowerCase() === 'select') {
286
- return 'mousedown'
287
- }
288
- return 'click'
289
- }
290
- /**
291
- * @param {EventTarget|Element} targetElement
292
- */
293
- FastClick.prototype.focus = function (targetElement) {
294
- var length
295
- // Issue #160: on iOS 7, some input elements (e.g. date datetime month) throw a vague TypeError on setSelectionRange. These elements don't have an integer value for the selectionStart and selectionEnd properties, but unfortunately that can't be used for detection because accessing the properties also throws a TypeError. Just check the type instead. Filed as Apple bug #15122724.
296
- if (deviceIsIOS &&
297
- targetElement.setSelectionRange &&
298
- targetElement.type.indexOf('date') !==
299
- 0 &&
300
- targetElement.type !==
301
- 'time' &&
302
- targetElement.type !==
303
- 'month' &&
304
- targetElement.type !==
305
- 'email') {
306
- length = targetElement.value.length
307
- targetElement.setSelectionRange(length, length)
308
- } else {
309
- targetElement.focus()
310
- }
311
- }
312
- /**
313
- * Check whether the given target element is a child of a scrollable layer and if so, set a flag on it.
314
- *
315
- * @param {EventTarget|Element} targetElement
316
- */
317
- FastClick.prototype.updateScrollParent = function (targetElement) {
318
- var scrollParent, parentElement
319
- scrollParent = targetElement.fastClickScrollParent
320
- // Attempt to discover whether the target element is contained within a scrollable layer. Re-check if the
321
- // target element was moved to another parent.
322
- if (!scrollParent || !scrollParent.contains(targetElement)) {
323
- parentElement = targetElement
324
- do {
325
- if (parentElement.scrollHeight > parentElement.offsetHeight) {
326
- scrollParent = parentElement
327
- targetElement.fastClickScrollParent = parentElement
328
- break
329
- }
330
- parentElement = parentElement.parentElement
331
- } while (parentElement)
332
- }
333
- // Always update the scroll top tracker if possible.
334
- if (scrollParent) {
335
- scrollParent.fastClickLastScrollTop = scrollParent.scrollTop
336
- }
337
- }
338
- /**
339
- * @param {EventTarget} targetElement
340
- * @returns {Element|EventTarget}
341
- */
342
- FastClick.prototype.getTargetElementFromEventTarget = function (eventTarget) {
343
- // On some older browsers (notably Safari on iOS 4.1 - see issue #56) the event target may be a text node.
344
- if (eventTarget.nodeType === Node.TEXT_NODE) {
345
- return eventTarget.parentNode
346
- }
347
- return eventTarget
348
- }
349
- /**
350
- * On touch start, record the position and scroll offset.
351
- *
352
- * @param {Event} event
353
- * @returns {boolean}
354
- */
355
- FastClick.prototype.onTouchStart = function (event) {
356
- var targetElement, touch, selection
357
- // Ignore multiple touches, otherwise pinch-to-zoom is prevented if both fingers are on the FastClick element (issue #111).
358
- if (event.targetTouches.length > 1) {
359
- return true
360
- }
361
- targetElement = this.getTargetElementFromEventTarget(event.target)
362
- touch = event.targetTouches[0]
363
- if (deviceIsIOS) {
364
- // Only trusted events will deselect text on iOS (issue #49)
365
- selection = window.getSelection()
366
- if (selection.rangeCount && !selection.isCollapsed) {
367
- return true
368
- }
369
- if (!deviceIsIOS4) {
370
- // Weird things happen on iOS when an alert or confirm dialog is opened from a click event callback (issue #23):
371
- // when the user next taps anywhere else on the page, new touchstart and touchend events are dispatched
372
- // with the same identifier as the touch event that previously triggered the click that triggered the alert.
373
- // Sadly, there is an issue on iOS 4 that causes some normal touch events to have the same identifier as an
374
- // immediately preceeding touch event (issue #52), so this fix is unavailable on that platform.
375
- // Issue 120: touch.identifier is 0 when Chrome dev tools 'Emulate touch events' is set with an iOS device UA string,
376
- // which causes all touch events to be ignored. As this block only applies to iOS, and iOS identifiers are always long,
377
- // random integers, it's safe to to continue if the identifier is 0 here.
378
- if (touch.identifier && touch.identifier === this.lastTouchIdentifier) {
379
- event.preventDefault()
380
- return false
381
- }
382
- this.lastTouchIdentifier = touch.identifier
383
- // If the target element is a child of a scrollable layer (using -webkit-overflow-scrolling: touch) and:
384
- // 1) the user does a fling scroll on the scrollable layer
385
- // 2) the user stops the fling scroll with another tap
386
- // then the event.target of the last 'touchend' event will be the element that was under the user's finger
387
- // when the fling scroll was started, causing FastClick to send a click event to that layer - unless a check
388
- // is made to ensure that a parent layer was not scrolled before sending a synthetic click (issue #42).
389
- this.updateScrollParent(targetElement)
390
- }
391
- }
392
- this.trackingClick = true
393
- this.trackingClickStart = event.timeStamp
394
- this.targetElement = targetElement
395
- this.touchStartX = touch.pageX
396
- this.touchStartY = touch.pageY
397
- // Prevent phantom clicks on fast double-tap (issue #36)
398
- if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
399
- event.preventDefault()
400
- }
401
- return true
402
- }
403
- /**
404
- * Based on a touchmove event object, check whether the touch has moved past a boundary since it started.
405
- *
406
- * @param {Event} event
407
- * @returns {boolean}
408
- */
409
- FastClick.prototype.touchHasMoved = function (event) {
410
- var touch = event.changedTouches[0], boundary = this.touchBoundary
411
- if (Math.abs(touch.pageX - this.touchStartX) > boundary || Math.abs(touch.pageY - this.touchStartY) > boundary) {
412
- return true
413
- }
414
- return false
415
- }
416
- /**
417
- * Update the last position.
418
- *
419
- * @param {Event} event
420
- * @returns {boolean}
421
- */
422
- FastClick.prototype.onTouchMove = function (event) {
423
- if (!this.trackingClick) {
424
- return true
425
- }
426
- // If the touch has moved, cancel the click tracking
427
- if (this.targetElement !== this.getTargetElementFromEventTarget(event.target) || this.touchHasMoved(event)) {
428
- this.trackingClick = false
429
- this.targetElement = null
430
- }
431
- return true
432
- }
433
- /**
434
- * Attempt to find the labelled control for the given label element.
435
- *
436
- * @param {EventTarget|HTMLLabelElement} labelElement
437
- * @returns {Element|null}
438
- */
439
- FastClick.prototype.findControl = function (labelElement) {
440
- // Fast path for newer browsers supporting the HTML5 control attribute
441
- if (labelElement.control !== undefined) {
442
- return labelElement.control
443
- }
444
- // All browsers under test that support touch events also support the HTML5 htmlFor attribute
445
- if (labelElement.htmlFor) {
446
- return document.getElementById(labelElement.htmlFor)
447
- }
448
- // If no for attribute exists, attempt to retrieve the first labellable descendant element
449
- // the list of which is defined here: http://www.w3.org/TR/html5/forms.html#category-label
450
- return labelElement.querySelector(
451
- 'button, input:not([type=hidden]), keygen, meter, output, progress, select, textarea')
452
- }
453
- /**
454
- * On touch end, determine whether to send a click event at once.
455
- *
456
- * @param {Event} event
457
- * @returns {boolean}
458
- */
459
- FastClick.prototype.onTouchEnd = function (event) {
460
- var forElement, trackingClickStart, targetTagName, scrollParent, touch, targetElement = this.targetElement
461
- if (!this.trackingClick) {
462
- return true
463
- }
464
- // Prevent phantom clicks on fast double-tap (issue #36)
465
- if ((event.timeStamp - this.lastClickTime) < this.tapDelay) {
466
- this.cancelNextClick = true
467
- return true
468
- }
469
- if ((event.timeStamp - this.trackingClickStart) > this.tapTimeout) {
470
- return true
471
- }
472
- // Reset to prevent wrong click cancel on input (issue #156).
473
- this.cancelNextClick = false
474
- this.lastClickTime = event.timeStamp
475
- trackingClickStart = this.trackingClickStart
476
- this.trackingClick = false
477
- this.trackingClickStart = 0
478
- // On some iOS devices, the targetElement supplied with the event is invalid if the layer
479
- // is performing a transition or scroll, and has to be re-detected manually. Note that
480
- // for this to function correctly, it must be called *after* the event target is checked!
481
- // See issue #57; also filed as rdar://13048589 .
482
- if (deviceIsIOSWithBadTarget) {
483
- touch = event.changedTouches[0]
484
- // In certain cases arguments of elementFromPoint can be negative, so prevent setting targetElement to null
485
- targetElement = document.elementFromPoint(touch.pageX - window.pageXOffset, touch.pageY - window.pageYOffset) ||
486
- targetElement
487
- targetElement.fastClickScrollParent = this.targetElement.fastClickScrollParent
488
- }
489
- targetTagName = targetElement.tagName.toLowerCase()
490
- if (targetTagName === 'label') {
491
- forElement = this.findControl(targetElement)
492
- if (forElement) {
493
- this.focus(targetElement)
494
- if (deviceIsAndroid) {
495
- return false
496
- }
497
- targetElement = forElement
498
- }
499
- } else if (this.needsFocus(targetElement)) {
500
- // Case 1: If the touch started a while ago (best guess is 100ms based on tests for issue #36) then focus will be triggered anyway. Return early and unset the target element reference so that the subsequent click will be allowed through.
501
- // Case 2: Without this exception for input elements tapped when the document is contained in an iframe, then any inputted text won't be visible even though the value attribute is updated as the user types (issue #37).
502
- if ((event.timeStamp - trackingClickStart) >
503
- 100 ||
504
- (deviceIsIOS && window.top !== window && targetTagName === 'input')) {
505
- this.targetElement = null
506
- return false
507
- }
508
- this.focus(targetElement)
509
- this.sendClick(targetElement, event)
510
- // Select elements need the event to go through on iOS 4, otherwise the selector menu won't open.
511
- // Also this breaks opening selects when VoiceOver is active on iOS6, iOS7 (and possibly others)
512
- if (!deviceIsIOS || targetTagName !== 'select') {
513
- this.targetElement = null
514
- event.preventDefault()
515
- }
516
- return false
517
- }
518
- if (deviceIsIOS && !deviceIsIOS4) {
519
- // Don't send a synthetic click event if the target element is contained within a parent layer that was scrolled
520
- // and this tap is being used to stop the scrolling (usually initiated by a fling - issue #42).
521
- scrollParent = targetElement.fastClickScrollParent
522
- if (scrollParent && scrollParent.fastClickLastScrollTop !== scrollParent.scrollTop) {
523
- return true
524
- }
525
- }
526
- // Prevent the actual click from going though - unless the target node is marked as requiring
527
- // real clicks or if it is in the whitelist in which case only non-programmatic clicks are permitted.
528
- if (!this.needsClick(targetElement)) {
529
- event.preventDefault()
530
- this.sendClick(targetElement, event)
531
- }
532
- return false
533
- }
534
- /**
535
- * On touch cancel, stop tracking the click.
536
- *
537
- * @returns {void}
538
- */
539
- FastClick.prototype.onTouchCancel = function () {
540
- this.trackingClick = false
541
- this.targetElement = null
542
- }
543
- /**
544
- * Determine mouse events which should be permitted.
545
- *
546
- * @param {Event} event
547
- * @returns {boolean}
548
- */
549
- FastClick.prototype.onMouse = function (event) {
550
- // If a target element was never set (because a touch event was never fired) allow the event
551
- if (!this.targetElement) {
552
- return true
553
- }
554
- if (event.forwardedTouchEvent) {
555
- return true
556
- }
557
- // Programmatically generated events targeting a specific element should be permitted
558
- if (!event.cancelable) {
559
- return true
560
- }
561
- // Derive and check the target element to see whether the mouse event needs to be permitted;
562
- // unless explicitly enabled, prevent non-touch click events from triggering actions,
563
- // to prevent ghost/doubleclicks.
564
- if (!this.needsClick(this.targetElement) || this.cancelNextClick) {
565
- // Prevent any user-added listeners declared on FastClick element from being fired.
566
- if (event.stopImmediatePropagation) {
567
- event.stopImmediatePropagation()
568
- } else {
569
- // Part of the hack for browsers that don't support Event#stopImmediatePropagation (e.g. Android 2)
570
- event.propagationStopped = true
571
- }
572
- // Cancel the event
573
- event.stopPropagation()
574
- event.preventDefault()
575
- return false
576
- }
577
- // If the mouse event is permitted, return true for the action to go through.
578
- return true
579
- }
580
- /**
581
- * On actual clicks, determine whether this is a touch-generated click, a click action occurring
582
- * naturally after a delay after a touch (which needs to be cancelled to avoid duplication), or
583
- * an actual click which should be permitted.
584
- *
585
- * @param {Event} event
586
- * @returns {boolean}
587
- */
588
- FastClick.prototype.onClick = function (event) {
589
- var permitted
590
- // It's possible for another FastClick-like library delivered with third-party code to fire a click event before FastClick does (issue #44). In that case, set the click-tracking flag back to false and return early. This will cause onTouchEnd to return early.
591
- if (this.trackingClick) {
592
- this.targetElement = null
593
- this.trackingClick = false
594
- return true
595
- }
596
- // Very odd behaviour on iOS (issue #18): if a submit element is present inside a form and the user hits enter in the iOS simulator or clicks the Go button on the pop-up OS keyboard the a kind of 'fake' click event will be triggered with the submit-type input element as the target.
597
- if (event.target.type === 'submit' && event.detail === 0) {
598
- return true
599
- }
600
- permitted = this.onMouse(event)
601
- // Only unset targetElement if the click is not permitted. This will ensure that the check for !targetElement in onMouse fails and the browser's click doesn't go through.
602
- if (!permitted) {
603
- this.targetElement = null
604
- }
605
- // If clicks are permitted, return true for the action to go through.
606
- return permitted
607
- }
608
- /**
609
- * Remove all FastClick's event listeners.
610
- *
611
- * @returns {void}
612
- */
613
- FastClick.prototype.destroy = function () {
614
- var layer = this.layer
615
- if (deviceIsAndroid) {
616
- layer.removeEventListener('mouseover', this.onMouse, true)
617
- layer.removeEventListener('mousedown', this.onMouse, true)
618
- layer.removeEventListener('mouseup', this.onMouse, true)
619
- }
620
- layer.removeEventListener('click', this.onClick, true)
621
- layer.removeEventListener('touchstart', this.onTouchStart, false)
622
- layer.removeEventListener('touchmove', this.onTouchMove, false)
623
- layer.removeEventListener('touchend', this.onTouchEnd, false)
624
- layer.removeEventListener('touchcancel', this.onTouchCancel, false)
625
- }
626
- /**
627
- * Check whether FastClick is needed.
628
- *
629
- * @param {Element} layer The layer to listen on
630
- */
631
- FastClick.notNeeded = function (layer) {
632
- var metaViewport
633
- var chromeVersion
634
- var blackberryVersion
635
- var firefoxVersion
636
- // Devices that don't support touch don't need FastClick
637
- if (typeof window.ontouchstart === 'undefined') {
638
- return true
639
- }
640
- // Chrome version - zero for other browsers
641
- chromeVersion = +(/Chrome\/([0-9]+)/.exec(navigator.userAgent) ||
642
- [
643
- ,
644
- 0
645
- ])[1]
646
- if (chromeVersion) {
647
- if (deviceIsAndroid) {
648
- metaViewport = document.querySelector('meta[name=viewport]')
649
- if (metaViewport) {
650
- // Chrome on Android with user-scalable="no" doesn't need FastClick (issue #89)
651
- if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
652
- return true
653
- }
654
- // Chrome 32 and above with width=device-width or less don't need FastClick
655
- if (chromeVersion > 31 && document.documentElement.scrollWidth <= window.outerWidth) {
656
- return true
657
- }
658
- }
659
- // Chrome desktop doesn't need FastClick (issue #15)
660
- } else {
661
- return true
662
- }
663
- }
664
- if (deviceIsBlackBerry10) {
665
- blackberryVersion = navigator.userAgent.match(/Version\/([0-9]*)\.([0-9]*)/)
666
- // BlackBerry 10.3+ does not require Fastclick library.
667
- // https://github.com/ftlabs/fastclick/issues/251
668
- if (blackberryVersion[1] >= 10 && blackberryVersion[2] >= 3) {
669
- metaViewport = document.querySelector('meta[name=viewport]')
670
- if (metaViewport) {
671
- // user-scalable=no eliminates click delay.
672
- if (metaViewport.content.indexOf('user-scalable=no') !== -1) {
673
- return true
674
- }
675
- // width=device-width (or less than device-width) eliminates click delay.
676
- if (document.documentElement.scrollWidth <= window.outerWidth) {
677
- return true
678
- }
679
- }
680
- }
681
- }
682
- // IE10 with -ms-touch-action: none or manipulation, which disables double-tap-to-zoom (issue #97)
683
- if (layer.style.msTouchAction === 'none' || layer.style.touchAction === 'manipulation') {
684
- return true
685
- }
686
- // Firefox version - zero for other browsers
687
- firefoxVersion = +(/Firefox\/([0-9]+)/.exec(navigator.userAgent) ||
688
- [
689
- ,
690
- 0
691
- ])[1]
692
- if (firefoxVersion >= 27) {
693
- // Firefox 27+ does not have tap delay if the content is not zoomable - https://bugzilla.mozilla.org/show_bug.cgi?id=922896
694
- metaViewport = document.querySelector('meta[name=viewport]')
695
- if (metaViewport &&
696
- (metaViewport.content.indexOf('user-scalable=no') !==
697
- -1 ||
698
- document.documentElement.scrollWidth <=
699
- window.outerWidth)) {
700
- return true
701
- }
702
- }
703
- // IE11: prefixed -ms-touch-action is no longer supported and it's recomended to use non-prefixed version
704
- // http://msdn.microsoft.com/en-us/library/windows/apps/Hh767313.aspx
705
- if (layer.style.touchAction === 'none' || layer.style.touchAction === 'manipulation') {
706
- return true
707
- }
708
- return false
709
- }
710
- /**
711
- * Factory method for creating a FastClick object
712
- *
713
- * @param {Element} layer The layer to listen on
714
- * @param {Object} [options={}] The options to override the defaults
715
- */
716
- FastClick.attach = function (layer, options) {
717
- return new FastClick(layer, options)
718
- }
719
- if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
720
- // AMD. Register as an anonymous module.
721
- define(function () {
722
- return FastClick
723
- })
724
- } else if (typeof module !== 'undefined' && module.exports) {
725
- module.exports = FastClick.attach
726
- module.exports.FastClick = FastClick
727
- } else {
728
- window.FastClick = FastClick
729
- }
730
- }())