@wiajs/core 1.0.10 → 1.0.11
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/dist/core.cmn.js +554 -2
- package/dist/core.esm.js +554 -2
- package/dist/core.js +460 -2
- package/dist/core.min.js +3 -3
- package/package.json +1 -1
package/dist/core.esm.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wia core v1.0.
|
|
2
|
+
* wia core v1.0.10
|
|
3
3
|
* (c) 2015-2023 Sibyl Yu and contributors
|
|
4
4
|
* Released under the MIT License.
|
|
5
5
|
*/
|
|
@@ -2161,7 +2161,8 @@ const Resize = {
|
|
|
2161
2161
|
};
|
|
2162
2162
|
|
|
2163
2163
|
/**
|
|
2164
|
-
* document 绑定click
|
|
2164
|
+
* document 绑定click事件,传递到 app.on
|
|
2165
|
+
* 触发所有子模块的 clicks
|
|
2165
2166
|
* 支持touch则绑定touch,否则绑定click
|
|
2166
2167
|
* 无论touch 还是 click事件,都会触发事件响应函数
|
|
2167
2168
|
* @param {*} cb
|
|
@@ -2252,6 +2253,556 @@ const Click = {
|
|
|
2252
2253
|
},
|
|
2253
2254
|
};
|
|
2254
2255
|
|
|
2256
|
+
/* eslint-disable no-nested-ternary */
|
|
2257
|
+
|
|
2258
|
+
|
|
2259
|
+
const {extend: extend$1} = Utils;
|
|
2260
|
+
const {device: device$1, support: support$1} = $;
|
|
2261
|
+
|
|
2262
|
+
function initTouch() {
|
|
2263
|
+
const app = this;
|
|
2264
|
+
const params = app.params.touch;
|
|
2265
|
+
const useRipple = params[`${app.theme}TouchRipple`];
|
|
2266
|
+
|
|
2267
|
+
if (device$1.ios && device$1.webView) {
|
|
2268
|
+
// Strange hack required for iOS 8 webview to work on inputs
|
|
2269
|
+
window.addEventListener('touchstart', () => {});
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
let touchStartX;
|
|
2273
|
+
let touchStartY;
|
|
2274
|
+
let targetElement;
|
|
2275
|
+
let isMoved;
|
|
2276
|
+
let tapHoldFired;
|
|
2277
|
+
let tapHoldTimeout;
|
|
2278
|
+
let preventClick;
|
|
2279
|
+
|
|
2280
|
+
let activableElement;
|
|
2281
|
+
let activeTimeout;
|
|
2282
|
+
|
|
2283
|
+
let rippleWave;
|
|
2284
|
+
let rippleTarget;
|
|
2285
|
+
let rippleTimeout;
|
|
2286
|
+
|
|
2287
|
+
function findActivableElement(el) {
|
|
2288
|
+
const target = $(el);
|
|
2289
|
+
const parents = target.parents(params.activeStateElements);
|
|
2290
|
+
if (target.closest('.no-active-state').length) {
|
|
2291
|
+
return null;
|
|
2292
|
+
}
|
|
2293
|
+
let activable;
|
|
2294
|
+
if (target.is(params.activeStateElements)) {
|
|
2295
|
+
activable = target;
|
|
2296
|
+
}
|
|
2297
|
+
if (parents.length > 0) {
|
|
2298
|
+
activable = activable ? activable.add(parents) : parents;
|
|
2299
|
+
}
|
|
2300
|
+
if (activable && activable.length > 1) {
|
|
2301
|
+
const newActivable = [];
|
|
2302
|
+
let preventPropagation;
|
|
2303
|
+
for (let i = 0; i < activable.length; i += 1) {
|
|
2304
|
+
if (!preventPropagation) {
|
|
2305
|
+
newActivable.push(activable[i]);
|
|
2306
|
+
if (
|
|
2307
|
+
activable.eq(i).hasClass('prevent-active-state-propagation') ||
|
|
2308
|
+
activable.eq(i).hasClass('no-active-state-propagation')
|
|
2309
|
+
) {
|
|
2310
|
+
preventPropagation = true;
|
|
2311
|
+
}
|
|
2312
|
+
}
|
|
2313
|
+
}
|
|
2314
|
+
activable = $(newActivable);
|
|
2315
|
+
}
|
|
2316
|
+
return activable || target;
|
|
2317
|
+
}
|
|
2318
|
+
|
|
2319
|
+
function isInsideScrollableView(el) {
|
|
2320
|
+
const pageContent = el.parents('.page-content');
|
|
2321
|
+
return pageContent.length > 0;
|
|
2322
|
+
}
|
|
2323
|
+
|
|
2324
|
+
function addActive() {
|
|
2325
|
+
if (!activableElement) return;
|
|
2326
|
+
activableElement.addClass('active-state');
|
|
2327
|
+
}
|
|
2328
|
+
function removeActive() {
|
|
2329
|
+
if (!activableElement) return;
|
|
2330
|
+
activableElement.removeClass('active-state');
|
|
2331
|
+
activableElement = null;
|
|
2332
|
+
}
|
|
2333
|
+
|
|
2334
|
+
// Ripple handlers
|
|
2335
|
+
function findRippleElement(el) {
|
|
2336
|
+
const rippleElements = params.touchRippleElements;
|
|
2337
|
+
const $el = $(el);
|
|
2338
|
+
if ($el.is(rippleElements)) {
|
|
2339
|
+
if ($el.hasClass('no-ripple')) {
|
|
2340
|
+
return false;
|
|
2341
|
+
}
|
|
2342
|
+
return $el;
|
|
2343
|
+
}
|
|
2344
|
+
if ($el.parents(rippleElements).length > 0) {
|
|
2345
|
+
const rippleParent = $el.parents(rippleElements).eq(0);
|
|
2346
|
+
if (rippleParent.hasClass('no-ripple')) {
|
|
2347
|
+
return false;
|
|
2348
|
+
}
|
|
2349
|
+
return rippleParent;
|
|
2350
|
+
}
|
|
2351
|
+
return false;
|
|
2352
|
+
}
|
|
2353
|
+
|
|
2354
|
+
function createRipple($el, x, y) {
|
|
2355
|
+
if (!$el) return;
|
|
2356
|
+
rippleWave = app.touchRipple.create(app, $el, x, y);
|
|
2357
|
+
}
|
|
2358
|
+
|
|
2359
|
+
function removeRipple() {
|
|
2360
|
+
if (!rippleWave) return;
|
|
2361
|
+
rippleWave.remove();
|
|
2362
|
+
rippleWave = undefined;
|
|
2363
|
+
rippleTarget = undefined;
|
|
2364
|
+
}
|
|
2365
|
+
function rippleTouchStart(el) {
|
|
2366
|
+
rippleTarget = findRippleElement(el);
|
|
2367
|
+
if (!rippleTarget || rippleTarget.length === 0) {
|
|
2368
|
+
rippleTarget = undefined;
|
|
2369
|
+
return;
|
|
2370
|
+
}
|
|
2371
|
+
const inScrollable = isInsideScrollableView(rippleTarget);
|
|
2372
|
+
|
|
2373
|
+
if (!inScrollable) {
|
|
2374
|
+
removeRipple();
|
|
2375
|
+
createRipple(rippleTarget, touchStartX, touchStartY);
|
|
2376
|
+
} else {
|
|
2377
|
+
clearTimeout(rippleTimeout);
|
|
2378
|
+
rippleTimeout = setTimeout(() => {
|
|
2379
|
+
removeRipple();
|
|
2380
|
+
createRipple(rippleTarget, touchStartX, touchStartY);
|
|
2381
|
+
}, 80);
|
|
2382
|
+
}
|
|
2383
|
+
}
|
|
2384
|
+
function rippleTouchMove() {
|
|
2385
|
+
clearTimeout(rippleTimeout);
|
|
2386
|
+
removeRipple();
|
|
2387
|
+
}
|
|
2388
|
+
function rippleTouchEnd() {
|
|
2389
|
+
if (!rippleWave && rippleTarget && !isMoved) {
|
|
2390
|
+
clearTimeout(rippleTimeout);
|
|
2391
|
+
createRipple(rippleTarget, touchStartX, touchStartY);
|
|
2392
|
+
setTimeout(removeRipple, 0);
|
|
2393
|
+
} else {
|
|
2394
|
+
removeRipple();
|
|
2395
|
+
}
|
|
2396
|
+
}
|
|
2397
|
+
|
|
2398
|
+
// Mouse Handlers
|
|
2399
|
+
function handleMouseDown(e) {
|
|
2400
|
+
const $activableEl = findActivableElement(e.target);
|
|
2401
|
+
if ($activableEl) {
|
|
2402
|
+
$activableEl.addClass('active-state');
|
|
2403
|
+
if ('which' in e && e.which === 3) {
|
|
2404
|
+
setTimeout(() => {
|
|
2405
|
+
$('.active-state').removeClass('active-state');
|
|
2406
|
+
}, 0);
|
|
2407
|
+
}
|
|
2408
|
+
}
|
|
2409
|
+
|
|
2410
|
+
if (useRipple) {
|
|
2411
|
+
touchStartX = e.pageX;
|
|
2412
|
+
touchStartY = e.pageY;
|
|
2413
|
+
rippleTouchStart(e.target, e.pageX, e.pageY);
|
|
2414
|
+
}
|
|
2415
|
+
}
|
|
2416
|
+
function handleMouseMove() {
|
|
2417
|
+
if (!params.activeStateOnMouseMove) {
|
|
2418
|
+
$('.active-state').removeClass('active-state');
|
|
2419
|
+
}
|
|
2420
|
+
if (useRipple) {
|
|
2421
|
+
rippleTouchMove();
|
|
2422
|
+
}
|
|
2423
|
+
}
|
|
2424
|
+
function handleMouseUp() {
|
|
2425
|
+
$('.active-state').removeClass('active-state');
|
|
2426
|
+
if (useRipple) {
|
|
2427
|
+
rippleTouchEnd();
|
|
2428
|
+
}
|
|
2429
|
+
}
|
|
2430
|
+
|
|
2431
|
+
function handleTouchCancel() {
|
|
2432
|
+
targetElement = null;
|
|
2433
|
+
|
|
2434
|
+
// Remove Active State
|
|
2435
|
+
clearTimeout(activeTimeout);
|
|
2436
|
+
clearTimeout(tapHoldTimeout);
|
|
2437
|
+
if (params.activeState) {
|
|
2438
|
+
removeActive();
|
|
2439
|
+
}
|
|
2440
|
+
|
|
2441
|
+
// Remove Ripple
|
|
2442
|
+
if (useRipple) {
|
|
2443
|
+
rippleTouchEnd();
|
|
2444
|
+
}
|
|
2445
|
+
}
|
|
2446
|
+
|
|
2447
|
+
let isScrolling;
|
|
2448
|
+
let isSegmentedStrong = false;
|
|
2449
|
+
let segmentedStrongEl = null;
|
|
2450
|
+
|
|
2451
|
+
const touchMoveActivableIos = '.dialog-button, .actions-button';
|
|
2452
|
+
let isTouchMoveActivable = false;
|
|
2453
|
+
let touchmoveActivableEl = null;
|
|
2454
|
+
|
|
2455
|
+
function handleTouchStart(e) {
|
|
2456
|
+
if (!e.isTrusted) return true;
|
|
2457
|
+
isMoved = false;
|
|
2458
|
+
tapHoldFired = false;
|
|
2459
|
+
preventClick = false;
|
|
2460
|
+
isScrolling = undefined;
|
|
2461
|
+
if (e.targetTouches.length > 1) {
|
|
2462
|
+
if (activableElement) removeActive();
|
|
2463
|
+
return true;
|
|
2464
|
+
}
|
|
2465
|
+
if (e.touches.length > 1 && activableElement) {
|
|
2466
|
+
removeActive();
|
|
2467
|
+
}
|
|
2468
|
+
if (params.tapHold) {
|
|
2469
|
+
if (tapHoldTimeout) clearTimeout(tapHoldTimeout);
|
|
2470
|
+
tapHoldTimeout = setTimeout(() => {
|
|
2471
|
+
if (e && e.touches && e.touches.length > 1) return;
|
|
2472
|
+
tapHoldFired = true;
|
|
2473
|
+
e.preventDefault();
|
|
2474
|
+
preventClick = true;
|
|
2475
|
+
$(e.target).trigger('taphold', e);
|
|
2476
|
+
app.emit('taphold', e);
|
|
2477
|
+
}, params.tapHoldDelay);
|
|
2478
|
+
}
|
|
2479
|
+
targetElement = e.target;
|
|
2480
|
+
touchStartX = e.targetTouches[0].pageX;
|
|
2481
|
+
touchStartY = e.targetTouches[0].pageY;
|
|
2482
|
+
isSegmentedStrong = e.target.closest(
|
|
2483
|
+
'.segmented-strong .button-active, .segmented-strong .tab-link-active'
|
|
2484
|
+
);
|
|
2485
|
+
isTouchMoveActivable = app.theme === 'ios' && e.target.closest(touchMoveActivableIos);
|
|
2486
|
+
if (isSegmentedStrong) {
|
|
2487
|
+
segmentedStrongEl = isSegmentedStrong.closest('.segmented-strong');
|
|
2488
|
+
}
|
|
2489
|
+
|
|
2490
|
+
if (params.activeState) {
|
|
2491
|
+
activableElement = findActivableElement(targetElement);
|
|
2492
|
+
if (activableElement && !isInsideScrollableView(activableElement)) {
|
|
2493
|
+
addActive();
|
|
2494
|
+
} else if (activableElement) {
|
|
2495
|
+
activeTimeout = setTimeout(addActive, 80);
|
|
2496
|
+
}
|
|
2497
|
+
}
|
|
2498
|
+
if (useRipple) {
|
|
2499
|
+
rippleTouchStart(targetElement);
|
|
2500
|
+
}
|
|
2501
|
+
return true;
|
|
2502
|
+
}
|
|
2503
|
+
|
|
2504
|
+
function handleTouchMove(e) {
|
|
2505
|
+
if (!e.isTrusted) return;
|
|
2506
|
+
let touch;
|
|
2507
|
+
let distance;
|
|
2508
|
+
let shouldRemoveActive = true;
|
|
2509
|
+
|
|
2510
|
+
if (e.type === 'touchmove') {
|
|
2511
|
+
touch = e.targetTouches[0];
|
|
2512
|
+
distance = params.touchClicksDistanceThreshold;
|
|
2513
|
+
}
|
|
2514
|
+
|
|
2515
|
+
const touchCurrentX = e.targetTouches[0].pageX;
|
|
2516
|
+
const touchCurrentY = e.targetTouches[0].pageY;
|
|
2517
|
+
|
|
2518
|
+
if (typeof isScrolling === 'undefined') {
|
|
2519
|
+
isScrolling = !!(
|
|
2520
|
+
isScrolling || Math.abs(touchCurrentY - touchStartY) > Math.abs(touchCurrentX - touchStartX)
|
|
2521
|
+
);
|
|
2522
|
+
}
|
|
2523
|
+
|
|
2524
|
+
if (isTouchMoveActivable || (!isScrolling && isSegmentedStrong && segmentedStrongEl)) {
|
|
2525
|
+
if (e.cancelable) e.preventDefault();
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
if (!isScrolling && isSegmentedStrong && segmentedStrongEl) {
|
|
2529
|
+
const elementFromPoint = document.elementFromPoint(
|
|
2530
|
+
e.targetTouches[0].clientX,
|
|
2531
|
+
e.targetTouches[0].clientY
|
|
2532
|
+
);
|
|
2533
|
+
const buttonEl = elementFromPoint.closest(
|
|
2534
|
+
'.segmented-strong .button:not(.button-active):not(.tab-link-active)'
|
|
2535
|
+
);
|
|
2536
|
+
if (buttonEl && segmentedStrongEl.contains(buttonEl)) {
|
|
2537
|
+
$(buttonEl).trigger('click', 'f7Segmented');
|
|
2538
|
+
targetElement = buttonEl;
|
|
2539
|
+
}
|
|
2540
|
+
}
|
|
2541
|
+
|
|
2542
|
+
if (distance && touch) {
|
|
2543
|
+
const {pageX, pageY} = touch;
|
|
2544
|
+
if (Math.abs(pageX - touchStartX) > distance || Math.abs(pageY - touchStartY) > distance) {
|
|
2545
|
+
isMoved = true;
|
|
2546
|
+
}
|
|
2547
|
+
} else {
|
|
2548
|
+
isMoved = true;
|
|
2549
|
+
}
|
|
2550
|
+
|
|
2551
|
+
if (isMoved) {
|
|
2552
|
+
preventClick = true;
|
|
2553
|
+
// Keep active state on touchMove (for dialog and actions buttons)
|
|
2554
|
+
if (isTouchMoveActivable) {
|
|
2555
|
+
const elementFromPoint = document.elementFromPoint(
|
|
2556
|
+
e.targetTouches[0].clientX,
|
|
2557
|
+
e.targetTouches[0].clientY
|
|
2558
|
+
);
|
|
2559
|
+
touchmoveActivableEl = elementFromPoint.closest(touchMoveActivableIos);
|
|
2560
|
+
if (
|
|
2561
|
+
touchmoveActivableEl &&
|
|
2562
|
+
activableElement &&
|
|
2563
|
+
activableElement[0] === touchmoveActivableEl
|
|
2564
|
+
) {
|
|
2565
|
+
shouldRemoveActive = false;
|
|
2566
|
+
} else if (touchmoveActivableEl) {
|
|
2567
|
+
setTimeout(() => {
|
|
2568
|
+
activableElement = findActivableElement(touchmoveActivableEl);
|
|
2569
|
+
addActive();
|
|
2570
|
+
});
|
|
2571
|
+
}
|
|
2572
|
+
}
|
|
2573
|
+
if (params.tapHold) {
|
|
2574
|
+
clearTimeout(tapHoldTimeout);
|
|
2575
|
+
}
|
|
2576
|
+
if (params.activeState && shouldRemoveActive) {
|
|
2577
|
+
clearTimeout(activeTimeout);
|
|
2578
|
+
removeActive();
|
|
2579
|
+
}
|
|
2580
|
+
if (useRipple) {
|
|
2581
|
+
rippleTouchMove();
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
function handleTouchEnd(e) {
|
|
2587
|
+
if (!e.isTrusted) return true;
|
|
2588
|
+
isScrolling = undefined;
|
|
2589
|
+
isSegmentedStrong = false;
|
|
2590
|
+
segmentedStrongEl = null;
|
|
2591
|
+
isTouchMoveActivable = false;
|
|
2592
|
+
clearTimeout(activeTimeout);
|
|
2593
|
+
clearTimeout(tapHoldTimeout);
|
|
2594
|
+
if (touchmoveActivableEl) {
|
|
2595
|
+
$(touchmoveActivableEl).trigger('click', 'f7TouchMoveActivable');
|
|
2596
|
+
touchmoveActivableEl = null;
|
|
2597
|
+
}
|
|
2598
|
+
if (document.activeElement === e.target) {
|
|
2599
|
+
if (params.activeState) removeActive();
|
|
2600
|
+
if (useRipple) {
|
|
2601
|
+
rippleTouchEnd();
|
|
2602
|
+
}
|
|
2603
|
+
return true;
|
|
2604
|
+
}
|
|
2605
|
+
if (params.activeState) {
|
|
2606
|
+
addActive();
|
|
2607
|
+
setTimeout(removeActive, 0);
|
|
2608
|
+
}
|
|
2609
|
+
if (useRipple) {
|
|
2610
|
+
rippleTouchEnd();
|
|
2611
|
+
}
|
|
2612
|
+
if ((params.tapHoldPreventClicks && tapHoldFired) || preventClick) {
|
|
2613
|
+
if (e.cancelable) e.preventDefault();
|
|
2614
|
+
preventClick = true;
|
|
2615
|
+
return false;
|
|
2616
|
+
}
|
|
2617
|
+
return true;
|
|
2618
|
+
}
|
|
2619
|
+
|
|
2620
|
+
function handleClick(e) {
|
|
2621
|
+
const isOverswipe = e && e.detail && e.detail === 'f7Overswipe';
|
|
2622
|
+
const isSegmented = e && e.detail && e.detail === 'f7Segmented';
|
|
2623
|
+
// eslint-disable-next-line
|
|
2624
|
+
const isTouchMoveActivable = e && e.detail && e.detail === 'f7TouchMoveActivable';
|
|
2625
|
+
let localPreventClick = preventClick;
|
|
2626
|
+
if (targetElement && e.target !== targetElement) {
|
|
2627
|
+
if (isOverswipe || isSegmented || isTouchMoveActivable) {
|
|
2628
|
+
localPreventClick = false;
|
|
2629
|
+
} else {
|
|
2630
|
+
localPreventClick = true;
|
|
2631
|
+
}
|
|
2632
|
+
} else if (isTouchMoveActivable) {
|
|
2633
|
+
localPreventClick = false;
|
|
2634
|
+
}
|
|
2635
|
+
if (params.tapHold && params.tapHoldPreventClicks && tapHoldFired) {
|
|
2636
|
+
localPreventClick = true;
|
|
2637
|
+
}
|
|
2638
|
+
if (localPreventClick) {
|
|
2639
|
+
e.stopImmediatePropagation();
|
|
2640
|
+
e.stopPropagation();
|
|
2641
|
+
e.preventDefault();
|
|
2642
|
+
}
|
|
2643
|
+
|
|
2644
|
+
if (params.tapHold) {
|
|
2645
|
+
tapHoldTimeout = setTimeout(
|
|
2646
|
+
() => {
|
|
2647
|
+
tapHoldFired = false;
|
|
2648
|
+
},
|
|
2649
|
+
device$1.ios || device$1.androidChrome ? 100 : 400
|
|
2650
|
+
);
|
|
2651
|
+
}
|
|
2652
|
+
preventClick = false;
|
|
2653
|
+
targetElement = null;
|
|
2654
|
+
|
|
2655
|
+
return !localPreventClick;
|
|
2656
|
+
}
|
|
2657
|
+
|
|
2658
|
+
/**
|
|
2659
|
+
* document touch �¼����ݸ� app.on
|
|
2660
|
+
* @param {*} name
|
|
2661
|
+
* @param {*} e
|
|
2662
|
+
*/
|
|
2663
|
+
function emitAppTouchEvent(name, e) {
|
|
2664
|
+
app.emit({
|
|
2665
|
+
events: name,
|
|
2666
|
+
data: [e],
|
|
2667
|
+
});
|
|
2668
|
+
}
|
|
2669
|
+
|
|
2670
|
+
function appTouchStartActive(e) {
|
|
2671
|
+
emitAppTouchEvent('touchstart touchstart:active', e);
|
|
2672
|
+
}
|
|
2673
|
+
|
|
2674
|
+
function appTouchMoveActive(e) {
|
|
2675
|
+
emitAppTouchEvent('touchmove touchmove:active', e);
|
|
2676
|
+
}
|
|
2677
|
+
|
|
2678
|
+
function appTouchEndActive(e) {
|
|
2679
|
+
emitAppTouchEvent('touchend touchend:active', e);
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
function appTouchStartPassive(e) {
|
|
2683
|
+
emitAppTouchEvent('touchstart:passive', e);
|
|
2684
|
+
}
|
|
2685
|
+
|
|
2686
|
+
function appTouchMovePassive(e) {
|
|
2687
|
+
emitAppTouchEvent('touchmove:passive', e);
|
|
2688
|
+
}
|
|
2689
|
+
|
|
2690
|
+
function appTouchEndPassive(e) {
|
|
2691
|
+
emitAppTouchEvent('touchend:passive', e);
|
|
2692
|
+
}
|
|
2693
|
+
|
|
2694
|
+
const passiveListener = support$1.passiveListener ? {passive: true} : false;
|
|
2695
|
+
const passiveListenerCapture = support$1.passiveListener ? {passive: true, capture: true} : true;
|
|
2696
|
+
const activeListener = support$1.passiveListener ? {passive: false} : false;
|
|
2697
|
+
const activeListenerCapture = support$1.passiveListener ? {passive: false, capture: true} : true;
|
|
2698
|
+
|
|
2699
|
+
// document touch �¼� ���ݸ� app.on
|
|
2700
|
+
if (support$1.passiveListener) {
|
|
2701
|
+
document.addEventListener(app.touchEvents.start, appTouchStartActive, activeListenerCapture);
|
|
2702
|
+
document.addEventListener(app.touchEvents.move, appTouchMoveActive, activeListener);
|
|
2703
|
+
document.addEventListener(app.touchEvents.end, appTouchEndActive, activeListener);
|
|
2704
|
+
|
|
2705
|
+
document.addEventListener(app.touchEvents.start, appTouchStartPassive, passiveListenerCapture);
|
|
2706
|
+
document.addEventListener(app.touchEvents.move, appTouchMovePassive, passiveListener);
|
|
2707
|
+
document.addEventListener(app.touchEvents.end, appTouchEndPassive, passiveListener);
|
|
2708
|
+
} else {
|
|
2709
|
+
document.addEventListener(
|
|
2710
|
+
app.touchEvents.start,
|
|
2711
|
+
e => {
|
|
2712
|
+
appTouchStartActive(e);
|
|
2713
|
+
appTouchStartPassive(e);
|
|
2714
|
+
},
|
|
2715
|
+
true
|
|
2716
|
+
);
|
|
2717
|
+
document.addEventListener(
|
|
2718
|
+
app.touchEvents.move,
|
|
2719
|
+
e => {
|
|
2720
|
+
appTouchMoveActive(e);
|
|
2721
|
+
appTouchMovePassive(e);
|
|
2722
|
+
},
|
|
2723
|
+
false
|
|
2724
|
+
);
|
|
2725
|
+
document.addEventListener(
|
|
2726
|
+
app.touchEvents.end,
|
|
2727
|
+
e => {
|
|
2728
|
+
appTouchEndActive(e);
|
|
2729
|
+
appTouchEndPassive(e);
|
|
2730
|
+
},
|
|
2731
|
+
false
|
|
2732
|
+
);
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
if (support$1.touch) {
|
|
2736
|
+
app.on('click', handleClick);
|
|
2737
|
+
app.on('touchstart', handleTouchStart);
|
|
2738
|
+
app.on('touchmove', handleTouchMove);
|
|
2739
|
+
app.on('touchend', handleTouchEnd);
|
|
2740
|
+
document.addEventListener('touchcancel', handleTouchCancel, {passive: true});
|
|
2741
|
+
} else if (params.activeState) {
|
|
2742
|
+
app.on('touchstart', handleMouseDown);
|
|
2743
|
+
app.on('touchmove', handleMouseMove);
|
|
2744
|
+
app.on('touchend', handleMouseUp);
|
|
2745
|
+
document.addEventListener('pointercancel', handleMouseUp, {passive: true});
|
|
2746
|
+
}
|
|
2747
|
+
|
|
2748
|
+
document.addEventListener('contextmenu', e => {
|
|
2749
|
+
if (
|
|
2750
|
+
params.disableContextMenu &&
|
|
2751
|
+
(device$1.ios ||
|
|
2752
|
+
device$1.android ||
|
|
2753
|
+
device$1.cordova ||
|
|
2754
|
+
(window.Capacitor && window.Capacitor.isNative))
|
|
2755
|
+
) {
|
|
2756
|
+
e.preventDefault();
|
|
2757
|
+
}
|
|
2758
|
+
if (useRipple) {
|
|
2759
|
+
if (activableElement) removeActive();
|
|
2760
|
+
rippleTouchEnd();
|
|
2761
|
+
}
|
|
2762
|
+
});
|
|
2763
|
+
}
|
|
2764
|
+
|
|
2765
|
+
const Touch = {
|
|
2766
|
+
name: 'touch',
|
|
2767
|
+
params: {
|
|
2768
|
+
touch: {
|
|
2769
|
+
// Clicks
|
|
2770
|
+
touchClicksDistanceThreshold: 5,
|
|
2771
|
+
// ContextMenu
|
|
2772
|
+
disableContextMenu: false,
|
|
2773
|
+
// Tap Hold
|
|
2774
|
+
tapHold: false,
|
|
2775
|
+
tapHoldDelay: 750,
|
|
2776
|
+
tapHoldPreventClicks: true,
|
|
2777
|
+
// Active State
|
|
2778
|
+
activeState: true,
|
|
2779
|
+
activeStateElements:
|
|
2780
|
+
'a, button, label, span, .actions-button, .stepper-button, .stepper-button-plus, .stepper-button-minus, .card-expandable, .link, .item-link, .accordion-item-toggle',
|
|
2781
|
+
activeStateOnMouseMove: false,
|
|
2782
|
+
mdTouchRipple: true,
|
|
2783
|
+
iosTouchRipple: false,
|
|
2784
|
+
touchRippleElements:
|
|
2785
|
+
'.ripple, .link, .item-link, .list label.item-content, .list-button, .links-list a, .button, button, .input-clear-button, .dialog-button, .tab-link, .item-radio, .item-checkbox, .actions-button, .searchbar-disable-button, .fab a, .checkbox, .radio, .data-table .sortable-cell:not(.input-cell), .notification-close-button, .stepper-button, .stepper-button-minus, .stepper-button-plus, .list.accordion-list .accordion-item-toggle',
|
|
2786
|
+
touchRippleInsetElements:
|
|
2787
|
+
'.ripple-inset, .icon-only, .searchbar-disable-button, .input-clear-button, .notification-close-button, .md .navbar .link.back',
|
|
2788
|
+
},
|
|
2789
|
+
},
|
|
2790
|
+
|
|
2791
|
+
create() {
|
|
2792
|
+
const app = this;
|
|
2793
|
+
extend$1(app, {
|
|
2794
|
+
touchEvents: {
|
|
2795
|
+
start: support$1.touch ? 'touchstart' : support$1.pointerEvents ? 'pointerdown' : 'mousedown',
|
|
2796
|
+
move: support$1.touch ? 'touchmove' : support$1.pointerEvents ? 'pointermove' : 'mousemove',
|
|
2797
|
+
end: support$1.touch ? 'touchend' : support$1.pointerEvents ? 'pointerup' : 'mouseup',
|
|
2798
|
+
},
|
|
2799
|
+
});
|
|
2800
|
+
},
|
|
2801
|
+
on: {
|
|
2802
|
+
init: initTouch,
|
|
2803
|
+
},
|
|
2804
|
+
};
|
|
2805
|
+
|
|
2255
2806
|
const SW = {
|
|
2256
2807
|
registrations: [],
|
|
2257
2808
|
register(path, scope) {
|
|
@@ -2851,6 +3402,7 @@ App.utils = Utils;
|
|
|
2851
3402
|
App.use([
|
|
2852
3403
|
Resize, // 控制屏幕大小
|
|
2853
3404
|
Click, // 触发UI组件的点击(Click 或 Touch)事件
|
|
3405
|
+
Touch, // 触发app.on(Touch事件)
|
|
2854
3406
|
SW$1, // ServiceWorker
|
|
2855
3407
|
|
|
2856
3408
|
//INSTALL_COMPONENTS
|