@oliasoft-open-source/charts-library 4.8.2 → 4.8.3-beta-2
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/index.js
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
|
+
(function() {
|
|
2
|
+
"use strict";
|
|
3
|
+
try {
|
|
4
|
+
if (typeof document != "undefined") {
|
|
5
|
+
var elementStyle = document.createElement("style");
|
|
6
|
+
elementStyle.appendChild(document.createTextNode("html[data-theme='dark'] ._chart_e3qdd_1 canvas {\n filter: invert(1) hue-rotate(180deg);\n}\n._chart_e3qdd_1 {\n border: 1px solid rgba(255, 255, 255, 0);\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n._chart_e3qdd_1 ._canvas_e3qdd_11 {\n flex-grow: 1;\n min-height: 0;\n position: relative;\n}\n._chart_e3qdd_1 ._canvas_e3qdd_11 canvas {\n width: 100% !important;\n height: 100% !important;\n}\n._chart_e3qdd_1._fixedHeight_e3qdd_20 {\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n height: auto;\n}\n._chart_e3qdd_1._stretchHeight_e3qdd_26 {\n display: flex;\n align-items: stretch;\n justify-content: stretch;\n height: 100%;\n}\n._chart_e3qdd_1._squareAspectRatio_e3qdd_32 {\n aspect-ratio: 1;\n min-height: 0;\n min-width: 0;\n}\n._chart_e3qdd_1:focus {\n outline: none;\n}\n._chart_e3qdd_1::-moz-focus-inner {\n border: 0;\n}\n._zoomForm_e3qdd_43 {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n top: 0;\n right: 0;\n}\n._zoomForm_e3qdd_43 ._zoomReset_e3qdd_51 {\n margin-left: 10px;\n}\n._zoomForm_e3qdd_43 ._help_e3qdd_54 {\n margin-left: 5px;\n line-height: 0;\n}\n._autoWeight_e3qdd_58 {\n width: auto;\n height: auto;\n}\n._table_e3qdd_62 {\n overflow: auto;\n}\n._controls_1edjs_1 {\n display: flex;\n align-items: center;\n gap: var(--padding-xs);\n}\n._buttons_1edjs_6 {\n display: flex;\n flex-grow: 1;\n align-items: flex-start;\n justify-content: flex-end;\n margin-left: auto;\n gap: var(--padding-xxs);\n}\n._legend_wpro0_1 {\n position: absolute;\n opacity: 0.9;\n display: flex;\n flex-direction: column;\n z-index: 1;\n}\n._legend_wpro0_1._isDragging_wpro0_8 {\n opacity: 0;\n}\n._legendItems_wpro0_11 {\n background-color: var(--color-background-raised);\n border: 1px solid var(--color-border);\n padding: 4px 8px;\n border-radius: 2px;\n overflow-y: auto;\n max-height: 100%;\n overflow: overlay;\n --scrollbar-color: #00000040;\n}\n._legendItems_wpro0_11::-webkit-scrollbar {\n display: block;\n width: 16px;\n z-index: 2;\n}\n._legendItems_wpro0_11::-webkit-scrollbar-button {\n display: none;\n}\n._legendItems_wpro0_11::-webkit-scrollbar-track {\n background-color: #00000000;\n}\n._legendItems_wpro0_11::-webkit-scrollbar-track-piece {\n background-color: #00000000;\n}\n._legendItems_wpro0_11::-webkit-scrollbar-thumb {\n background-color: #00000000;\n border: 5px solid transparent;\n border-radius: 24px;\n box-shadow: 4px 0px 0px 4px var(--scrollbar-color) inset;\n}\n._legendItems_wpro0_11::-webkit-scrollbar-corner {\n background: rgba(0, 0, 0, 0);\n}\n._legend_wpro0_1._isDragging_wpro0_8 ._legendItems_wpro0_11._legendItems_wpro0_11 {\n pointer-events: none;\n}\n._legend_wpro0_1._isHidden_wpro0_47 ._legendItems_wpro0_11._legendItems_wpro0_11 {\n display: none;\n}\n._legendToggle_wpro0_50 {\n position: absolute;\n top: 0;\n right: 0;\n transform: translate(50%, -50%);\n display: none;\n}\n._legend_wpro0_1._isHidden_wpro0_47 ._legendToggle_wpro0_50._legendToggle_wpro0_50,\n._legend_wpro0_1:hover ._legendToggle_wpro0_50._legendToggle_wpro0_50 {\n display: block;\n}\n._legend_wpro0_1:active ._legendToggle_wpro0_50._legendToggle_wpro0_50:not(:hover) {\n display: none;\n}\n._legend_wpro0_1._isHidden_wpro0_47 ._legendToggle_wpro0_50._legendToggle_wpro0_50 {\n position: static;\n transform: none;\n}\n._legend_wpro0_1._isDragging_wpro0_8 ._legendToggle_wpro0_50._legendToggle_wpro0_50 {\n display: none;\n}\n._legendItem_wpro0_11 {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n user-select: none;\n cursor: pointer;\n font-size: 12px;\n line-height: 16px;\n}\n._legendItemSymbol_wpro0_80 {\n display: flex;\n align-items: center;\n height: 16px;\n position: relative;\n flex-shrink: 0;\n}\nhtml[data-theme='dark'] ._legendItemSymbol_wpro0_80._legendItemSymbol_wpro0_80 {\n filter: invert(1) hue-rotate(180deg);\n}\n._legendItemBox_wpro0_90 {\n width: 100%;\n height: 12px;\n display: block;\n}\n._legendItemLine_wpro0_95 {\n position: absolute;\n display: flex;\n top: 50%;\n left: 0;\n width: 100%;\n transform: translateY(-50%);\n}\n._legendItemPoint_wpro0_103 {\n position: absolute;\n display: flex;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n._isHidden_wpro0_47 ._legendItemText_wpro0_110._legendItemText_wpro0_110 {\n text-decoration: line-through;\n}\n._scrollbars_wpro0_113 {\n overflow: overlay;\n --scrollbar-color: #00000040;\n}\n._scrollbars_wpro0_113::-webkit-scrollbar {\n display: block;\n width: 16px;\n z-index: 2;\n}\n._scrollbars_wpro0_113::-webkit-scrollbar-button {\n display: none;\n}\n._scrollbars_wpro0_113::-webkit-scrollbar-track {\n background-color: #00000000;\n}\n._scrollbars_wpro0_113::-webkit-scrollbar-track-piece {\n background-color: #00000000;\n}\n._scrollbars_wpro0_113::-webkit-scrollbar-thumb {\n background-color: #00000000;\n border: 5px solid transparent;\n border-radius: 24px;\n box-shadow: 4px 0px 0px 4px var(--scrollbar-color) inset;\n}\n._scrollbars_wpro0_113::-webkit-scrollbar-corner {\n background: rgba(0, 0, 0, 0);\n}\n._dropzoneContainer_wpro0_140 {\n position: absolute;\n}\n._dropzone_wpro0_140 {\n position: absolute;\n width: 50%;\n height: 50%;\n display: flex;\n}\n._dropzone_wpro0_140._left_wpro0_149 {\n left: 0;\n justify-content: flex-start;\n}\n._dropzone_wpro0_140._right_wpro0_153 {\n right: 0;\n justify-content: flex-end;\n}\n._dropzone_wpro0_140._top_wpro0_157 {\n top: 0;\n align-items: flex-start;\n}\n._dropzone_wpro0_140._bottom_wpro0_161 {\n bottom: 0;\n align-items: flex-end;\n}\n._dropzonePlaceholder_wpro0_165 {\n position: absolute;\n background-color: rgba(0, 0, 0, 0.05);\n display: none;\n}\n[data-theme='dark'] ._dropzonePlaceholder_wpro0_165 {\n background-color: rgba(255, 255, 255, 0.05);\n}\n._isActive_wpro0_173 ._dropzonePlaceholder_wpro0_165._dropzonePlaceholder_wpro0_165 {\n display: block;\n}\n._resizeContainer_wpro0_176 {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\nhtml[data-theme='dark'] ._chart_1jdnu_1 canvas {\n filter: invert(1) hue-rotate(180deg);\n}\n._chart_1jdnu_1 {\n border: 1px solid rgba(255, 255, 255, 0);\n padding-top: 10px;\n position: relative;\n}\n._chart_1jdnu_1 canvas {\n width: 100% !important;\n height: 100% !important;\n}\n._chart_1jdnu_1._fixedHeight_1jdnu_13 {\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n height: auto;\n}\n._chart_1jdnu_1._stretchHeight_1jdnu_19 {\n display: flex;\n align-items: stretch;\n justify-content: stretch;\n height: 100%;\n}\n._chart_1jdnu_1:focus {\n border: 1px solid #85b7d9;\n outline: none;\n}\n._chart_1jdnu_1::-moz-focus-inner {\n border: 0;\n}\n._zoomForm_1jdnu_32 {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n top: 0;\n right: 0;\n}\n._zoomForm_1jdnu_32 ._zoomReset_1jdnu_40 {\n margin-left: 10px;\n}\n._zoomForm_1jdnu_32 ._help_1jdnu_43 {\n margin-left: 5px;\n line-height: 0;\n}\n._autoWeight_1jdnu_47 {\n width: 'auto';\n height: 'auto';\n}\nhtml[data-theme='dark'] ._chart_x1sru_1 canvas {\n filter: invert(1) hue-rotate(180deg);\n}\n._chart_x1sru_1 {\n border: 1px solid rgba(255, 255, 255, 0);\n position: relative;\n display: flex;\n flex-direction: column;\n}\n._chart_x1sru_1 ._canvas_x1sru_10 {\n flex-grow: 1;\n min-height: 0;\n position: relative;\n}\n._chart_x1sru_1 ._canvas_x1sru_10 canvas {\n width: 100% !important;\n height: 100% !important;\n}\n._chart_x1sru_1._fixedHeight_x1sru_19 {\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n height: auto;\n}\n._chart_x1sru_1._stretchHeight_x1sru_25 {\n display: flex;\n align-items: stretch;\n justify-content: stretch;\n height: 100%;\n}\n._chart_x1sru_1:focus {\n border: 1px solid #85b7d9;\n outline: none;\n}\n._chart_x1sru_1::-moz-focus-inner {\n border: 0;\n}\n._zoomForm_x1sru_38 {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n top: 0;\n right: 0;\n}\n._zoomForm_x1sru_38 ._zoomReset_x1sru_46 {\n margin-left: 10px;\n}\n._zoomForm_x1sru_38 ._help_x1sru_49 {\n margin-left: 5px;\n line-height: 0;\n}\n._autoWeight_x1sru_53 {\n width: auto;\n height: auto;\n}\n._actions_x1sru_57 {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n}\nhtml[data-theme='dark'] ._chart_1qlu1_1 canvas {\n filter: invert(1) hue-rotate(180deg);\n}\n._chart_1qlu1_1 {\n border: 1px solid rgba(255, 255, 255, 0);\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n._chart_1qlu1_1 ._canvas_1qlu1_11 {\n flex-grow: 1;\n min-height: 0;\n position: relative;\n}\n._chart_1qlu1_1 ._canvas_1qlu1_11 canvas {\n width: 100% !important;\n height: 100% !important;\n}\n._chart_1qlu1_1._fixedHeight_1qlu1_20 {\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n height: auto;\n}\n._chart_1qlu1_1._stretchHeight_1qlu1_26 {\n display: flex;\n align-items: stretch;\n justify-content: stretch;\n height: 100%;\n}\n._chart_1qlu1_1._squareAspectRatio_1qlu1_32 {\n aspect-ratio: 1;\n min-height: 0;\n min-width: 0;\n}\n._chart_1qlu1_1:focus {\n outline: none;\n}\n._chart_1qlu1_1::-moz-focus-inner {\n border: 0;\n}\n._zoomForm_1qlu1_43 {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n top: 0;\n right: 0;\n}\n._zoomForm_1qlu1_43 ._zoomReset_1qlu1_51 {\n margin-left: 10px;\n}\n._zoomForm_1qlu1_43 ._help_1qlu1_54 {\n margin-left: 5px;\n line-height: 0;\n}\n._autoWeight_1qlu1_58 {\n width: 'auto';\n height: 'auto';\n}"));
|
|
7
|
+
document.head.appendChild(elementStyle);
|
|
8
|
+
}
|
|
9
|
+
} catch (e) {
|
|
10
|
+
console.error("vite-plugin-css-injected-by-js", e);
|
|
11
|
+
}
|
|
12
|
+
})();
|
|
1
13
|
var __defProp = Object.defineProperty;
|
|
2
14
|
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
3
15
|
var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
@@ -572,9 +584,9 @@ let Color$1 = class Color {
|
|
|
572
584
|
}
|
|
573
585
|
};
|
|
574
586
|
/*!
|
|
575
|
-
* Chart.js v4.4.
|
|
587
|
+
* Chart.js v4.4.8
|
|
576
588
|
* https://www.chartjs.org
|
|
577
|
-
* (c)
|
|
589
|
+
* (c) 2025 Chart.js Contributors
|
|
578
590
|
* Released under the MIT License
|
|
579
591
|
*/
|
|
580
592
|
function noop$1() {
|
|
@@ -815,8 +827,11 @@ function _factorize$1(value) {
|
|
|
815
827
|
result.sort((a2, b2) => a2 - b2).pop();
|
|
816
828
|
return result;
|
|
817
829
|
}
|
|
830
|
+
function isNonPrimitive(n2) {
|
|
831
|
+
return typeof n2 === "symbol" || typeof n2 === "object" && n2 !== null && !(Symbol.toPrimitive in n2 || "toString" in n2 || "valueOf" in n2);
|
|
832
|
+
}
|
|
818
833
|
function isNumber$1(n2) {
|
|
819
|
-
return !isNaN(parseFloat(n2)) && isFinite(n2);
|
|
834
|
+
return !isNonPrimitive(n2) && !isNaN(parseFloat(n2)) && isFinite(n2);
|
|
820
835
|
}
|
|
821
836
|
function almostWhole$1(x2, epsilon) {
|
|
822
837
|
const rounded = Math.round(x2);
|
|
@@ -1034,24 +1049,35 @@ function _getStartAndCountOfVisiblePoints$1(meta, points, animationsDisabled) {
|
|
|
1034
1049
|
let start = 0;
|
|
1035
1050
|
let count = pointCount;
|
|
1036
1051
|
if (meta._sorted) {
|
|
1037
|
-
const { iScale, _parsed } = meta;
|
|
1052
|
+
const { iScale, vScale, _parsed } = meta;
|
|
1053
|
+
const spanGaps = meta.dataset ? meta.dataset.options ? meta.dataset.options.spanGaps : null : null;
|
|
1038
1054
|
const axis = iScale.axis;
|
|
1039
1055
|
const { min, max, minDefined, maxDefined } = iScale.getUserBounds();
|
|
1040
1056
|
if (minDefined) {
|
|
1041
|
-
start =
|
|
1057
|
+
start = Math.min(
|
|
1042
1058
|
// @ts-expect-error Need to type _parsed
|
|
1043
1059
|
_lookupByKey$1(_parsed, axis, min).lo,
|
|
1044
1060
|
// @ts-expect-error Need to fix types on _lookupByKey
|
|
1045
1061
|
animationsDisabled ? pointCount : _lookupByKey$1(points, axis, iScale.getPixelForValue(min)).lo
|
|
1046
|
-
)
|
|
1062
|
+
);
|
|
1063
|
+
if (spanGaps) {
|
|
1064
|
+
const distanceToDefinedLo = _parsed.slice(0, start + 1).reverse().findIndex((point) => !isNullOrUndef$1(point[vScale.axis]));
|
|
1065
|
+
start -= Math.max(0, distanceToDefinedLo);
|
|
1066
|
+
}
|
|
1067
|
+
start = _limitValue$1(start, 0, pointCount - 1);
|
|
1047
1068
|
}
|
|
1048
1069
|
if (maxDefined) {
|
|
1049
|
-
|
|
1070
|
+
let end = Math.max(
|
|
1050
1071
|
// @ts-expect-error Need to type _parsed
|
|
1051
1072
|
_lookupByKey$1(_parsed, iScale.axis, max, true).hi + 1,
|
|
1052
1073
|
// @ts-expect-error Need to fix types on _lookupByKey
|
|
1053
1074
|
animationsDisabled ? 0 : _lookupByKey$1(points, axis, iScale.getPixelForValue(max), true).hi + 1
|
|
1054
|
-
)
|
|
1075
|
+
);
|
|
1076
|
+
if (spanGaps) {
|
|
1077
|
+
const distanceToDefinedHi = _parsed.slice(end - 1).findIndex((point) => !isNullOrUndef$1(point[vScale.axis]));
|
|
1078
|
+
end += Math.max(0, distanceToDefinedHi);
|
|
1079
|
+
}
|
|
1080
|
+
count = _limitValue$1(end, start, pointCount) - start;
|
|
1055
1081
|
} else {
|
|
1056
1082
|
count = pointCount - start;
|
|
1057
1083
|
}
|
|
@@ -1562,6 +1588,7 @@ function drawPointLegend$1(ctx, options, x2, y2, w2) {
|
|
|
1562
1588
|
}
|
|
1563
1589
|
ctx.beginPath();
|
|
1564
1590
|
switch (style) {
|
|
1591
|
+
// Default includes circle
|
|
1565
1592
|
default:
|
|
1566
1593
|
if (w2) {
|
|
1567
1594
|
ctx.ellipse(x2, y2, w2 / 2, radius, 0, 0, TAU$1);
|
|
@@ -1600,6 +1627,7 @@ function drawPointLegend$1(ctx, options, x2, y2, w2) {
|
|
|
1600
1627
|
break;
|
|
1601
1628
|
}
|
|
1602
1629
|
rad += QUARTER_PI$1;
|
|
1630
|
+
/* falls through */
|
|
1603
1631
|
case "rectRot":
|
|
1604
1632
|
xOffsetW = Math.cos(rad) * (w2 ? w2 / 2 : radius);
|
|
1605
1633
|
xOffset = Math.cos(rad) * radius;
|
|
@@ -1613,6 +1641,7 @@ function drawPointLegend$1(ctx, options, x2, y2, w2) {
|
|
|
1613
1641
|
break;
|
|
1614
1642
|
case "crossRot":
|
|
1615
1643
|
rad += QUARTER_PI$1;
|
|
1644
|
+
/* falls through */
|
|
1616
1645
|
case "cross":
|
|
1617
1646
|
xOffsetW = Math.cos(rad) * (w2 ? w2 / 2 : radius);
|
|
1618
1647
|
xOffset = Math.cos(rad) * radius;
|
|
@@ -2883,9 +2912,9 @@ function styleChanged$1(style, prevStyle) {
|
|
|
2883
2912
|
return JSON.stringify(style, replacer) !== JSON.stringify(prevStyle, replacer);
|
|
2884
2913
|
}
|
|
2885
2914
|
/*!
|
|
2886
|
-
* Chart.js v4.4.
|
|
2915
|
+
* Chart.js v4.4.8
|
|
2887
2916
|
* https://www.chartjs.org
|
|
2888
|
-
* (c)
|
|
2917
|
+
* (c) 2025 Chart.js Contributors
|
|
2889
2918
|
* Released under the MIT License
|
|
2890
2919
|
*/
|
|
2891
2920
|
let Animator$1 = class Animator {
|
|
@@ -5094,10 +5123,20 @@ var adapters$1 = {
|
|
|
5094
5123
|
function binarySearch$1(metaset, axis, value, intersect) {
|
|
5095
5124
|
const { controller, data, _sorted } = metaset;
|
|
5096
5125
|
const iScale = controller._cachedMeta.iScale;
|
|
5126
|
+
const spanGaps = metaset.dataset ? metaset.dataset.options ? metaset.dataset.options.spanGaps : null : null;
|
|
5097
5127
|
if (iScale && axis === iScale.axis && axis !== "r" && _sorted && data.length) {
|
|
5098
5128
|
const lookupMethod = iScale._reversePixels ? _rlookupByKey$1 : _lookupByKey$1;
|
|
5099
5129
|
if (!intersect) {
|
|
5100
|
-
|
|
5130
|
+
const result = lookupMethod(data, axis, value);
|
|
5131
|
+
if (spanGaps) {
|
|
5132
|
+
const { vScale } = controller._cachedMeta;
|
|
5133
|
+
const { _parsed } = metaset;
|
|
5134
|
+
const distanceToDefinedLo = _parsed.slice(0, result.lo + 1).reverse().findIndex((point) => !isNullOrUndef$1(point[vScale.axis]));
|
|
5135
|
+
result.lo -= Math.max(0, distanceToDefinedLo);
|
|
5136
|
+
const distanceToDefinedHi = _parsed.slice(result.hi).findIndex((point) => !isNullOrUndef$1(point[vScale.axis]));
|
|
5137
|
+
result.hi += Math.max(0, distanceToDefinedHi);
|
|
5138
|
+
}
|
|
5139
|
+
return result;
|
|
5101
5140
|
} else if (controller._sharedOptions) {
|
|
5102
5141
|
const el = data[0];
|
|
5103
5142
|
const range = typeof el.getRange === "function" && el.getRange(axis);
|
|
@@ -7975,7 +8014,7 @@ function needContext$1(proxy, names2) {
|
|
|
7975
8014
|
}
|
|
7976
8015
|
return false;
|
|
7977
8016
|
}
|
|
7978
|
-
var version$3 = "4.4.
|
|
8017
|
+
var version$3 = "4.4.8";
|
|
7979
8018
|
const KNOWN_POSITIONS$1 = [
|
|
7980
8019
|
"top",
|
|
7981
8020
|
"bottom",
|
|
@@ -13133,1797 +13172,1803 @@ var hammer = { exports: {} };
|
|
|
13133
13172
|
*
|
|
13134
13173
|
* Copyright (c) 2016 Jorik Tangelder;
|
|
13135
13174
|
* Licensed under the MIT license */
|
|
13136
|
-
|
|
13137
|
-
|
|
13138
|
-
|
|
13139
|
-
|
|
13140
|
-
|
|
13141
|
-
|
|
13142
|
-
|
|
13143
|
-
|
|
13144
|
-
|
|
13145
|
-
|
|
13146
|
-
|
|
13147
|
-
|
|
13148
|
-
|
|
13149
|
-
|
|
13150
|
-
|
|
13151
|
-
|
|
13152
|
-
|
|
13153
|
-
|
|
13154
|
-
|
|
13155
|
-
var i2;
|
|
13156
|
-
if (!obj) {
|
|
13157
|
-
return;
|
|
13158
|
-
}
|
|
13159
|
-
if (obj.forEach) {
|
|
13160
|
-
obj.forEach(iterator, context);
|
|
13161
|
-
} else if (obj.length !== undefined$1) {
|
|
13162
|
-
i2 = 0;
|
|
13163
|
-
while (i2 < obj.length) {
|
|
13164
|
-
iterator.call(context, obj[i2], i2, obj);
|
|
13165
|
-
i2++;
|
|
13166
|
-
}
|
|
13167
|
-
} else {
|
|
13168
|
-
for (i2 in obj) {
|
|
13169
|
-
obj.hasOwnProperty(i2) && iterator.call(context, obj[i2], i2, obj);
|
|
13175
|
+
var hasRequiredHammer;
|
|
13176
|
+
function requireHammer() {
|
|
13177
|
+
if (hasRequiredHammer) return hammer.exports;
|
|
13178
|
+
hasRequiredHammer = 1;
|
|
13179
|
+
(function(module) {
|
|
13180
|
+
(function(window2, document2, exportName, undefined$1) {
|
|
13181
|
+
var VENDOR_PREFIXES = ["", "webkit", "Moz", "MS", "ms", "o"];
|
|
13182
|
+
var TEST_ELEMENT = document2.createElement("div");
|
|
13183
|
+
var TYPE_FUNCTION = "function";
|
|
13184
|
+
var round2 = Math.round;
|
|
13185
|
+
var abs = Math.abs;
|
|
13186
|
+
var now = Date.now;
|
|
13187
|
+
function setTimeoutContext(fn, timeout, context) {
|
|
13188
|
+
return setTimeout(bindFn(fn, context), timeout);
|
|
13189
|
+
}
|
|
13190
|
+
function invokeArrayArg(arg, fn, context) {
|
|
13191
|
+
if (Array.isArray(arg)) {
|
|
13192
|
+
each2(arg, context[fn], context);
|
|
13193
|
+
return true;
|
|
13170
13194
|
}
|
|
13195
|
+
return false;
|
|
13171
13196
|
}
|
|
13172
|
-
|
|
13173
|
-
|
|
13174
|
-
|
|
13175
|
-
|
|
13176
|
-
var e2 = new Error("get-stack-trace");
|
|
13177
|
-
var stack = e2 && e2.stack ? e2.stack.replace(/^[^\(]+?[\n$]/gm, "").replace(/^\s+at\s+/gm, "").replace(/^Object.<anonymous>\s*\(/gm, "{anonymous}()@") : "Unknown Stack Trace";
|
|
13178
|
-
var log = window2.console && (window2.console.warn || window2.console.log);
|
|
13179
|
-
if (log) {
|
|
13180
|
-
log.call(window2.console, deprecationMessage, stack);
|
|
13181
|
-
}
|
|
13182
|
-
return method.apply(this, arguments);
|
|
13183
|
-
};
|
|
13184
|
-
}
|
|
13185
|
-
var assign;
|
|
13186
|
-
if (typeof Object.assign !== "function") {
|
|
13187
|
-
assign = function assign2(target) {
|
|
13188
|
-
if (target === undefined$1 || target === null) {
|
|
13189
|
-
throw new TypeError("Cannot convert undefined or null to object");
|
|
13197
|
+
function each2(obj, iterator, context) {
|
|
13198
|
+
var i2;
|
|
13199
|
+
if (!obj) {
|
|
13200
|
+
return;
|
|
13190
13201
|
}
|
|
13191
|
-
|
|
13192
|
-
|
|
13193
|
-
|
|
13194
|
-
|
|
13195
|
-
|
|
13196
|
-
|
|
13197
|
-
|
|
13198
|
-
|
|
13199
|
-
|
|
13202
|
+
if (obj.forEach) {
|
|
13203
|
+
obj.forEach(iterator, context);
|
|
13204
|
+
} else if (obj.length !== undefined$1) {
|
|
13205
|
+
i2 = 0;
|
|
13206
|
+
while (i2 < obj.length) {
|
|
13207
|
+
iterator.call(context, obj[i2], i2, obj);
|
|
13208
|
+
i2++;
|
|
13209
|
+
}
|
|
13210
|
+
} else {
|
|
13211
|
+
for (i2 in obj) {
|
|
13212
|
+
obj.hasOwnProperty(i2) && iterator.call(context, obj[i2], i2, obj);
|
|
13200
13213
|
}
|
|
13201
13214
|
}
|
|
13202
|
-
return output;
|
|
13203
|
-
};
|
|
13204
|
-
} else {
|
|
13205
|
-
assign = Object.assign;
|
|
13206
|
-
}
|
|
13207
|
-
var extend = deprecate(function extend2(dest, src, merge3) {
|
|
13208
|
-
var keys = Object.keys(src);
|
|
13209
|
-
var i2 = 0;
|
|
13210
|
-
while (i2 < keys.length) {
|
|
13211
|
-
if (!merge3 || merge3 && dest[keys[i2]] === undefined$1) {
|
|
13212
|
-
dest[keys[i2]] = src[keys[i2]];
|
|
13213
|
-
}
|
|
13214
|
-
i2++;
|
|
13215
|
-
}
|
|
13216
|
-
return dest;
|
|
13217
|
-
}, "extend", "Use `assign`.");
|
|
13218
|
-
var merge2 = deprecate(function merge3(dest, src) {
|
|
13219
|
-
return extend(dest, src, true);
|
|
13220
|
-
}, "merge", "Use `assign`.");
|
|
13221
|
-
function inherit(child, base, properties) {
|
|
13222
|
-
var baseP = base.prototype, childP;
|
|
13223
|
-
childP = child.prototype = Object.create(baseP);
|
|
13224
|
-
childP.constructor = child;
|
|
13225
|
-
childP._super = baseP;
|
|
13226
|
-
if (properties) {
|
|
13227
|
-
assign(childP, properties);
|
|
13228
|
-
}
|
|
13229
|
-
}
|
|
13230
|
-
function bindFn(fn, context) {
|
|
13231
|
-
return function boundFn() {
|
|
13232
|
-
return fn.apply(context, arguments);
|
|
13233
|
-
};
|
|
13234
|
-
}
|
|
13235
|
-
function boolOrFn(val, args) {
|
|
13236
|
-
if (typeof val == TYPE_FUNCTION) {
|
|
13237
|
-
return val.apply(args ? args[0] || undefined$1 : undefined$1, args);
|
|
13238
13215
|
}
|
|
13239
|
-
|
|
13240
|
-
|
|
13241
|
-
|
|
13242
|
-
|
|
13243
|
-
|
|
13244
|
-
|
|
13245
|
-
|
|
13246
|
-
|
|
13247
|
-
|
|
13248
|
-
|
|
13249
|
-
|
|
13250
|
-
each2(splitStr(types), function(type) {
|
|
13251
|
-
target.removeEventListener(type, handler, false);
|
|
13252
|
-
});
|
|
13253
|
-
}
|
|
13254
|
-
function hasParent(node, parent) {
|
|
13255
|
-
while (node) {
|
|
13256
|
-
if (node == parent) {
|
|
13257
|
-
return true;
|
|
13258
|
-
}
|
|
13259
|
-
node = node.parentNode;
|
|
13216
|
+
function deprecate(method, name, message) {
|
|
13217
|
+
var deprecationMessage = "DEPRECATED METHOD: " + name + "\n" + message + " AT \n";
|
|
13218
|
+
return function() {
|
|
13219
|
+
var e2 = new Error("get-stack-trace");
|
|
13220
|
+
var stack = e2 && e2.stack ? e2.stack.replace(/^[^\(]+?[\n$]/gm, "").replace(/^\s+at\s+/gm, "").replace(/^Object.<anonymous>\s*\(/gm, "{anonymous}()@") : "Unknown Stack Trace";
|
|
13221
|
+
var log = window2.console && (window2.console.warn || window2.console.log);
|
|
13222
|
+
if (log) {
|
|
13223
|
+
log.call(window2.console, deprecationMessage, stack);
|
|
13224
|
+
}
|
|
13225
|
+
return method.apply(this, arguments);
|
|
13226
|
+
};
|
|
13260
13227
|
}
|
|
13261
|
-
|
|
13262
|
-
|
|
13263
|
-
|
|
13264
|
-
|
|
13265
|
-
|
|
13266
|
-
|
|
13267
|
-
|
|
13268
|
-
|
|
13269
|
-
|
|
13270
|
-
|
|
13271
|
-
|
|
13228
|
+
var assign;
|
|
13229
|
+
if (typeof Object.assign !== "function") {
|
|
13230
|
+
assign = function assign2(target) {
|
|
13231
|
+
if (target === undefined$1 || target === null) {
|
|
13232
|
+
throw new TypeError("Cannot convert undefined or null to object");
|
|
13233
|
+
}
|
|
13234
|
+
var output = Object(target);
|
|
13235
|
+
for (var index2 = 1; index2 < arguments.length; index2++) {
|
|
13236
|
+
var source = arguments[index2];
|
|
13237
|
+
if (source !== undefined$1 && source !== null) {
|
|
13238
|
+
for (var nextKey in source) {
|
|
13239
|
+
if (source.hasOwnProperty(nextKey)) {
|
|
13240
|
+
output[nextKey] = source[nextKey];
|
|
13241
|
+
}
|
|
13242
|
+
}
|
|
13243
|
+
}
|
|
13244
|
+
}
|
|
13245
|
+
return output;
|
|
13246
|
+
};
|
|
13272
13247
|
} else {
|
|
13248
|
+
assign = Object.assign;
|
|
13249
|
+
}
|
|
13250
|
+
var extend = deprecate(function extend2(dest, src, merge3) {
|
|
13251
|
+
var keys = Object.keys(src);
|
|
13273
13252
|
var i2 = 0;
|
|
13274
|
-
while (i2 <
|
|
13275
|
-
if (
|
|
13276
|
-
|
|
13253
|
+
while (i2 < keys.length) {
|
|
13254
|
+
if (!merge3 || merge3 && dest[keys[i2]] === undefined$1) {
|
|
13255
|
+
dest[keys[i2]] = src[keys[i2]];
|
|
13277
13256
|
}
|
|
13278
13257
|
i2++;
|
|
13279
13258
|
}
|
|
13280
|
-
return
|
|
13281
|
-
}
|
|
13282
|
-
|
|
13283
|
-
|
|
13284
|
-
|
|
13285
|
-
|
|
13286
|
-
|
|
13287
|
-
|
|
13288
|
-
|
|
13289
|
-
|
|
13290
|
-
|
|
13291
|
-
|
|
13292
|
-
if (inArray(values, val) < 0) {
|
|
13293
|
-
results.push(src[i2]);
|
|
13259
|
+
return dest;
|
|
13260
|
+
}, "extend", "Use `assign`.");
|
|
13261
|
+
var merge2 = deprecate(function merge3(dest, src) {
|
|
13262
|
+
return extend(dest, src, true);
|
|
13263
|
+
}, "merge", "Use `assign`.");
|
|
13264
|
+
function inherit(child, base, properties) {
|
|
13265
|
+
var baseP = base.prototype, childP;
|
|
13266
|
+
childP = child.prototype = Object.create(baseP);
|
|
13267
|
+
childP.constructor = child;
|
|
13268
|
+
childP._super = baseP;
|
|
13269
|
+
if (properties) {
|
|
13270
|
+
assign(childP, properties);
|
|
13294
13271
|
}
|
|
13295
|
-
values[i2] = val;
|
|
13296
|
-
i2++;
|
|
13297
13272
|
}
|
|
13298
|
-
{
|
|
13299
|
-
{
|
|
13300
|
-
|
|
13301
|
-
|
|
13302
|
-
});
|
|
13303
|
-
}
|
|
13273
|
+
function bindFn(fn, context) {
|
|
13274
|
+
return function boundFn() {
|
|
13275
|
+
return fn.apply(context, arguments);
|
|
13276
|
+
};
|
|
13304
13277
|
}
|
|
13305
|
-
|
|
13306
|
-
|
|
13307
|
-
|
|
13308
|
-
var prefix, prop;
|
|
13309
|
-
var camelProp = property[0].toUpperCase() + property.slice(1);
|
|
13310
|
-
var i2 = 0;
|
|
13311
|
-
while (i2 < VENDOR_PREFIXES.length) {
|
|
13312
|
-
prefix = VENDOR_PREFIXES[i2];
|
|
13313
|
-
prop = prefix ? prefix + camelProp : property;
|
|
13314
|
-
if (prop in obj) {
|
|
13315
|
-
return prop;
|
|
13316
|
-
}
|
|
13317
|
-
i2++;
|
|
13318
|
-
}
|
|
13319
|
-
return undefined$1;
|
|
13320
|
-
}
|
|
13321
|
-
var _uniqueId = 1;
|
|
13322
|
-
function uniqueId() {
|
|
13323
|
-
return _uniqueId++;
|
|
13324
|
-
}
|
|
13325
|
-
function getWindowForElement(element) {
|
|
13326
|
-
var doc = element.ownerDocument || element;
|
|
13327
|
-
return doc.defaultView || doc.parentWindow || window2;
|
|
13328
|
-
}
|
|
13329
|
-
var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
|
13330
|
-
var SUPPORT_TOUCH = "ontouchstart" in window2;
|
|
13331
|
-
var SUPPORT_POINTER_EVENTS = prefixed(window2, "PointerEvent") !== undefined$1;
|
|
13332
|
-
var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
|
|
13333
|
-
var INPUT_TYPE_TOUCH = "touch";
|
|
13334
|
-
var INPUT_TYPE_PEN = "pen";
|
|
13335
|
-
var INPUT_TYPE_MOUSE = "mouse";
|
|
13336
|
-
var INPUT_TYPE_KINECT = "kinect";
|
|
13337
|
-
var COMPUTE_INTERVAL = 25;
|
|
13338
|
-
var INPUT_START = 1;
|
|
13339
|
-
var INPUT_MOVE = 2;
|
|
13340
|
-
var INPUT_END = 4;
|
|
13341
|
-
var INPUT_CANCEL = 8;
|
|
13342
|
-
var DIRECTION_NONE = 1;
|
|
13343
|
-
var DIRECTION_LEFT = 2;
|
|
13344
|
-
var DIRECTION_RIGHT = 4;
|
|
13345
|
-
var DIRECTION_UP = 8;
|
|
13346
|
-
var DIRECTION_DOWN = 16;
|
|
13347
|
-
var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
|
|
13348
|
-
var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
|
|
13349
|
-
var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
|
|
13350
|
-
var PROPS_XY = ["x", "y"];
|
|
13351
|
-
var PROPS_CLIENT_XY = ["clientX", "clientY"];
|
|
13352
|
-
function Input(manager, callback2) {
|
|
13353
|
-
var self2 = this;
|
|
13354
|
-
this.manager = manager;
|
|
13355
|
-
this.callback = callback2;
|
|
13356
|
-
this.element = manager.element;
|
|
13357
|
-
this.target = manager.options.inputTarget;
|
|
13358
|
-
this.domHandler = function(ev) {
|
|
13359
|
-
if (boolOrFn(manager.options.enable, [manager])) {
|
|
13360
|
-
self2.handler(ev);
|
|
13278
|
+
function boolOrFn(val, args) {
|
|
13279
|
+
if (typeof val == TYPE_FUNCTION) {
|
|
13280
|
+
return val.apply(args ? args[0] || undefined$1 : undefined$1, args);
|
|
13361
13281
|
}
|
|
13362
|
-
|
|
13363
|
-
this.init();
|
|
13364
|
-
}
|
|
13365
|
-
Input.prototype = {
|
|
13366
|
-
/**
|
|
13367
|
-
* should handle the inputEvent data and trigger the callback
|
|
13368
|
-
* @virtual
|
|
13369
|
-
*/
|
|
13370
|
-
handler: function() {
|
|
13371
|
-
},
|
|
13372
|
-
/**
|
|
13373
|
-
* bind the events
|
|
13374
|
-
*/
|
|
13375
|
-
init: function() {
|
|
13376
|
-
this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
|
|
13377
|
-
this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
|
|
13378
|
-
this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
|
13379
|
-
},
|
|
13380
|
-
/**
|
|
13381
|
-
* unbind the events
|
|
13382
|
-
*/
|
|
13383
|
-
destroy: function() {
|
|
13384
|
-
this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
|
|
13385
|
-
this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
|
|
13386
|
-
this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
|
13282
|
+
return val;
|
|
13387
13283
|
}
|
|
13388
|
-
|
|
13389
|
-
|
|
13390
|
-
var Type;
|
|
13391
|
-
var inputClass = manager.options.inputClass;
|
|
13392
|
-
if (inputClass) {
|
|
13393
|
-
Type = inputClass;
|
|
13394
|
-
} else if (SUPPORT_POINTER_EVENTS) {
|
|
13395
|
-
Type = PointerEventInput;
|
|
13396
|
-
} else if (SUPPORT_ONLY_TOUCH) {
|
|
13397
|
-
Type = TouchInput;
|
|
13398
|
-
} else if (!SUPPORT_TOUCH) {
|
|
13399
|
-
Type = MouseInput;
|
|
13400
|
-
} else {
|
|
13401
|
-
Type = TouchMouseInput;
|
|
13402
|
-
}
|
|
13403
|
-
return new Type(manager, inputHandler);
|
|
13404
|
-
}
|
|
13405
|
-
function inputHandler(manager, eventType, input) {
|
|
13406
|
-
var pointersLen = input.pointers.length;
|
|
13407
|
-
var changedPointersLen = input.changedPointers.length;
|
|
13408
|
-
var isFirst = eventType & INPUT_START && pointersLen - changedPointersLen === 0;
|
|
13409
|
-
var isFinal = eventType & (INPUT_END | INPUT_CANCEL) && pointersLen - changedPointersLen === 0;
|
|
13410
|
-
input.isFirst = !!isFirst;
|
|
13411
|
-
input.isFinal = !!isFinal;
|
|
13412
|
-
if (isFirst) {
|
|
13413
|
-
manager.session = {};
|
|
13414
|
-
}
|
|
13415
|
-
input.eventType = eventType;
|
|
13416
|
-
computeInputData(manager, input);
|
|
13417
|
-
manager.emit("hammer.input", input);
|
|
13418
|
-
manager.recognize(input);
|
|
13419
|
-
manager.session.prevInput = input;
|
|
13420
|
-
}
|
|
13421
|
-
function computeInputData(manager, input) {
|
|
13422
|
-
var session = manager.session;
|
|
13423
|
-
var pointers = input.pointers;
|
|
13424
|
-
var pointersLength = pointers.length;
|
|
13425
|
-
if (!session.firstInput) {
|
|
13426
|
-
session.firstInput = simpleCloneInputData(input);
|
|
13427
|
-
}
|
|
13428
|
-
if (pointersLength > 1 && !session.firstMultiple) {
|
|
13429
|
-
session.firstMultiple = simpleCloneInputData(input);
|
|
13430
|
-
} else if (pointersLength === 1) {
|
|
13431
|
-
session.firstMultiple = false;
|
|
13432
|
-
}
|
|
13433
|
-
var firstInput = session.firstInput;
|
|
13434
|
-
var firstMultiple = session.firstMultiple;
|
|
13435
|
-
var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
|
|
13436
|
-
var center = input.center = getCenter2(pointers);
|
|
13437
|
-
input.timeStamp = now();
|
|
13438
|
-
input.deltaTime = input.timeStamp - firstInput.timeStamp;
|
|
13439
|
-
input.angle = getAngle(offsetCenter, center);
|
|
13440
|
-
input.distance = getDistance(offsetCenter, center);
|
|
13441
|
-
computeDeltaXY(session, input);
|
|
13442
|
-
input.offsetDirection = getDirection(input.deltaX, input.deltaY);
|
|
13443
|
-
var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
|
|
13444
|
-
input.overallVelocityX = overallVelocity.x;
|
|
13445
|
-
input.overallVelocityY = overallVelocity.y;
|
|
13446
|
-
input.overallVelocity = abs(overallVelocity.x) > abs(overallVelocity.y) ? overallVelocity.x : overallVelocity.y;
|
|
13447
|
-
input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
|
|
13448
|
-
input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
|
|
13449
|
-
input.maxPointers = !session.prevInput ? input.pointers.length : input.pointers.length > session.prevInput.maxPointers ? input.pointers.length : session.prevInput.maxPointers;
|
|
13450
|
-
computeIntervalInputData(session, input);
|
|
13451
|
-
var target = manager.element;
|
|
13452
|
-
if (hasParent(input.srcEvent.target, target)) {
|
|
13453
|
-
target = input.srcEvent.target;
|
|
13454
|
-
}
|
|
13455
|
-
input.target = target;
|
|
13456
|
-
}
|
|
13457
|
-
function computeDeltaXY(session, input) {
|
|
13458
|
-
var center = input.center;
|
|
13459
|
-
var offset = session.offsetDelta || {};
|
|
13460
|
-
var prevDelta = session.prevDelta || {};
|
|
13461
|
-
var prevInput = session.prevInput || {};
|
|
13462
|
-
if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
|
|
13463
|
-
prevDelta = session.prevDelta = {
|
|
13464
|
-
x: prevInput.deltaX || 0,
|
|
13465
|
-
y: prevInput.deltaY || 0
|
|
13466
|
-
};
|
|
13467
|
-
offset = session.offsetDelta = {
|
|
13468
|
-
x: center.x,
|
|
13469
|
-
y: center.y
|
|
13470
|
-
};
|
|
13284
|
+
function ifUndefined(val1, val2) {
|
|
13285
|
+
return val1 === undefined$1 ? val2 : val1;
|
|
13471
13286
|
}
|
|
13472
|
-
|
|
13473
|
-
|
|
13474
|
-
|
|
13475
|
-
|
|
13476
|
-
var last = session.lastInterval || input, deltaTime = input.timeStamp - last.timeStamp, velocity, velocityX, velocityY, direction;
|
|
13477
|
-
if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined$1)) {
|
|
13478
|
-
var deltaX = input.deltaX - last.deltaX;
|
|
13479
|
-
var deltaY = input.deltaY - last.deltaY;
|
|
13480
|
-
var v2 = getVelocity(deltaTime, deltaX, deltaY);
|
|
13481
|
-
velocityX = v2.x;
|
|
13482
|
-
velocityY = v2.y;
|
|
13483
|
-
velocity = abs(v2.x) > abs(v2.y) ? v2.x : v2.y;
|
|
13484
|
-
direction = getDirection(deltaX, deltaY);
|
|
13485
|
-
session.lastInterval = input;
|
|
13486
|
-
} else {
|
|
13487
|
-
velocity = last.velocity;
|
|
13488
|
-
velocityX = last.velocityX;
|
|
13489
|
-
velocityY = last.velocityY;
|
|
13490
|
-
direction = last.direction;
|
|
13491
|
-
}
|
|
13492
|
-
input.velocity = velocity;
|
|
13493
|
-
input.velocityX = velocityX;
|
|
13494
|
-
input.velocityY = velocityY;
|
|
13495
|
-
input.direction = direction;
|
|
13496
|
-
}
|
|
13497
|
-
function simpleCloneInputData(input) {
|
|
13498
|
-
var pointers = [];
|
|
13499
|
-
var i2 = 0;
|
|
13500
|
-
while (i2 < input.pointers.length) {
|
|
13501
|
-
pointers[i2] = {
|
|
13502
|
-
clientX: round2(input.pointers[i2].clientX),
|
|
13503
|
-
clientY: round2(input.pointers[i2].clientY)
|
|
13504
|
-
};
|
|
13505
|
-
i2++;
|
|
13287
|
+
function addEventListeners(target, types, handler) {
|
|
13288
|
+
each2(splitStr(types), function(type) {
|
|
13289
|
+
target.addEventListener(type, handler, false);
|
|
13290
|
+
});
|
|
13506
13291
|
}
|
|
13507
|
-
|
|
13508
|
-
|
|
13509
|
-
|
|
13510
|
-
|
|
13511
|
-
deltaX: input.deltaX,
|
|
13512
|
-
deltaY: input.deltaY
|
|
13513
|
-
};
|
|
13514
|
-
}
|
|
13515
|
-
function getCenter2(pointers) {
|
|
13516
|
-
var pointersLength = pointers.length;
|
|
13517
|
-
if (pointersLength === 1) {
|
|
13518
|
-
return {
|
|
13519
|
-
x: round2(pointers[0].clientX),
|
|
13520
|
-
y: round2(pointers[0].clientY)
|
|
13521
|
-
};
|
|
13292
|
+
function removeEventListeners(target, types, handler) {
|
|
13293
|
+
each2(splitStr(types), function(type) {
|
|
13294
|
+
target.removeEventListener(type, handler, false);
|
|
13295
|
+
});
|
|
13522
13296
|
}
|
|
13523
|
-
|
|
13524
|
-
|
|
13525
|
-
|
|
13526
|
-
|
|
13527
|
-
|
|
13297
|
+
function hasParent(node, parent) {
|
|
13298
|
+
while (node) {
|
|
13299
|
+
if (node == parent) {
|
|
13300
|
+
return true;
|
|
13301
|
+
}
|
|
13302
|
+
node = node.parentNode;
|
|
13303
|
+
}
|
|
13304
|
+
return false;
|
|
13528
13305
|
}
|
|
13529
|
-
|
|
13530
|
-
|
|
13531
|
-
y: round2(y2 / pointersLength)
|
|
13532
|
-
};
|
|
13533
|
-
}
|
|
13534
|
-
function getVelocity(deltaTime, x2, y2) {
|
|
13535
|
-
return {
|
|
13536
|
-
x: x2 / deltaTime || 0,
|
|
13537
|
-
y: y2 / deltaTime || 0
|
|
13538
|
-
};
|
|
13539
|
-
}
|
|
13540
|
-
function getDirection(x2, y2) {
|
|
13541
|
-
if (x2 === y2) {
|
|
13542
|
-
return DIRECTION_NONE;
|
|
13306
|
+
function inStr(str, find2) {
|
|
13307
|
+
return str.indexOf(find2) > -1;
|
|
13543
13308
|
}
|
|
13544
|
-
|
|
13545
|
-
return
|
|
13309
|
+
function splitStr(str) {
|
|
13310
|
+
return str.trim().split(/\s+/g);
|
|
13546
13311
|
}
|
|
13547
|
-
|
|
13548
|
-
|
|
13549
|
-
|
|
13550
|
-
|
|
13551
|
-
|
|
13312
|
+
function inArray(src, find2, findByKey) {
|
|
13313
|
+
if (src.indexOf && !findByKey) {
|
|
13314
|
+
return src.indexOf(find2);
|
|
13315
|
+
} else {
|
|
13316
|
+
var i2 = 0;
|
|
13317
|
+
while (i2 < src.length) {
|
|
13318
|
+
if (findByKey && src[i2][findByKey] == find2 || !findByKey && src[i2] === find2) {
|
|
13319
|
+
return i2;
|
|
13320
|
+
}
|
|
13321
|
+
i2++;
|
|
13322
|
+
}
|
|
13323
|
+
return -1;
|
|
13324
|
+
}
|
|
13552
13325
|
}
|
|
13553
|
-
|
|
13554
|
-
|
|
13555
|
-
}
|
|
13556
|
-
function getAngle(p1, p2, props) {
|
|
13557
|
-
if (!props) {
|
|
13558
|
-
props = PROPS_XY;
|
|
13326
|
+
function toArray2(obj) {
|
|
13327
|
+
return Array.prototype.slice.call(obj, 0);
|
|
13559
13328
|
}
|
|
13560
|
-
|
|
13561
|
-
|
|
13562
|
-
|
|
13563
|
-
|
|
13564
|
-
|
|
13565
|
-
|
|
13566
|
-
|
|
13567
|
-
|
|
13568
|
-
|
|
13569
|
-
|
|
13570
|
-
|
|
13571
|
-
mousemove: INPUT_MOVE,
|
|
13572
|
-
mouseup: INPUT_END
|
|
13573
|
-
};
|
|
13574
|
-
var MOUSE_ELEMENT_EVENTS = "mousedown";
|
|
13575
|
-
var MOUSE_WINDOW_EVENTS = "mousemove mouseup";
|
|
13576
|
-
function MouseInput() {
|
|
13577
|
-
this.evEl = MOUSE_ELEMENT_EVENTS;
|
|
13578
|
-
this.evWin = MOUSE_WINDOW_EVENTS;
|
|
13579
|
-
this.pressed = false;
|
|
13580
|
-
Input.apply(this, arguments);
|
|
13581
|
-
}
|
|
13582
|
-
inherit(MouseInput, Input, {
|
|
13583
|
-
/**
|
|
13584
|
-
* handle mouse events
|
|
13585
|
-
* @param {Object} ev
|
|
13586
|
-
*/
|
|
13587
|
-
handler: function MEhandler(ev) {
|
|
13588
|
-
var eventType = MOUSE_INPUT_MAP[ev.type];
|
|
13589
|
-
if (eventType & INPUT_START && ev.button === 0) {
|
|
13590
|
-
this.pressed = true;
|
|
13591
|
-
}
|
|
13592
|
-
if (eventType & INPUT_MOVE && ev.which !== 1) {
|
|
13593
|
-
eventType = INPUT_END;
|
|
13594
|
-
}
|
|
13595
|
-
if (!this.pressed) {
|
|
13596
|
-
return;
|
|
13329
|
+
function uniqueArray(src, key, sort) {
|
|
13330
|
+
var results = [];
|
|
13331
|
+
var values = [];
|
|
13332
|
+
var i2 = 0;
|
|
13333
|
+
while (i2 < src.length) {
|
|
13334
|
+
var val = src[i2][key];
|
|
13335
|
+
if (inArray(values, val) < 0) {
|
|
13336
|
+
results.push(src[i2]);
|
|
13337
|
+
}
|
|
13338
|
+
values[i2] = val;
|
|
13339
|
+
i2++;
|
|
13597
13340
|
}
|
|
13598
|
-
|
|
13599
|
-
|
|
13341
|
+
{
|
|
13342
|
+
{
|
|
13343
|
+
results = results.sort(function sortUniqueArray(a2, b2) {
|
|
13344
|
+
return a2[key] > b2[key];
|
|
13345
|
+
});
|
|
13346
|
+
}
|
|
13600
13347
|
}
|
|
13601
|
-
|
|
13602
|
-
pointers: [ev],
|
|
13603
|
-
changedPointers: [ev],
|
|
13604
|
-
pointerType: INPUT_TYPE_MOUSE,
|
|
13605
|
-
srcEvent: ev
|
|
13606
|
-
});
|
|
13348
|
+
return results;
|
|
13607
13349
|
}
|
|
13608
|
-
|
|
13609
|
-
|
|
13610
|
-
|
|
13611
|
-
|
|
13612
|
-
|
|
13613
|
-
|
|
13614
|
-
|
|
13615
|
-
|
|
13616
|
-
|
|
13617
|
-
2: INPUT_TYPE_TOUCH,
|
|
13618
|
-
3: INPUT_TYPE_PEN,
|
|
13619
|
-
4: INPUT_TYPE_MOUSE,
|
|
13620
|
-
5: INPUT_TYPE_KINECT
|
|
13621
|
-
// see https://twitter.com/jacobrossi/status/480596438489890816
|
|
13622
|
-
};
|
|
13623
|
-
var POINTER_ELEMENT_EVENTS = "pointerdown";
|
|
13624
|
-
var POINTER_WINDOW_EVENTS = "pointermove pointerup pointercancel";
|
|
13625
|
-
if (window2.MSPointerEvent && !window2.PointerEvent) {
|
|
13626
|
-
POINTER_ELEMENT_EVENTS = "MSPointerDown";
|
|
13627
|
-
POINTER_WINDOW_EVENTS = "MSPointerMove MSPointerUp MSPointerCancel";
|
|
13628
|
-
}
|
|
13629
|
-
function PointerEventInput() {
|
|
13630
|
-
this.evEl = POINTER_ELEMENT_EVENTS;
|
|
13631
|
-
this.evWin = POINTER_WINDOW_EVENTS;
|
|
13632
|
-
Input.apply(this, arguments);
|
|
13633
|
-
this.store = this.manager.session.pointerEvents = [];
|
|
13634
|
-
}
|
|
13635
|
-
inherit(PointerEventInput, Input, {
|
|
13636
|
-
/**
|
|
13637
|
-
* handle mouse events
|
|
13638
|
-
* @param {Object} ev
|
|
13639
|
-
*/
|
|
13640
|
-
handler: function PEhandler(ev) {
|
|
13641
|
-
var store = this.store;
|
|
13642
|
-
var removePointer = false;
|
|
13643
|
-
var eventTypeNormalized = ev.type.toLowerCase().replace("ms", "");
|
|
13644
|
-
var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
|
|
13645
|
-
var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
|
|
13646
|
-
var isTouch = pointerType == INPUT_TYPE_TOUCH;
|
|
13647
|
-
var storeIndex = inArray(store, ev.pointerId, "pointerId");
|
|
13648
|
-
if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
|
|
13649
|
-
if (storeIndex < 0) {
|
|
13650
|
-
store.push(ev);
|
|
13651
|
-
storeIndex = store.length - 1;
|
|
13350
|
+
function prefixed(obj, property) {
|
|
13351
|
+
var prefix, prop;
|
|
13352
|
+
var camelProp = property[0].toUpperCase() + property.slice(1);
|
|
13353
|
+
var i2 = 0;
|
|
13354
|
+
while (i2 < VENDOR_PREFIXES.length) {
|
|
13355
|
+
prefix = VENDOR_PREFIXES[i2];
|
|
13356
|
+
prop = prefix ? prefix + camelProp : property;
|
|
13357
|
+
if (prop in obj) {
|
|
13358
|
+
return prop;
|
|
13652
13359
|
}
|
|
13653
|
-
|
|
13654
|
-
removePointer = true;
|
|
13360
|
+
i2++;
|
|
13655
13361
|
}
|
|
13656
|
-
|
|
13657
|
-
|
|
13362
|
+
return undefined$1;
|
|
13363
|
+
}
|
|
13364
|
+
var _uniqueId = 1;
|
|
13365
|
+
function uniqueId() {
|
|
13366
|
+
return _uniqueId++;
|
|
13367
|
+
}
|
|
13368
|
+
function getWindowForElement(element) {
|
|
13369
|
+
var doc = element.ownerDocument || element;
|
|
13370
|
+
return doc.defaultView || doc.parentWindow || window2;
|
|
13371
|
+
}
|
|
13372
|
+
var MOBILE_REGEX = /mobile|tablet|ip(ad|hone|od)|android/i;
|
|
13373
|
+
var SUPPORT_TOUCH = "ontouchstart" in window2;
|
|
13374
|
+
var SUPPORT_POINTER_EVENTS = prefixed(window2, "PointerEvent") !== undefined$1;
|
|
13375
|
+
var SUPPORT_ONLY_TOUCH = SUPPORT_TOUCH && MOBILE_REGEX.test(navigator.userAgent);
|
|
13376
|
+
var INPUT_TYPE_TOUCH = "touch";
|
|
13377
|
+
var INPUT_TYPE_PEN = "pen";
|
|
13378
|
+
var INPUT_TYPE_MOUSE = "mouse";
|
|
13379
|
+
var INPUT_TYPE_KINECT = "kinect";
|
|
13380
|
+
var COMPUTE_INTERVAL = 25;
|
|
13381
|
+
var INPUT_START = 1;
|
|
13382
|
+
var INPUT_MOVE = 2;
|
|
13383
|
+
var INPUT_END = 4;
|
|
13384
|
+
var INPUT_CANCEL = 8;
|
|
13385
|
+
var DIRECTION_NONE = 1;
|
|
13386
|
+
var DIRECTION_LEFT = 2;
|
|
13387
|
+
var DIRECTION_RIGHT = 4;
|
|
13388
|
+
var DIRECTION_UP = 8;
|
|
13389
|
+
var DIRECTION_DOWN = 16;
|
|
13390
|
+
var DIRECTION_HORIZONTAL = DIRECTION_LEFT | DIRECTION_RIGHT;
|
|
13391
|
+
var DIRECTION_VERTICAL = DIRECTION_UP | DIRECTION_DOWN;
|
|
13392
|
+
var DIRECTION_ALL = DIRECTION_HORIZONTAL | DIRECTION_VERTICAL;
|
|
13393
|
+
var PROPS_XY = ["x", "y"];
|
|
13394
|
+
var PROPS_CLIENT_XY = ["clientX", "clientY"];
|
|
13395
|
+
function Input(manager, callback2) {
|
|
13396
|
+
var self2 = this;
|
|
13397
|
+
this.manager = manager;
|
|
13398
|
+
this.callback = callback2;
|
|
13399
|
+
this.element = manager.element;
|
|
13400
|
+
this.target = manager.options.inputTarget;
|
|
13401
|
+
this.domHandler = function(ev) {
|
|
13402
|
+
if (boolOrFn(manager.options.enable, [manager])) {
|
|
13403
|
+
self2.handler(ev);
|
|
13404
|
+
}
|
|
13405
|
+
};
|
|
13406
|
+
this.init();
|
|
13407
|
+
}
|
|
13408
|
+
Input.prototype = {
|
|
13409
|
+
/**
|
|
13410
|
+
* should handle the inputEvent data and trigger the callback
|
|
13411
|
+
* @virtual
|
|
13412
|
+
*/
|
|
13413
|
+
handler: function() {
|
|
13414
|
+
},
|
|
13415
|
+
/**
|
|
13416
|
+
* bind the events
|
|
13417
|
+
*/
|
|
13418
|
+
init: function() {
|
|
13419
|
+
this.evEl && addEventListeners(this.element, this.evEl, this.domHandler);
|
|
13420
|
+
this.evTarget && addEventListeners(this.target, this.evTarget, this.domHandler);
|
|
13421
|
+
this.evWin && addEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
|
13422
|
+
},
|
|
13423
|
+
/**
|
|
13424
|
+
* unbind the events
|
|
13425
|
+
*/
|
|
13426
|
+
destroy: function() {
|
|
13427
|
+
this.evEl && removeEventListeners(this.element, this.evEl, this.domHandler);
|
|
13428
|
+
this.evTarget && removeEventListeners(this.target, this.evTarget, this.domHandler);
|
|
13429
|
+
this.evWin && removeEventListeners(getWindowForElement(this.element), this.evWin, this.domHandler);
|
|
13658
13430
|
}
|
|
13659
|
-
|
|
13660
|
-
|
|
13661
|
-
|
|
13662
|
-
|
|
13663
|
-
|
|
13664
|
-
|
|
13665
|
-
})
|
|
13666
|
-
|
|
13667
|
-
|
|
13431
|
+
};
|
|
13432
|
+
function createInputInstance(manager) {
|
|
13433
|
+
var Type;
|
|
13434
|
+
var inputClass = manager.options.inputClass;
|
|
13435
|
+
if (inputClass) {
|
|
13436
|
+
Type = inputClass;
|
|
13437
|
+
} else if (SUPPORT_POINTER_EVENTS) {
|
|
13438
|
+
Type = PointerEventInput;
|
|
13439
|
+
} else if (SUPPORT_ONLY_TOUCH) {
|
|
13440
|
+
Type = TouchInput;
|
|
13441
|
+
} else if (!SUPPORT_TOUCH) {
|
|
13442
|
+
Type = MouseInput;
|
|
13443
|
+
} else {
|
|
13444
|
+
Type = TouchMouseInput;
|
|
13668
13445
|
}
|
|
13669
|
-
|
|
13670
|
-
|
|
13671
|
-
|
|
13672
|
-
|
|
13673
|
-
|
|
13674
|
-
|
|
13675
|
-
|
|
13676
|
-
|
|
13677
|
-
|
|
13678
|
-
|
|
13679
|
-
|
|
13680
|
-
this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
|
|
13681
|
-
this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
|
|
13682
|
-
this.started = false;
|
|
13683
|
-
Input.apply(this, arguments);
|
|
13684
|
-
}
|
|
13685
|
-
inherit(SingleTouchInput, Input, {
|
|
13686
|
-
handler: function TEhandler(ev) {
|
|
13687
|
-
var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
|
13688
|
-
if (type === INPUT_START) {
|
|
13689
|
-
this.started = true;
|
|
13446
|
+
return new Type(manager, inputHandler);
|
|
13447
|
+
}
|
|
13448
|
+
function inputHandler(manager, eventType, input) {
|
|
13449
|
+
var pointersLen = input.pointers.length;
|
|
13450
|
+
var changedPointersLen = input.changedPointers.length;
|
|
13451
|
+
var isFirst = eventType & INPUT_START && pointersLen - changedPointersLen === 0;
|
|
13452
|
+
var isFinal = eventType & (INPUT_END | INPUT_CANCEL) && pointersLen - changedPointersLen === 0;
|
|
13453
|
+
input.isFirst = !!isFirst;
|
|
13454
|
+
input.isFinal = !!isFinal;
|
|
13455
|
+
if (isFirst) {
|
|
13456
|
+
manager.session = {};
|
|
13690
13457
|
}
|
|
13691
|
-
|
|
13692
|
-
|
|
13458
|
+
input.eventType = eventType;
|
|
13459
|
+
computeInputData(manager, input);
|
|
13460
|
+
manager.emit("hammer.input", input);
|
|
13461
|
+
manager.recognize(input);
|
|
13462
|
+
manager.session.prevInput = input;
|
|
13463
|
+
}
|
|
13464
|
+
function computeInputData(manager, input) {
|
|
13465
|
+
var session = manager.session;
|
|
13466
|
+
var pointers = input.pointers;
|
|
13467
|
+
var pointersLength = pointers.length;
|
|
13468
|
+
if (!session.firstInput) {
|
|
13469
|
+
session.firstInput = simpleCloneInputData(input);
|
|
13693
13470
|
}
|
|
13694
|
-
|
|
13695
|
-
|
|
13696
|
-
|
|
13471
|
+
if (pointersLength > 1 && !session.firstMultiple) {
|
|
13472
|
+
session.firstMultiple = simpleCloneInputData(input);
|
|
13473
|
+
} else if (pointersLength === 1) {
|
|
13474
|
+
session.firstMultiple = false;
|
|
13697
13475
|
}
|
|
13698
|
-
|
|
13699
|
-
|
|
13700
|
-
|
|
13701
|
-
|
|
13702
|
-
|
|
13703
|
-
|
|
13704
|
-
|
|
13705
|
-
|
|
13706
|
-
|
|
13707
|
-
|
|
13708
|
-
|
|
13709
|
-
|
|
13710
|
-
|
|
13711
|
-
|
|
13712
|
-
|
|
13713
|
-
|
|
13714
|
-
|
|
13715
|
-
|
|
13716
|
-
|
|
13717
|
-
|
|
13718
|
-
|
|
13719
|
-
};
|
|
13720
|
-
var TOUCH_TARGET_EVENTS = "touchstart touchmove touchend touchcancel";
|
|
13721
|
-
function TouchInput() {
|
|
13722
|
-
this.evTarget = TOUCH_TARGET_EVENTS;
|
|
13723
|
-
this.targetIds = {};
|
|
13724
|
-
Input.apply(this, arguments);
|
|
13725
|
-
}
|
|
13726
|
-
inherit(TouchInput, Input, {
|
|
13727
|
-
handler: function MTEhandler(ev) {
|
|
13728
|
-
var type = TOUCH_INPUT_MAP[ev.type];
|
|
13729
|
-
var touches = getTouches.call(this, ev, type);
|
|
13730
|
-
if (!touches) {
|
|
13731
|
-
return;
|
|
13476
|
+
var firstInput = session.firstInput;
|
|
13477
|
+
var firstMultiple = session.firstMultiple;
|
|
13478
|
+
var offsetCenter = firstMultiple ? firstMultiple.center : firstInput.center;
|
|
13479
|
+
var center = input.center = getCenter2(pointers);
|
|
13480
|
+
input.timeStamp = now();
|
|
13481
|
+
input.deltaTime = input.timeStamp - firstInput.timeStamp;
|
|
13482
|
+
input.angle = getAngle(offsetCenter, center);
|
|
13483
|
+
input.distance = getDistance(offsetCenter, center);
|
|
13484
|
+
computeDeltaXY(session, input);
|
|
13485
|
+
input.offsetDirection = getDirection(input.deltaX, input.deltaY);
|
|
13486
|
+
var overallVelocity = getVelocity(input.deltaTime, input.deltaX, input.deltaY);
|
|
13487
|
+
input.overallVelocityX = overallVelocity.x;
|
|
13488
|
+
input.overallVelocityY = overallVelocity.y;
|
|
13489
|
+
input.overallVelocity = abs(overallVelocity.x) > abs(overallVelocity.y) ? overallVelocity.x : overallVelocity.y;
|
|
13490
|
+
input.scale = firstMultiple ? getScale(firstMultiple.pointers, pointers) : 1;
|
|
13491
|
+
input.rotation = firstMultiple ? getRotation(firstMultiple.pointers, pointers) : 0;
|
|
13492
|
+
input.maxPointers = !session.prevInput ? input.pointers.length : input.pointers.length > session.prevInput.maxPointers ? input.pointers.length : session.prevInput.maxPointers;
|
|
13493
|
+
computeIntervalInputData(session, input);
|
|
13494
|
+
var target = manager.element;
|
|
13495
|
+
if (hasParent(input.srcEvent.target, target)) {
|
|
13496
|
+
target = input.srcEvent.target;
|
|
13732
13497
|
}
|
|
13733
|
-
|
|
13734
|
-
|
|
13735
|
-
|
|
13736
|
-
|
|
13737
|
-
|
|
13738
|
-
}
|
|
13498
|
+
input.target = target;
|
|
13499
|
+
}
|
|
13500
|
+
function computeDeltaXY(session, input) {
|
|
13501
|
+
var center = input.center;
|
|
13502
|
+
var offset = session.offsetDelta || {};
|
|
13503
|
+
var prevDelta = session.prevDelta || {};
|
|
13504
|
+
var prevInput = session.prevInput || {};
|
|
13505
|
+
if (input.eventType === INPUT_START || prevInput.eventType === INPUT_END) {
|
|
13506
|
+
prevDelta = session.prevDelta = {
|
|
13507
|
+
x: prevInput.deltaX || 0,
|
|
13508
|
+
y: prevInput.deltaY || 0
|
|
13509
|
+
};
|
|
13510
|
+
offset = session.offsetDelta = {
|
|
13511
|
+
x: center.x,
|
|
13512
|
+
y: center.y
|
|
13513
|
+
};
|
|
13514
|
+
}
|
|
13515
|
+
input.deltaX = prevDelta.x + (center.x - offset.x);
|
|
13516
|
+
input.deltaY = prevDelta.y + (center.y - offset.y);
|
|
13517
|
+
}
|
|
13518
|
+
function computeIntervalInputData(session, input) {
|
|
13519
|
+
var last = session.lastInterval || input, deltaTime = input.timeStamp - last.timeStamp, velocity, velocityX, velocityY, direction;
|
|
13520
|
+
if (input.eventType != INPUT_CANCEL && (deltaTime > COMPUTE_INTERVAL || last.velocity === undefined$1)) {
|
|
13521
|
+
var deltaX = input.deltaX - last.deltaX;
|
|
13522
|
+
var deltaY = input.deltaY - last.deltaY;
|
|
13523
|
+
var v2 = getVelocity(deltaTime, deltaX, deltaY);
|
|
13524
|
+
velocityX = v2.x;
|
|
13525
|
+
velocityY = v2.y;
|
|
13526
|
+
velocity = abs(v2.x) > abs(v2.y) ? v2.x : v2.y;
|
|
13527
|
+
direction = getDirection(deltaX, deltaY);
|
|
13528
|
+
session.lastInterval = input;
|
|
13529
|
+
} else {
|
|
13530
|
+
velocity = last.velocity;
|
|
13531
|
+
velocityX = last.velocityX;
|
|
13532
|
+
velocityY = last.velocityY;
|
|
13533
|
+
direction = last.direction;
|
|
13534
|
+
}
|
|
13535
|
+
input.velocity = velocity;
|
|
13536
|
+
input.velocityX = velocityX;
|
|
13537
|
+
input.velocityY = velocityY;
|
|
13538
|
+
input.direction = direction;
|
|
13739
13539
|
}
|
|
13740
|
-
|
|
13741
|
-
|
|
13742
|
-
|
|
13743
|
-
|
|
13744
|
-
|
|
13745
|
-
|
|
13746
|
-
|
|
13747
|
-
|
|
13748
|
-
var i2, targetTouches, changedTouches = toArray2(ev.changedTouches), changedTargetTouches = [], target = this.target;
|
|
13749
|
-
targetTouches = allTouches.filter(function(touch) {
|
|
13750
|
-
return hasParent(touch.target, target);
|
|
13751
|
-
});
|
|
13752
|
-
if (type === INPUT_START) {
|
|
13753
|
-
i2 = 0;
|
|
13754
|
-
while (i2 < targetTouches.length) {
|
|
13755
|
-
targetIds[targetTouches[i2].identifier] = true;
|
|
13540
|
+
function simpleCloneInputData(input) {
|
|
13541
|
+
var pointers = [];
|
|
13542
|
+
var i2 = 0;
|
|
13543
|
+
while (i2 < input.pointers.length) {
|
|
13544
|
+
pointers[i2] = {
|
|
13545
|
+
clientX: round2(input.pointers[i2].clientX),
|
|
13546
|
+
clientY: round2(input.pointers[i2].clientY)
|
|
13547
|
+
};
|
|
13756
13548
|
i2++;
|
|
13757
13549
|
}
|
|
13550
|
+
return {
|
|
13551
|
+
timeStamp: now(),
|
|
13552
|
+
pointers,
|
|
13553
|
+
center: getCenter2(pointers),
|
|
13554
|
+
deltaX: input.deltaX,
|
|
13555
|
+
deltaY: input.deltaY
|
|
13556
|
+
};
|
|
13758
13557
|
}
|
|
13759
|
-
|
|
13760
|
-
|
|
13761
|
-
if (
|
|
13762
|
-
|
|
13558
|
+
function getCenter2(pointers) {
|
|
13559
|
+
var pointersLength = pointers.length;
|
|
13560
|
+
if (pointersLength === 1) {
|
|
13561
|
+
return {
|
|
13562
|
+
x: round2(pointers[0].clientX),
|
|
13563
|
+
y: round2(pointers[0].clientY)
|
|
13564
|
+
};
|
|
13763
13565
|
}
|
|
13764
|
-
|
|
13765
|
-
|
|
13566
|
+
var x2 = 0, y2 = 0, i2 = 0;
|
|
13567
|
+
while (i2 < pointersLength) {
|
|
13568
|
+
x2 += pointers[i2].clientX;
|
|
13569
|
+
y2 += pointers[i2].clientY;
|
|
13570
|
+
i2++;
|
|
13766
13571
|
}
|
|
13767
|
-
|
|
13572
|
+
return {
|
|
13573
|
+
x: round2(x2 / pointersLength),
|
|
13574
|
+
y: round2(y2 / pointersLength)
|
|
13575
|
+
};
|
|
13768
13576
|
}
|
|
13769
|
-
|
|
13770
|
-
return
|
|
13577
|
+
function getVelocity(deltaTime, x2, y2) {
|
|
13578
|
+
return {
|
|
13579
|
+
x: x2 / deltaTime || 0,
|
|
13580
|
+
y: y2 / deltaTime || 0
|
|
13581
|
+
};
|
|
13771
13582
|
}
|
|
13772
|
-
|
|
13773
|
-
|
|
13774
|
-
|
|
13775
|
-
changedTargetTouches
|
|
13776
|
-
];
|
|
13777
|
-
}
|
|
13778
|
-
var DEDUP_TIMEOUT = 2500;
|
|
13779
|
-
var DEDUP_DISTANCE = 25;
|
|
13780
|
-
function TouchMouseInput() {
|
|
13781
|
-
Input.apply(this, arguments);
|
|
13782
|
-
var handler = bindFn(this.handler, this);
|
|
13783
|
-
this.touch = new TouchInput(this.manager, handler);
|
|
13784
|
-
this.mouse = new MouseInput(this.manager, handler);
|
|
13785
|
-
this.primaryTouch = null;
|
|
13786
|
-
this.lastTouches = [];
|
|
13787
|
-
}
|
|
13788
|
-
inherit(TouchMouseInput, Input, {
|
|
13789
|
-
/**
|
|
13790
|
-
* handle mouse and touch events
|
|
13791
|
-
* @param {Hammer} manager
|
|
13792
|
-
* @param {String} inputEvent
|
|
13793
|
-
* @param {Object} inputData
|
|
13794
|
-
*/
|
|
13795
|
-
handler: function TMEhandler(manager, inputEvent, inputData) {
|
|
13796
|
-
var isTouch = inputData.pointerType == INPUT_TYPE_TOUCH, isMouse = inputData.pointerType == INPUT_TYPE_MOUSE;
|
|
13797
|
-
if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
|
|
13798
|
-
return;
|
|
13583
|
+
function getDirection(x2, y2) {
|
|
13584
|
+
if (x2 === y2) {
|
|
13585
|
+
return DIRECTION_NONE;
|
|
13799
13586
|
}
|
|
13800
|
-
if (
|
|
13801
|
-
|
|
13802
|
-
} else if (isMouse && isSyntheticEvent.call(this, inputData)) {
|
|
13803
|
-
return;
|
|
13587
|
+
if (abs(x2) >= abs(y2)) {
|
|
13588
|
+
return x2 < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
|
13804
13589
|
}
|
|
13805
|
-
|
|
13806
|
-
},
|
|
13807
|
-
/**
|
|
13808
|
-
* remove the event listeners
|
|
13809
|
-
*/
|
|
13810
|
-
destroy: function destroy() {
|
|
13811
|
-
this.touch.destroy();
|
|
13812
|
-
this.mouse.destroy();
|
|
13813
|
-
}
|
|
13814
|
-
});
|
|
13815
|
-
function recordTouches(eventType, eventData) {
|
|
13816
|
-
if (eventType & INPUT_START) {
|
|
13817
|
-
this.primaryTouch = eventData.changedPointers[0].identifier;
|
|
13818
|
-
setLastTouch.call(this, eventData);
|
|
13819
|
-
} else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
|
13820
|
-
setLastTouch.call(this, eventData);
|
|
13821
|
-
}
|
|
13822
|
-
}
|
|
13823
|
-
function setLastTouch(eventData) {
|
|
13824
|
-
var touch = eventData.changedPointers[0];
|
|
13825
|
-
if (touch.identifier === this.primaryTouch) {
|
|
13826
|
-
var lastTouch = { x: touch.clientX, y: touch.clientY };
|
|
13827
|
-
this.lastTouches.push(lastTouch);
|
|
13828
|
-
var lts = this.lastTouches;
|
|
13829
|
-
var removeLastTouch = function() {
|
|
13830
|
-
var i2 = lts.indexOf(lastTouch);
|
|
13831
|
-
if (i2 > -1) {
|
|
13832
|
-
lts.splice(i2, 1);
|
|
13833
|
-
}
|
|
13834
|
-
};
|
|
13835
|
-
setTimeout(removeLastTouch, DEDUP_TIMEOUT);
|
|
13590
|
+
return y2 < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
|
13836
13591
|
}
|
|
13837
|
-
|
|
13838
|
-
|
|
13839
|
-
|
|
13840
|
-
for (var i2 = 0; i2 < this.lastTouches.length; i2++) {
|
|
13841
|
-
var t = this.lastTouches[i2];
|
|
13842
|
-
var dx = Math.abs(x2 - t.x), dy = Math.abs(y2 - t.y);
|
|
13843
|
-
if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
|
|
13844
|
-
return true;
|
|
13592
|
+
function getDistance(p1, p2, props) {
|
|
13593
|
+
if (!props) {
|
|
13594
|
+
props = PROPS_XY;
|
|
13845
13595
|
}
|
|
13596
|
+
var x2 = p2[props[0]] - p1[props[0]], y2 = p2[props[1]] - p1[props[1]];
|
|
13597
|
+
return Math.sqrt(x2 * x2 + y2 * y2);
|
|
13846
13598
|
}
|
|
13847
|
-
|
|
13848
|
-
|
|
13849
|
-
|
|
13850
|
-
var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined$1;
|
|
13851
|
-
var TOUCH_ACTION_COMPUTE = "compute";
|
|
13852
|
-
var TOUCH_ACTION_AUTO = "auto";
|
|
13853
|
-
var TOUCH_ACTION_MANIPULATION = "manipulation";
|
|
13854
|
-
var TOUCH_ACTION_NONE = "none";
|
|
13855
|
-
var TOUCH_ACTION_PAN_X = "pan-x";
|
|
13856
|
-
var TOUCH_ACTION_PAN_Y = "pan-y";
|
|
13857
|
-
var TOUCH_ACTION_MAP = getTouchActionProps();
|
|
13858
|
-
function TouchAction(manager, value) {
|
|
13859
|
-
this.manager = manager;
|
|
13860
|
-
this.set(value);
|
|
13861
|
-
}
|
|
13862
|
-
TouchAction.prototype = {
|
|
13863
|
-
/**
|
|
13864
|
-
* set the touchAction value on the element or enable the polyfill
|
|
13865
|
-
* @param {String} value
|
|
13866
|
-
*/
|
|
13867
|
-
set: function(value) {
|
|
13868
|
-
if (value == TOUCH_ACTION_COMPUTE) {
|
|
13869
|
-
value = this.compute();
|
|
13599
|
+
function getAngle(p1, p2, props) {
|
|
13600
|
+
if (!props) {
|
|
13601
|
+
props = PROPS_XY;
|
|
13870
13602
|
}
|
|
13871
|
-
|
|
13872
|
-
|
|
13873
|
-
|
|
13874
|
-
|
|
13875
|
-
|
|
13876
|
-
|
|
13877
|
-
|
|
13878
|
-
|
|
13879
|
-
|
|
13880
|
-
|
|
13881
|
-
|
|
13882
|
-
|
|
13883
|
-
|
|
13884
|
-
|
|
13885
|
-
|
|
13886
|
-
|
|
13887
|
-
|
|
13888
|
-
|
|
13889
|
-
|
|
13890
|
-
|
|
13603
|
+
var x2 = p2[props[0]] - p1[props[0]], y2 = p2[props[1]] - p1[props[1]];
|
|
13604
|
+
return Math.atan2(y2, x2) * 180 / Math.PI;
|
|
13605
|
+
}
|
|
13606
|
+
function getRotation(start, end) {
|
|
13607
|
+
return getAngle(end[1], end[0], PROPS_CLIENT_XY) + getAngle(start[1], start[0], PROPS_CLIENT_XY);
|
|
13608
|
+
}
|
|
13609
|
+
function getScale(start, end) {
|
|
13610
|
+
return getDistance(end[0], end[1], PROPS_CLIENT_XY) / getDistance(start[0], start[1], PROPS_CLIENT_XY);
|
|
13611
|
+
}
|
|
13612
|
+
var MOUSE_INPUT_MAP = {
|
|
13613
|
+
mousedown: INPUT_START,
|
|
13614
|
+
mousemove: INPUT_MOVE,
|
|
13615
|
+
mouseup: INPUT_END
|
|
13616
|
+
};
|
|
13617
|
+
var MOUSE_ELEMENT_EVENTS = "mousedown";
|
|
13618
|
+
var MOUSE_WINDOW_EVENTS = "mousemove mouseup";
|
|
13619
|
+
function MouseInput() {
|
|
13620
|
+
this.evEl = MOUSE_ELEMENT_EVENTS;
|
|
13621
|
+
this.evWin = MOUSE_WINDOW_EVENTS;
|
|
13622
|
+
this.pressed = false;
|
|
13623
|
+
Input.apply(this, arguments);
|
|
13624
|
+
}
|
|
13625
|
+
inherit(MouseInput, Input, {
|
|
13626
|
+
/**
|
|
13627
|
+
* handle mouse events
|
|
13628
|
+
* @param {Object} ev
|
|
13629
|
+
*/
|
|
13630
|
+
handler: function MEhandler(ev) {
|
|
13631
|
+
var eventType = MOUSE_INPUT_MAP[ev.type];
|
|
13632
|
+
if (eventType & INPUT_START && ev.button === 0) {
|
|
13633
|
+
this.pressed = true;
|
|
13891
13634
|
}
|
|
13892
|
-
|
|
13893
|
-
|
|
13894
|
-
|
|
13895
|
-
|
|
13896
|
-
|
|
13897
|
-
|
|
13898
|
-
|
|
13899
|
-
|
|
13900
|
-
|
|
13901
|
-
|
|
13902
|
-
|
|
13903
|
-
|
|
13904
|
-
|
|
13635
|
+
if (eventType & INPUT_MOVE && ev.which !== 1) {
|
|
13636
|
+
eventType = INPUT_END;
|
|
13637
|
+
}
|
|
13638
|
+
if (!this.pressed) {
|
|
13639
|
+
return;
|
|
13640
|
+
}
|
|
13641
|
+
if (eventType & INPUT_END) {
|
|
13642
|
+
this.pressed = false;
|
|
13643
|
+
}
|
|
13644
|
+
this.callback(this.manager, eventType, {
|
|
13645
|
+
pointers: [ev],
|
|
13646
|
+
changedPointers: [ev],
|
|
13647
|
+
pointerType: INPUT_TYPE_MOUSE,
|
|
13648
|
+
srcEvent: ev
|
|
13649
|
+
});
|
|
13905
13650
|
}
|
|
13906
|
-
|
|
13907
|
-
|
|
13908
|
-
|
|
13909
|
-
|
|
13910
|
-
|
|
13911
|
-
|
|
13912
|
-
|
|
13913
|
-
|
|
13914
|
-
|
|
13651
|
+
});
|
|
13652
|
+
var POINTER_INPUT_MAP = {
|
|
13653
|
+
pointerdown: INPUT_START,
|
|
13654
|
+
pointermove: INPUT_MOVE,
|
|
13655
|
+
pointerup: INPUT_END,
|
|
13656
|
+
pointercancel: INPUT_CANCEL,
|
|
13657
|
+
pointerout: INPUT_CANCEL
|
|
13658
|
+
};
|
|
13659
|
+
var IE10_POINTER_TYPE_ENUM = {
|
|
13660
|
+
2: INPUT_TYPE_TOUCH,
|
|
13661
|
+
3: INPUT_TYPE_PEN,
|
|
13662
|
+
4: INPUT_TYPE_MOUSE,
|
|
13663
|
+
5: INPUT_TYPE_KINECT
|
|
13664
|
+
// see https://twitter.com/jacobrossi/status/480596438489890816
|
|
13665
|
+
};
|
|
13666
|
+
var POINTER_ELEMENT_EVENTS = "pointerdown";
|
|
13667
|
+
var POINTER_WINDOW_EVENTS = "pointermove pointerup pointercancel";
|
|
13668
|
+
if (window2.MSPointerEvent && !window2.PointerEvent) {
|
|
13669
|
+
POINTER_ELEMENT_EVENTS = "MSPointerDown";
|
|
13670
|
+
POINTER_WINDOW_EVENTS = "MSPointerMove MSPointerUp MSPointerCancel";
|
|
13671
|
+
}
|
|
13672
|
+
function PointerEventInput() {
|
|
13673
|
+
this.evEl = POINTER_ELEMENT_EVENTS;
|
|
13674
|
+
this.evWin = POINTER_WINDOW_EVENTS;
|
|
13675
|
+
Input.apply(this, arguments);
|
|
13676
|
+
this.store = this.manager.session.pointerEvents = [];
|
|
13677
|
+
}
|
|
13678
|
+
inherit(PointerEventInput, Input, {
|
|
13679
|
+
/**
|
|
13680
|
+
* handle mouse events
|
|
13681
|
+
* @param {Object} ev
|
|
13682
|
+
*/
|
|
13683
|
+
handler: function PEhandler(ev) {
|
|
13684
|
+
var store = this.store;
|
|
13685
|
+
var removePointer = false;
|
|
13686
|
+
var eventTypeNormalized = ev.type.toLowerCase().replace("ms", "");
|
|
13687
|
+
var eventType = POINTER_INPUT_MAP[eventTypeNormalized];
|
|
13688
|
+
var pointerType = IE10_POINTER_TYPE_ENUM[ev.pointerType] || ev.pointerType;
|
|
13689
|
+
var isTouch = pointerType == INPUT_TYPE_TOUCH;
|
|
13690
|
+
var storeIndex = inArray(store, ev.pointerId, "pointerId");
|
|
13691
|
+
if (eventType & INPUT_START && (ev.button === 0 || isTouch)) {
|
|
13692
|
+
if (storeIndex < 0) {
|
|
13693
|
+
store.push(ev);
|
|
13694
|
+
storeIndex = store.length - 1;
|
|
13695
|
+
}
|
|
13696
|
+
} else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
|
13697
|
+
removePointer = true;
|
|
13698
|
+
}
|
|
13699
|
+
if (storeIndex < 0) {
|
|
13915
13700
|
return;
|
|
13916
13701
|
}
|
|
13702
|
+
store[storeIndex] = ev;
|
|
13703
|
+
this.callback(this.manager, eventType, {
|
|
13704
|
+
pointers: store,
|
|
13705
|
+
changedPointers: [ev],
|
|
13706
|
+
pointerType,
|
|
13707
|
+
srcEvent: ev
|
|
13708
|
+
});
|
|
13709
|
+
if (removePointer) {
|
|
13710
|
+
store.splice(storeIndex, 1);
|
|
13711
|
+
}
|
|
13917
13712
|
}
|
|
13918
|
-
|
|
13919
|
-
|
|
13713
|
+
});
|
|
13714
|
+
var SINGLE_TOUCH_INPUT_MAP = {
|
|
13715
|
+
touchstart: INPUT_START,
|
|
13716
|
+
touchmove: INPUT_MOVE,
|
|
13717
|
+
touchend: INPUT_END,
|
|
13718
|
+
touchcancel: INPUT_CANCEL
|
|
13719
|
+
};
|
|
13720
|
+
var SINGLE_TOUCH_TARGET_EVENTS = "touchstart";
|
|
13721
|
+
var SINGLE_TOUCH_WINDOW_EVENTS = "touchstart touchmove touchend touchcancel";
|
|
13722
|
+
function SingleTouchInput() {
|
|
13723
|
+
this.evTarget = SINGLE_TOUCH_TARGET_EVENTS;
|
|
13724
|
+
this.evWin = SINGLE_TOUCH_WINDOW_EVENTS;
|
|
13725
|
+
this.started = false;
|
|
13726
|
+
Input.apply(this, arguments);
|
|
13727
|
+
}
|
|
13728
|
+
inherit(SingleTouchInput, Input, {
|
|
13729
|
+
handler: function TEhandler(ev) {
|
|
13730
|
+
var type = SINGLE_TOUCH_INPUT_MAP[ev.type];
|
|
13731
|
+
if (type === INPUT_START) {
|
|
13732
|
+
this.started = true;
|
|
13733
|
+
}
|
|
13734
|
+
if (!this.started) {
|
|
13735
|
+
return;
|
|
13736
|
+
}
|
|
13737
|
+
var touches = normalizeSingleTouches.call(this, ev, type);
|
|
13738
|
+
if (type & (INPUT_END | INPUT_CANCEL) && touches[0].length - touches[1].length === 0) {
|
|
13739
|
+
this.started = false;
|
|
13740
|
+
}
|
|
13741
|
+
this.callback(this.manager, type, {
|
|
13742
|
+
pointers: touches[0],
|
|
13743
|
+
changedPointers: touches[1],
|
|
13744
|
+
pointerType: INPUT_TYPE_TOUCH,
|
|
13745
|
+
srcEvent: ev
|
|
13746
|
+
});
|
|
13920
13747
|
}
|
|
13921
|
-
|
|
13922
|
-
|
|
13748
|
+
});
|
|
13749
|
+
function normalizeSingleTouches(ev, type) {
|
|
13750
|
+
var all = toArray2(ev.touches);
|
|
13751
|
+
var changed = toArray2(ev.changedTouches);
|
|
13752
|
+
if (type & (INPUT_END | INPUT_CANCEL)) {
|
|
13753
|
+
all = uniqueArray(all.concat(changed), "identifier");
|
|
13923
13754
|
}
|
|
13924
|
-
|
|
13925
|
-
/**
|
|
13926
|
-
* call preventDefault to prevent the browser's default behavior (scrolling in most cases)
|
|
13927
|
-
* @param {Object} srcEvent
|
|
13928
|
-
*/
|
|
13929
|
-
preventSrc: function(srcEvent) {
|
|
13930
|
-
this.manager.session.prevented = true;
|
|
13931
|
-
srcEvent.preventDefault();
|
|
13932
|
-
}
|
|
13933
|
-
};
|
|
13934
|
-
function cleanTouchActions(actions2) {
|
|
13935
|
-
if (inStr(actions2, TOUCH_ACTION_NONE)) {
|
|
13936
|
-
return TOUCH_ACTION_NONE;
|
|
13937
|
-
}
|
|
13938
|
-
var hasPanX = inStr(actions2, TOUCH_ACTION_PAN_X);
|
|
13939
|
-
var hasPanY = inStr(actions2, TOUCH_ACTION_PAN_Y);
|
|
13940
|
-
if (hasPanX && hasPanY) {
|
|
13941
|
-
return TOUCH_ACTION_NONE;
|
|
13942
|
-
}
|
|
13943
|
-
if (hasPanX || hasPanY) {
|
|
13944
|
-
return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
|
|
13945
|
-
}
|
|
13946
|
-
if (inStr(actions2, TOUCH_ACTION_MANIPULATION)) {
|
|
13947
|
-
return TOUCH_ACTION_MANIPULATION;
|
|
13755
|
+
return [all, changed];
|
|
13948
13756
|
}
|
|
13949
|
-
|
|
13950
|
-
|
|
13951
|
-
|
|
13952
|
-
|
|
13953
|
-
|
|
13954
|
-
}
|
|
13955
|
-
var
|
|
13956
|
-
|
|
13957
|
-
|
|
13958
|
-
|
|
13757
|
+
var TOUCH_INPUT_MAP = {
|
|
13758
|
+
touchstart: INPUT_START,
|
|
13759
|
+
touchmove: INPUT_MOVE,
|
|
13760
|
+
touchend: INPUT_END,
|
|
13761
|
+
touchcancel: INPUT_CANCEL
|
|
13762
|
+
};
|
|
13763
|
+
var TOUCH_TARGET_EVENTS = "touchstart touchmove touchend touchcancel";
|
|
13764
|
+
function TouchInput() {
|
|
13765
|
+
this.evTarget = TOUCH_TARGET_EVENTS;
|
|
13766
|
+
this.targetIds = {};
|
|
13767
|
+
Input.apply(this, arguments);
|
|
13768
|
+
}
|
|
13769
|
+
inherit(TouchInput, Input, {
|
|
13770
|
+
handler: function MTEhandler(ev) {
|
|
13771
|
+
var type = TOUCH_INPUT_MAP[ev.type];
|
|
13772
|
+
var touches = getTouches.call(this, ev, type);
|
|
13773
|
+
if (!touches) {
|
|
13774
|
+
return;
|
|
13775
|
+
}
|
|
13776
|
+
this.callback(this.manager, type, {
|
|
13777
|
+
pointers: touches[0],
|
|
13778
|
+
changedPointers: touches[1],
|
|
13779
|
+
pointerType: INPUT_TYPE_TOUCH,
|
|
13780
|
+
srcEvent: ev
|
|
13781
|
+
});
|
|
13782
|
+
}
|
|
13959
13783
|
});
|
|
13960
|
-
|
|
13961
|
-
|
|
13962
|
-
|
|
13963
|
-
|
|
13964
|
-
|
|
13965
|
-
|
|
13966
|
-
var STATE_RECOGNIZED = STATE_ENDED;
|
|
13967
|
-
var STATE_CANCELLED = 16;
|
|
13968
|
-
var STATE_FAILED = 32;
|
|
13969
|
-
function Recognizer(options) {
|
|
13970
|
-
this.options = assign({}, this.defaults, options || {});
|
|
13971
|
-
this.id = uniqueId();
|
|
13972
|
-
this.manager = null;
|
|
13973
|
-
this.options.enable = ifUndefined(this.options.enable, true);
|
|
13974
|
-
this.state = STATE_POSSIBLE;
|
|
13975
|
-
this.simultaneous = {};
|
|
13976
|
-
this.requireFail = [];
|
|
13977
|
-
}
|
|
13978
|
-
Recognizer.prototype = {
|
|
13979
|
-
/**
|
|
13980
|
-
* @virtual
|
|
13981
|
-
* @type {Object}
|
|
13982
|
-
*/
|
|
13983
|
-
defaults: {},
|
|
13984
|
-
/**
|
|
13985
|
-
* set options
|
|
13986
|
-
* @param {Object} options
|
|
13987
|
-
* @return {Recognizer}
|
|
13988
|
-
*/
|
|
13989
|
-
set: function(options) {
|
|
13990
|
-
assign(this.options, options);
|
|
13991
|
-
this.manager && this.manager.touchAction.update();
|
|
13992
|
-
return this;
|
|
13993
|
-
},
|
|
13994
|
-
/**
|
|
13995
|
-
* recognize simultaneous with an other recognizer.
|
|
13996
|
-
* @param {Recognizer} otherRecognizer
|
|
13997
|
-
* @returns {Recognizer} this
|
|
13998
|
-
*/
|
|
13999
|
-
recognizeWith: function(otherRecognizer) {
|
|
14000
|
-
if (invokeArrayArg(otherRecognizer, "recognizeWith", this)) {
|
|
14001
|
-
return this;
|
|
13784
|
+
function getTouches(ev, type) {
|
|
13785
|
+
var allTouches = toArray2(ev.touches);
|
|
13786
|
+
var targetIds = this.targetIds;
|
|
13787
|
+
if (type & (INPUT_START | INPUT_MOVE) && allTouches.length === 1) {
|
|
13788
|
+
targetIds[allTouches[0].identifier] = true;
|
|
13789
|
+
return [allTouches, allTouches];
|
|
14002
13790
|
}
|
|
14003
|
-
var
|
|
14004
|
-
|
|
14005
|
-
|
|
14006
|
-
|
|
14007
|
-
|
|
13791
|
+
var i2, targetTouches, changedTouches = toArray2(ev.changedTouches), changedTargetTouches = [], target = this.target;
|
|
13792
|
+
targetTouches = allTouches.filter(function(touch) {
|
|
13793
|
+
return hasParent(touch.target, target);
|
|
13794
|
+
});
|
|
13795
|
+
if (type === INPUT_START) {
|
|
13796
|
+
i2 = 0;
|
|
13797
|
+
while (i2 < targetTouches.length) {
|
|
13798
|
+
targetIds[targetTouches[i2].identifier] = true;
|
|
13799
|
+
i2++;
|
|
13800
|
+
}
|
|
14008
13801
|
}
|
|
14009
|
-
|
|
14010
|
-
|
|
14011
|
-
|
|
14012
|
-
|
|
14013
|
-
|
|
14014
|
-
|
|
14015
|
-
|
|
14016
|
-
|
|
14017
|
-
|
|
14018
|
-
return this;
|
|
13802
|
+
i2 = 0;
|
|
13803
|
+
while (i2 < changedTouches.length) {
|
|
13804
|
+
if (targetIds[changedTouches[i2].identifier]) {
|
|
13805
|
+
changedTargetTouches.push(changedTouches[i2]);
|
|
13806
|
+
}
|
|
13807
|
+
if (type & (INPUT_END | INPUT_CANCEL)) {
|
|
13808
|
+
delete targetIds[changedTouches[i2].identifier];
|
|
13809
|
+
}
|
|
13810
|
+
i2++;
|
|
14019
13811
|
}
|
|
14020
|
-
|
|
14021
|
-
|
|
14022
|
-
return this;
|
|
14023
|
-
},
|
|
14024
|
-
/**
|
|
14025
|
-
* recognizer can only run when an other is failing
|
|
14026
|
-
* @param {Recognizer} otherRecognizer
|
|
14027
|
-
* @returns {Recognizer} this
|
|
14028
|
-
*/
|
|
14029
|
-
requireFailure: function(otherRecognizer) {
|
|
14030
|
-
if (invokeArrayArg(otherRecognizer, "requireFailure", this)) {
|
|
14031
|
-
return this;
|
|
13812
|
+
if (!changedTargetTouches.length) {
|
|
13813
|
+
return;
|
|
14032
13814
|
}
|
|
14033
|
-
|
|
14034
|
-
|
|
14035
|
-
|
|
14036
|
-
|
|
14037
|
-
|
|
13815
|
+
return [
|
|
13816
|
+
// merge targetTouches with changedTargetTouches so it contains ALL touches, including 'end' and 'cancel'
|
|
13817
|
+
uniqueArray(targetTouches.concat(changedTargetTouches), "identifier"),
|
|
13818
|
+
changedTargetTouches
|
|
13819
|
+
];
|
|
13820
|
+
}
|
|
13821
|
+
var DEDUP_TIMEOUT = 2500;
|
|
13822
|
+
var DEDUP_DISTANCE = 25;
|
|
13823
|
+
function TouchMouseInput() {
|
|
13824
|
+
Input.apply(this, arguments);
|
|
13825
|
+
var handler = bindFn(this.handler, this);
|
|
13826
|
+
this.touch = new TouchInput(this.manager, handler);
|
|
13827
|
+
this.mouse = new MouseInput(this.manager, handler);
|
|
13828
|
+
this.primaryTouch = null;
|
|
13829
|
+
this.lastTouches = [];
|
|
13830
|
+
}
|
|
13831
|
+
inherit(TouchMouseInput, Input, {
|
|
13832
|
+
/**
|
|
13833
|
+
* handle mouse and touch events
|
|
13834
|
+
* @param {Hammer} manager
|
|
13835
|
+
* @param {String} inputEvent
|
|
13836
|
+
* @param {Object} inputData
|
|
13837
|
+
*/
|
|
13838
|
+
handler: function TMEhandler(manager, inputEvent, inputData) {
|
|
13839
|
+
var isTouch = inputData.pointerType == INPUT_TYPE_TOUCH, isMouse = inputData.pointerType == INPUT_TYPE_MOUSE;
|
|
13840
|
+
if (isMouse && inputData.sourceCapabilities && inputData.sourceCapabilities.firesTouchEvents) {
|
|
13841
|
+
return;
|
|
13842
|
+
}
|
|
13843
|
+
if (isTouch) {
|
|
13844
|
+
recordTouches.call(this, inputEvent, inputData);
|
|
13845
|
+
} else if (isMouse && isSyntheticEvent.call(this, inputData)) {
|
|
13846
|
+
return;
|
|
13847
|
+
}
|
|
13848
|
+
this.callback(manager, inputEvent, inputData);
|
|
13849
|
+
},
|
|
13850
|
+
/**
|
|
13851
|
+
* remove the event listeners
|
|
13852
|
+
*/
|
|
13853
|
+
destroy: function destroy() {
|
|
13854
|
+
this.touch.destroy();
|
|
13855
|
+
this.mouse.destroy();
|
|
14038
13856
|
}
|
|
14039
|
-
|
|
14040
|
-
|
|
14041
|
-
|
|
14042
|
-
|
|
14043
|
-
|
|
14044
|
-
|
|
14045
|
-
|
|
14046
|
-
dropRequireFailure: function(otherRecognizer) {
|
|
14047
|
-
if (invokeArrayArg(otherRecognizer, "dropRequireFailure", this)) {
|
|
14048
|
-
return this;
|
|
13857
|
+
});
|
|
13858
|
+
function recordTouches(eventType, eventData) {
|
|
13859
|
+
if (eventType & INPUT_START) {
|
|
13860
|
+
this.primaryTouch = eventData.changedPointers[0].identifier;
|
|
13861
|
+
setLastTouch.call(this, eventData);
|
|
13862
|
+
} else if (eventType & (INPUT_END | INPUT_CANCEL)) {
|
|
13863
|
+
setLastTouch.call(this, eventData);
|
|
14049
13864
|
}
|
|
14050
|
-
|
|
14051
|
-
|
|
14052
|
-
|
|
14053
|
-
|
|
13865
|
+
}
|
|
13866
|
+
function setLastTouch(eventData) {
|
|
13867
|
+
var touch = eventData.changedPointers[0];
|
|
13868
|
+
if (touch.identifier === this.primaryTouch) {
|
|
13869
|
+
var lastTouch = { x: touch.clientX, y: touch.clientY };
|
|
13870
|
+
this.lastTouches.push(lastTouch);
|
|
13871
|
+
var lts = this.lastTouches;
|
|
13872
|
+
var removeLastTouch = function() {
|
|
13873
|
+
var i2 = lts.indexOf(lastTouch);
|
|
13874
|
+
if (i2 > -1) {
|
|
13875
|
+
lts.splice(i2, 1);
|
|
13876
|
+
}
|
|
13877
|
+
};
|
|
13878
|
+
setTimeout(removeLastTouch, DEDUP_TIMEOUT);
|
|
14054
13879
|
}
|
|
14055
|
-
|
|
14056
|
-
|
|
14057
|
-
|
|
14058
|
-
|
|
14059
|
-
|
|
14060
|
-
|
|
14061
|
-
|
|
14062
|
-
|
|
14063
|
-
|
|
14064
|
-
|
|
14065
|
-
|
|
14066
|
-
|
|
14067
|
-
|
|
14068
|
-
|
|
14069
|
-
|
|
14070
|
-
|
|
14071
|
-
|
|
14072
|
-
|
|
14073
|
-
|
|
14074
|
-
|
|
14075
|
-
|
|
14076
|
-
|
|
14077
|
-
|
|
14078
|
-
|
|
14079
|
-
|
|
14080
|
-
|
|
14081
|
-
|
|
13880
|
+
}
|
|
13881
|
+
function isSyntheticEvent(eventData) {
|
|
13882
|
+
var x2 = eventData.srcEvent.clientX, y2 = eventData.srcEvent.clientY;
|
|
13883
|
+
for (var i2 = 0; i2 < this.lastTouches.length; i2++) {
|
|
13884
|
+
var t = this.lastTouches[i2];
|
|
13885
|
+
var dx = Math.abs(x2 - t.x), dy = Math.abs(y2 - t.y);
|
|
13886
|
+
if (dx <= DEDUP_DISTANCE && dy <= DEDUP_DISTANCE) {
|
|
13887
|
+
return true;
|
|
13888
|
+
}
|
|
13889
|
+
}
|
|
13890
|
+
return false;
|
|
13891
|
+
}
|
|
13892
|
+
var PREFIXED_TOUCH_ACTION = prefixed(TEST_ELEMENT.style, "touchAction");
|
|
13893
|
+
var NATIVE_TOUCH_ACTION = PREFIXED_TOUCH_ACTION !== undefined$1;
|
|
13894
|
+
var TOUCH_ACTION_COMPUTE = "compute";
|
|
13895
|
+
var TOUCH_ACTION_AUTO = "auto";
|
|
13896
|
+
var TOUCH_ACTION_MANIPULATION = "manipulation";
|
|
13897
|
+
var TOUCH_ACTION_NONE = "none";
|
|
13898
|
+
var TOUCH_ACTION_PAN_X = "pan-x";
|
|
13899
|
+
var TOUCH_ACTION_PAN_Y = "pan-y";
|
|
13900
|
+
var TOUCH_ACTION_MAP = getTouchActionProps();
|
|
13901
|
+
function TouchAction(manager, value) {
|
|
13902
|
+
this.manager = manager;
|
|
13903
|
+
this.set(value);
|
|
13904
|
+
}
|
|
13905
|
+
TouchAction.prototype = {
|
|
13906
|
+
/**
|
|
13907
|
+
* set the touchAction value on the element or enable the polyfill
|
|
13908
|
+
* @param {String} value
|
|
13909
|
+
*/
|
|
13910
|
+
set: function(value) {
|
|
13911
|
+
if (value == TOUCH_ACTION_COMPUTE) {
|
|
13912
|
+
value = this.compute();
|
|
13913
|
+
}
|
|
13914
|
+
if (NATIVE_TOUCH_ACTION && this.manager.element.style && TOUCH_ACTION_MAP[value]) {
|
|
13915
|
+
this.manager.element.style[PREFIXED_TOUCH_ACTION] = value;
|
|
13916
|
+
}
|
|
13917
|
+
this.actions = value.toLowerCase().trim();
|
|
13918
|
+
},
|
|
13919
|
+
/**
|
|
13920
|
+
* just re-set the touchAction value
|
|
13921
|
+
*/
|
|
13922
|
+
update: function() {
|
|
13923
|
+
this.set(this.manager.options.touchAction);
|
|
13924
|
+
},
|
|
13925
|
+
/**
|
|
13926
|
+
* compute the value for the touchAction property based on the recognizer's settings
|
|
13927
|
+
* @returns {String} value
|
|
13928
|
+
*/
|
|
13929
|
+
compute: function() {
|
|
13930
|
+
var actions2 = [];
|
|
13931
|
+
each2(this.manager.recognizers, function(recognizer) {
|
|
13932
|
+
if (boolOrFn(recognizer.options.enable, [recognizer])) {
|
|
13933
|
+
actions2 = actions2.concat(recognizer.getTouchAction());
|
|
13934
|
+
}
|
|
13935
|
+
});
|
|
13936
|
+
return cleanTouchActions(actions2.join(" "));
|
|
13937
|
+
},
|
|
13938
|
+
/**
|
|
13939
|
+
* this method is called on each input cycle and provides the preventing of the browser behavior
|
|
13940
|
+
* @param {Object} input
|
|
13941
|
+
*/
|
|
13942
|
+
preventDefaults: function(input) {
|
|
13943
|
+
var srcEvent = input.srcEvent;
|
|
13944
|
+
var direction = input.offsetDirection;
|
|
13945
|
+
if (this.manager.session.prevented) {
|
|
13946
|
+
srcEvent.preventDefault();
|
|
13947
|
+
return;
|
|
13948
|
+
}
|
|
13949
|
+
var actions2 = this.actions;
|
|
13950
|
+
var hasNone = inStr(actions2, TOUCH_ACTION_NONE) && !TOUCH_ACTION_MAP[TOUCH_ACTION_NONE];
|
|
13951
|
+
var hasPanY = inStr(actions2, TOUCH_ACTION_PAN_Y) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_Y];
|
|
13952
|
+
var hasPanX = inStr(actions2, TOUCH_ACTION_PAN_X) && !TOUCH_ACTION_MAP[TOUCH_ACTION_PAN_X];
|
|
13953
|
+
if (hasNone) {
|
|
13954
|
+
var isTapPointer = input.pointers.length === 1;
|
|
13955
|
+
var isTapMovement = input.distance < 2;
|
|
13956
|
+
var isTapTouchTime = input.deltaTime < 250;
|
|
13957
|
+
if (isTapPointer && isTapMovement && isTapTouchTime) {
|
|
13958
|
+
return;
|
|
13959
|
+
}
|
|
13960
|
+
}
|
|
13961
|
+
if (hasPanX && hasPanY) {
|
|
13962
|
+
return;
|
|
13963
|
+
}
|
|
13964
|
+
if (hasNone || hasPanY && direction & DIRECTION_HORIZONTAL || hasPanX && direction & DIRECTION_VERTICAL) {
|
|
13965
|
+
return this.preventSrc(srcEvent);
|
|
13966
|
+
}
|
|
13967
|
+
},
|
|
13968
|
+
/**
|
|
13969
|
+
* call preventDefault to prevent the browser's default behavior (scrolling in most cases)
|
|
13970
|
+
* @param {Object} srcEvent
|
|
13971
|
+
*/
|
|
13972
|
+
preventSrc: function(srcEvent) {
|
|
13973
|
+
this.manager.session.prevented = true;
|
|
13974
|
+
srcEvent.preventDefault();
|
|
14082
13975
|
}
|
|
14083
|
-
|
|
14084
|
-
|
|
13976
|
+
};
|
|
13977
|
+
function cleanTouchActions(actions2) {
|
|
13978
|
+
if (inStr(actions2, TOUCH_ACTION_NONE)) {
|
|
13979
|
+
return TOUCH_ACTION_NONE;
|
|
14085
13980
|
}
|
|
14086
|
-
|
|
14087
|
-
|
|
14088
|
-
|
|
13981
|
+
var hasPanX = inStr(actions2, TOUCH_ACTION_PAN_X);
|
|
13982
|
+
var hasPanY = inStr(actions2, TOUCH_ACTION_PAN_Y);
|
|
13983
|
+
if (hasPanX && hasPanY) {
|
|
13984
|
+
return TOUCH_ACTION_NONE;
|
|
14089
13985
|
}
|
|
14090
|
-
if (
|
|
14091
|
-
|
|
13986
|
+
if (hasPanX || hasPanY) {
|
|
13987
|
+
return hasPanX ? TOUCH_ACTION_PAN_X : TOUCH_ACTION_PAN_Y;
|
|
14092
13988
|
}
|
|
14093
|
-
|
|
14094
|
-
|
|
14095
|
-
* Check that all the require failure recognizers has failed,
|
|
14096
|
-
* if true, it emits a gesture event,
|
|
14097
|
-
* otherwise, setup the state to FAILED.
|
|
14098
|
-
* @param {Object} input
|
|
14099
|
-
*/
|
|
14100
|
-
tryEmit: function(input) {
|
|
14101
|
-
if (this.canEmit()) {
|
|
14102
|
-
return this.emit(input);
|
|
13989
|
+
if (inStr(actions2, TOUCH_ACTION_MANIPULATION)) {
|
|
13990
|
+
return TOUCH_ACTION_MANIPULATION;
|
|
14103
13991
|
}
|
|
14104
|
-
|
|
14105
|
-
}
|
|
14106
|
-
|
|
14107
|
-
|
|
14108
|
-
|
|
14109
|
-
*/
|
|
14110
|
-
canEmit: function() {
|
|
14111
|
-
var i2 = 0;
|
|
14112
|
-
while (i2 < this.requireFail.length) {
|
|
14113
|
-
if (!(this.requireFail[i2].state & (STATE_FAILED | STATE_POSSIBLE))) {
|
|
14114
|
-
return false;
|
|
14115
|
-
}
|
|
14116
|
-
i2++;
|
|
13992
|
+
return TOUCH_ACTION_AUTO;
|
|
13993
|
+
}
|
|
13994
|
+
function getTouchActionProps() {
|
|
13995
|
+
if (!NATIVE_TOUCH_ACTION) {
|
|
13996
|
+
return false;
|
|
14117
13997
|
}
|
|
14118
|
-
|
|
14119
|
-
|
|
14120
|
-
|
|
14121
|
-
|
|
14122
|
-
|
|
14123
|
-
|
|
14124
|
-
|
|
14125
|
-
|
|
14126
|
-
|
|
14127
|
-
|
|
13998
|
+
var touchMap = {};
|
|
13999
|
+
var cssSupports = window2.CSS && window2.CSS.supports;
|
|
14000
|
+
["auto", "manipulation", "pan-y", "pan-x", "pan-x pan-y", "none"].forEach(function(val) {
|
|
14001
|
+
touchMap[val] = cssSupports ? window2.CSS.supports("touch-action", val) : true;
|
|
14002
|
+
});
|
|
14003
|
+
return touchMap;
|
|
14004
|
+
}
|
|
14005
|
+
var STATE_POSSIBLE = 1;
|
|
14006
|
+
var STATE_BEGAN = 2;
|
|
14007
|
+
var STATE_CHANGED = 4;
|
|
14008
|
+
var STATE_ENDED = 8;
|
|
14009
|
+
var STATE_RECOGNIZED = STATE_ENDED;
|
|
14010
|
+
var STATE_CANCELLED = 16;
|
|
14011
|
+
var STATE_FAILED = 32;
|
|
14012
|
+
function Recognizer(options) {
|
|
14013
|
+
this.options = assign({}, this.defaults, options || {});
|
|
14014
|
+
this.id = uniqueId();
|
|
14015
|
+
this.manager = null;
|
|
14016
|
+
this.options.enable = ifUndefined(this.options.enable, true);
|
|
14017
|
+
this.state = STATE_POSSIBLE;
|
|
14018
|
+
this.simultaneous = {};
|
|
14019
|
+
this.requireFail = [];
|
|
14020
|
+
}
|
|
14021
|
+
Recognizer.prototype = {
|
|
14022
|
+
/**
|
|
14023
|
+
* @virtual
|
|
14024
|
+
* @type {Object}
|
|
14025
|
+
*/
|
|
14026
|
+
defaults: {},
|
|
14027
|
+
/**
|
|
14028
|
+
* set options
|
|
14029
|
+
* @param {Object} options
|
|
14030
|
+
* @return {Recognizer}
|
|
14031
|
+
*/
|
|
14032
|
+
set: function(options) {
|
|
14033
|
+
assign(this.options, options);
|
|
14034
|
+
this.manager && this.manager.touchAction.update();
|
|
14035
|
+
return this;
|
|
14036
|
+
},
|
|
14037
|
+
/**
|
|
14038
|
+
* recognize simultaneous with an other recognizer.
|
|
14039
|
+
* @param {Recognizer} otherRecognizer
|
|
14040
|
+
* @returns {Recognizer} this
|
|
14041
|
+
*/
|
|
14042
|
+
recognizeWith: function(otherRecognizer) {
|
|
14043
|
+
if (invokeArrayArg(otherRecognizer, "recognizeWith", this)) {
|
|
14044
|
+
return this;
|
|
14045
|
+
}
|
|
14046
|
+
var simultaneous = this.simultaneous;
|
|
14047
|
+
otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
|
14048
|
+
if (!simultaneous[otherRecognizer.id]) {
|
|
14049
|
+
simultaneous[otherRecognizer.id] = otherRecognizer;
|
|
14050
|
+
otherRecognizer.recognizeWith(this);
|
|
14051
|
+
}
|
|
14052
|
+
return this;
|
|
14053
|
+
},
|
|
14054
|
+
/**
|
|
14055
|
+
* drop the simultaneous link. it doesnt remove the link on the other recognizer.
|
|
14056
|
+
* @param {Recognizer} otherRecognizer
|
|
14057
|
+
* @returns {Recognizer} this
|
|
14058
|
+
*/
|
|
14059
|
+
dropRecognizeWith: function(otherRecognizer) {
|
|
14060
|
+
if (invokeArrayArg(otherRecognizer, "dropRecognizeWith", this)) {
|
|
14061
|
+
return this;
|
|
14062
|
+
}
|
|
14063
|
+
otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
|
14064
|
+
delete this.simultaneous[otherRecognizer.id];
|
|
14065
|
+
return this;
|
|
14066
|
+
},
|
|
14067
|
+
/**
|
|
14068
|
+
* recognizer can only run when an other is failing
|
|
14069
|
+
* @param {Recognizer} otherRecognizer
|
|
14070
|
+
* @returns {Recognizer} this
|
|
14071
|
+
*/
|
|
14072
|
+
requireFailure: function(otherRecognizer) {
|
|
14073
|
+
if (invokeArrayArg(otherRecognizer, "requireFailure", this)) {
|
|
14074
|
+
return this;
|
|
14075
|
+
}
|
|
14076
|
+
var requireFail = this.requireFail;
|
|
14077
|
+
otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
|
14078
|
+
if (inArray(requireFail, otherRecognizer) === -1) {
|
|
14079
|
+
requireFail.push(otherRecognizer);
|
|
14080
|
+
otherRecognizer.requireFailure(this);
|
|
14081
|
+
}
|
|
14082
|
+
return this;
|
|
14083
|
+
},
|
|
14084
|
+
/**
|
|
14085
|
+
* drop the requireFailure link. it does not remove the link on the other recognizer.
|
|
14086
|
+
* @param {Recognizer} otherRecognizer
|
|
14087
|
+
* @returns {Recognizer} this
|
|
14088
|
+
*/
|
|
14089
|
+
dropRequireFailure: function(otherRecognizer) {
|
|
14090
|
+
if (invokeArrayArg(otherRecognizer, "dropRequireFailure", this)) {
|
|
14091
|
+
return this;
|
|
14092
|
+
}
|
|
14093
|
+
otherRecognizer = getRecognizerByNameIfManager(otherRecognizer, this);
|
|
14094
|
+
var index2 = inArray(this.requireFail, otherRecognizer);
|
|
14095
|
+
if (index2 > -1) {
|
|
14096
|
+
this.requireFail.splice(index2, 1);
|
|
14097
|
+
}
|
|
14098
|
+
return this;
|
|
14099
|
+
},
|
|
14100
|
+
/**
|
|
14101
|
+
* has require failures boolean
|
|
14102
|
+
* @returns {boolean}
|
|
14103
|
+
*/
|
|
14104
|
+
hasRequireFailures: function() {
|
|
14105
|
+
return this.requireFail.length > 0;
|
|
14106
|
+
},
|
|
14107
|
+
/**
|
|
14108
|
+
* if the recognizer can recognize simultaneous with an other recognizer
|
|
14109
|
+
* @param {Recognizer} otherRecognizer
|
|
14110
|
+
* @returns {Boolean}
|
|
14111
|
+
*/
|
|
14112
|
+
canRecognizeWith: function(otherRecognizer) {
|
|
14113
|
+
return !!this.simultaneous[otherRecognizer.id];
|
|
14114
|
+
},
|
|
14115
|
+
/**
|
|
14116
|
+
* You should use `tryEmit` instead of `emit` directly to check
|
|
14117
|
+
* that all the needed recognizers has failed before emitting.
|
|
14118
|
+
* @param {Object} input
|
|
14119
|
+
*/
|
|
14120
|
+
emit: function(input) {
|
|
14121
|
+
var self2 = this;
|
|
14122
|
+
var state = this.state;
|
|
14123
|
+
function emit(event) {
|
|
14124
|
+
self2.manager.emit(event, input);
|
|
14125
|
+
}
|
|
14126
|
+
if (state < STATE_ENDED) {
|
|
14127
|
+
emit(self2.options.event + stateStr(state));
|
|
14128
|
+
}
|
|
14129
|
+
emit(self2.options.event);
|
|
14130
|
+
if (input.additionalEvent) {
|
|
14131
|
+
emit(input.additionalEvent);
|
|
14132
|
+
}
|
|
14133
|
+
if (state >= STATE_ENDED) {
|
|
14134
|
+
emit(self2.options.event + stateStr(state));
|
|
14135
|
+
}
|
|
14136
|
+
},
|
|
14137
|
+
/**
|
|
14138
|
+
* Check that all the require failure recognizers has failed,
|
|
14139
|
+
* if true, it emits a gesture event,
|
|
14140
|
+
* otherwise, setup the state to FAILED.
|
|
14141
|
+
* @param {Object} input
|
|
14142
|
+
*/
|
|
14143
|
+
tryEmit: function(input) {
|
|
14144
|
+
if (this.canEmit()) {
|
|
14145
|
+
return this.emit(input);
|
|
14146
|
+
}
|
|
14128
14147
|
this.state = STATE_FAILED;
|
|
14129
|
-
|
|
14148
|
+
},
|
|
14149
|
+
/**
|
|
14150
|
+
* can we emit?
|
|
14151
|
+
* @returns {boolean}
|
|
14152
|
+
*/
|
|
14153
|
+
canEmit: function() {
|
|
14154
|
+
var i2 = 0;
|
|
14155
|
+
while (i2 < this.requireFail.length) {
|
|
14156
|
+
if (!(this.requireFail[i2].state & (STATE_FAILED | STATE_POSSIBLE))) {
|
|
14157
|
+
return false;
|
|
14158
|
+
}
|
|
14159
|
+
i2++;
|
|
14160
|
+
}
|
|
14161
|
+
return true;
|
|
14162
|
+
},
|
|
14163
|
+
/**
|
|
14164
|
+
* update the recognizer
|
|
14165
|
+
* @param {Object} inputData
|
|
14166
|
+
*/
|
|
14167
|
+
recognize: function(inputData) {
|
|
14168
|
+
var inputDataClone = assign({}, inputData);
|
|
14169
|
+
if (!boolOrFn(this.options.enable, [this, inputDataClone])) {
|
|
14170
|
+
this.reset();
|
|
14171
|
+
this.state = STATE_FAILED;
|
|
14172
|
+
return;
|
|
14173
|
+
}
|
|
14174
|
+
if (this.state & (STATE_RECOGNIZED | STATE_CANCELLED | STATE_FAILED)) {
|
|
14175
|
+
this.state = STATE_POSSIBLE;
|
|
14176
|
+
}
|
|
14177
|
+
this.state = this.process(inputDataClone);
|
|
14178
|
+
if (this.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED | STATE_CANCELLED)) {
|
|
14179
|
+
this.tryEmit(inputDataClone);
|
|
14180
|
+
}
|
|
14181
|
+
},
|
|
14182
|
+
/**
|
|
14183
|
+
* return the state of the recognizer
|
|
14184
|
+
* the actual recognizing happens in this method
|
|
14185
|
+
* @virtual
|
|
14186
|
+
* @param {Object} inputData
|
|
14187
|
+
* @returns {Const} STATE
|
|
14188
|
+
*/
|
|
14189
|
+
process: function(inputData) {
|
|
14190
|
+
},
|
|
14191
|
+
// jshint ignore:line
|
|
14192
|
+
/**
|
|
14193
|
+
* return the preferred touch-action
|
|
14194
|
+
* @virtual
|
|
14195
|
+
* @returns {Array}
|
|
14196
|
+
*/
|
|
14197
|
+
getTouchAction: function() {
|
|
14198
|
+
},
|
|
14199
|
+
/**
|
|
14200
|
+
* called when the gesture isn't allowed to recognize
|
|
14201
|
+
* like when another is being recognized or it is disabled
|
|
14202
|
+
* @virtual
|
|
14203
|
+
*/
|
|
14204
|
+
reset: function() {
|
|
14130
14205
|
}
|
|
14131
|
-
|
|
14132
|
-
|
|
14206
|
+
};
|
|
14207
|
+
function stateStr(state) {
|
|
14208
|
+
if (state & STATE_CANCELLED) {
|
|
14209
|
+
return "cancel";
|
|
14210
|
+
} else if (state & STATE_ENDED) {
|
|
14211
|
+
return "end";
|
|
14212
|
+
} else if (state & STATE_CHANGED) {
|
|
14213
|
+
return "move";
|
|
14214
|
+
} else if (state & STATE_BEGAN) {
|
|
14215
|
+
return "start";
|
|
14133
14216
|
}
|
|
14134
|
-
|
|
14135
|
-
|
|
14136
|
-
|
|
14217
|
+
return "";
|
|
14218
|
+
}
|
|
14219
|
+
function directionStr(direction) {
|
|
14220
|
+
if (direction == DIRECTION_DOWN) {
|
|
14221
|
+
return "down";
|
|
14222
|
+
} else if (direction == DIRECTION_UP) {
|
|
14223
|
+
return "up";
|
|
14224
|
+
} else if (direction == DIRECTION_LEFT) {
|
|
14225
|
+
return "left";
|
|
14226
|
+
} else if (direction == DIRECTION_RIGHT) {
|
|
14227
|
+
return "right";
|
|
14137
14228
|
}
|
|
14138
|
-
|
|
14139
|
-
/**
|
|
14140
|
-
* return the state of the recognizer
|
|
14141
|
-
* the actual recognizing happens in this method
|
|
14142
|
-
* @virtual
|
|
14143
|
-
* @param {Object} inputData
|
|
14144
|
-
* @returns {Const} STATE
|
|
14145
|
-
*/
|
|
14146
|
-
process: function(inputData) {
|
|
14147
|
-
},
|
|
14148
|
-
// jshint ignore:line
|
|
14149
|
-
/**
|
|
14150
|
-
* return the preferred touch-action
|
|
14151
|
-
* @virtual
|
|
14152
|
-
* @returns {Array}
|
|
14153
|
-
*/
|
|
14154
|
-
getTouchAction: function() {
|
|
14155
|
-
},
|
|
14156
|
-
/**
|
|
14157
|
-
* called when the gesture isn't allowed to recognize
|
|
14158
|
-
* like when another is being recognized or it is disabled
|
|
14159
|
-
* @virtual
|
|
14160
|
-
*/
|
|
14161
|
-
reset: function() {
|
|
14229
|
+
return "";
|
|
14162
14230
|
}
|
|
14163
|
-
|
|
14164
|
-
|
|
14165
|
-
|
|
14166
|
-
|
|
14167
|
-
|
|
14168
|
-
return
|
|
14169
|
-
}
|
|
14170
|
-
|
|
14171
|
-
|
|
14172
|
-
|
|
14173
|
-
|
|
14174
|
-
return "";
|
|
14175
|
-
}
|
|
14176
|
-
function directionStr(direction) {
|
|
14177
|
-
if (direction == DIRECTION_DOWN) {
|
|
14178
|
-
return "down";
|
|
14179
|
-
} else if (direction == DIRECTION_UP) {
|
|
14180
|
-
return "up";
|
|
14181
|
-
} else if (direction == DIRECTION_LEFT) {
|
|
14182
|
-
return "left";
|
|
14183
|
-
} else if (direction == DIRECTION_RIGHT) {
|
|
14184
|
-
return "right";
|
|
14185
|
-
}
|
|
14186
|
-
return "";
|
|
14187
|
-
}
|
|
14188
|
-
function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
|
14189
|
-
var manager = recognizer.manager;
|
|
14190
|
-
if (manager) {
|
|
14191
|
-
return manager.get(otherRecognizer);
|
|
14192
|
-
}
|
|
14193
|
-
return otherRecognizer;
|
|
14194
|
-
}
|
|
14195
|
-
function AttrRecognizer() {
|
|
14196
|
-
Recognizer.apply(this, arguments);
|
|
14197
|
-
}
|
|
14198
|
-
inherit(AttrRecognizer, Recognizer, {
|
|
14199
|
-
/**
|
|
14200
|
-
* @namespace
|
|
14201
|
-
* @memberof AttrRecognizer
|
|
14202
|
-
*/
|
|
14203
|
-
defaults: {
|
|
14231
|
+
function getRecognizerByNameIfManager(otherRecognizer, recognizer) {
|
|
14232
|
+
var manager = recognizer.manager;
|
|
14233
|
+
if (manager) {
|
|
14234
|
+
return manager.get(otherRecognizer);
|
|
14235
|
+
}
|
|
14236
|
+
return otherRecognizer;
|
|
14237
|
+
}
|
|
14238
|
+
function AttrRecognizer() {
|
|
14239
|
+
Recognizer.apply(this, arguments);
|
|
14240
|
+
}
|
|
14241
|
+
inherit(AttrRecognizer, Recognizer, {
|
|
14204
14242
|
/**
|
|
14205
|
-
* @
|
|
14206
|
-
* @
|
|
14243
|
+
* @namespace
|
|
14244
|
+
* @memberof AttrRecognizer
|
|
14207
14245
|
*/
|
|
14208
|
-
|
|
14209
|
-
|
|
14210
|
-
|
|
14211
|
-
|
|
14212
|
-
|
|
14213
|
-
|
|
14214
|
-
|
|
14215
|
-
|
|
14216
|
-
|
|
14217
|
-
|
|
14218
|
-
|
|
14219
|
-
|
|
14220
|
-
|
|
14221
|
-
|
|
14222
|
-
|
|
14223
|
-
|
|
14224
|
-
|
|
14225
|
-
|
|
14226
|
-
|
|
14227
|
-
|
|
14228
|
-
|
|
14229
|
-
|
|
14230
|
-
|
|
14231
|
-
|
|
14232
|
-
|
|
14233
|
-
|
|
14234
|
-
|
|
14235
|
-
|
|
14236
|
-
|
|
14237
|
-
return
|
|
14246
|
+
defaults: {
|
|
14247
|
+
/**
|
|
14248
|
+
* @type {Number}
|
|
14249
|
+
* @default 1
|
|
14250
|
+
*/
|
|
14251
|
+
pointers: 1
|
|
14252
|
+
},
|
|
14253
|
+
/**
|
|
14254
|
+
* Used to check if it the recognizer receives valid input, like input.distance > 10.
|
|
14255
|
+
* @memberof AttrRecognizer
|
|
14256
|
+
* @param {Object} input
|
|
14257
|
+
* @returns {Boolean} recognized
|
|
14258
|
+
*/
|
|
14259
|
+
attrTest: function(input) {
|
|
14260
|
+
var optionPointers = this.options.pointers;
|
|
14261
|
+
return optionPointers === 0 || input.pointers.length === optionPointers;
|
|
14262
|
+
},
|
|
14263
|
+
/**
|
|
14264
|
+
* Process the input and return the state for the recognizer
|
|
14265
|
+
* @memberof AttrRecognizer
|
|
14266
|
+
* @param {Object} input
|
|
14267
|
+
* @returns {*} State
|
|
14268
|
+
*/
|
|
14269
|
+
process: function(input) {
|
|
14270
|
+
var state = this.state;
|
|
14271
|
+
var eventType = input.eventType;
|
|
14272
|
+
var isRecognized = state & (STATE_BEGAN | STATE_CHANGED);
|
|
14273
|
+
var isValid = this.attrTest(input);
|
|
14274
|
+
if (isRecognized && (eventType & INPUT_CANCEL || !isValid)) {
|
|
14275
|
+
return state | STATE_CANCELLED;
|
|
14276
|
+
} else if (isRecognized || isValid) {
|
|
14277
|
+
if (eventType & INPUT_END) {
|
|
14278
|
+
return state | STATE_ENDED;
|
|
14279
|
+
} else if (!(state & STATE_BEGAN)) {
|
|
14280
|
+
return STATE_BEGAN;
|
|
14281
|
+
}
|
|
14282
|
+
return state | STATE_CHANGED;
|
|
14238
14283
|
}
|
|
14239
|
-
return
|
|
14284
|
+
return STATE_FAILED;
|
|
14240
14285
|
}
|
|
14241
|
-
|
|
14286
|
+
});
|
|
14287
|
+
function PanRecognizer() {
|
|
14288
|
+
AttrRecognizer.apply(this, arguments);
|
|
14289
|
+
this.pX = null;
|
|
14290
|
+
this.pY = null;
|
|
14242
14291
|
}
|
|
14243
|
-
|
|
14244
|
-
|
|
14245
|
-
|
|
14246
|
-
|
|
14247
|
-
|
|
14248
|
-
|
|
14249
|
-
|
|
14250
|
-
|
|
14251
|
-
|
|
14252
|
-
|
|
14253
|
-
|
|
14254
|
-
|
|
14255
|
-
|
|
14256
|
-
|
|
14257
|
-
|
|
14258
|
-
|
|
14259
|
-
},
|
|
14260
|
-
getTouchAction: function() {
|
|
14261
|
-
var direction = this.options.direction;
|
|
14262
|
-
var actions2 = [];
|
|
14263
|
-
if (direction & DIRECTION_HORIZONTAL) {
|
|
14264
|
-
actions2.push(TOUCH_ACTION_PAN_Y);
|
|
14265
|
-
}
|
|
14266
|
-
if (direction & DIRECTION_VERTICAL) {
|
|
14267
|
-
actions2.push(TOUCH_ACTION_PAN_X);
|
|
14268
|
-
}
|
|
14269
|
-
return actions2;
|
|
14270
|
-
},
|
|
14271
|
-
directionTest: function(input) {
|
|
14272
|
-
var options = this.options;
|
|
14273
|
-
var hasMoved = true;
|
|
14274
|
-
var distance = input.distance;
|
|
14275
|
-
var direction = input.direction;
|
|
14276
|
-
var x2 = input.deltaX;
|
|
14277
|
-
var y2 = input.deltaY;
|
|
14278
|
-
if (!(direction & options.direction)) {
|
|
14279
|
-
if (options.direction & DIRECTION_HORIZONTAL) {
|
|
14280
|
-
direction = x2 === 0 ? DIRECTION_NONE : x2 < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
|
14281
|
-
hasMoved = x2 != this.pX;
|
|
14282
|
-
distance = Math.abs(input.deltaX);
|
|
14283
|
-
} else {
|
|
14284
|
-
direction = y2 === 0 ? DIRECTION_NONE : y2 < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
|
14285
|
-
hasMoved = y2 != this.pY;
|
|
14286
|
-
distance = Math.abs(input.deltaY);
|
|
14292
|
+
inherit(PanRecognizer, AttrRecognizer, {
|
|
14293
|
+
/**
|
|
14294
|
+
* @namespace
|
|
14295
|
+
* @memberof PanRecognizer
|
|
14296
|
+
*/
|
|
14297
|
+
defaults: {
|
|
14298
|
+
event: "pan",
|
|
14299
|
+
threshold: 10,
|
|
14300
|
+
pointers: 1,
|
|
14301
|
+
direction: DIRECTION_ALL
|
|
14302
|
+
},
|
|
14303
|
+
getTouchAction: function() {
|
|
14304
|
+
var direction = this.options.direction;
|
|
14305
|
+
var actions2 = [];
|
|
14306
|
+
if (direction & DIRECTION_HORIZONTAL) {
|
|
14307
|
+
actions2.push(TOUCH_ACTION_PAN_Y);
|
|
14287
14308
|
}
|
|
14309
|
+
if (direction & DIRECTION_VERTICAL) {
|
|
14310
|
+
actions2.push(TOUCH_ACTION_PAN_X);
|
|
14311
|
+
}
|
|
14312
|
+
return actions2;
|
|
14313
|
+
},
|
|
14314
|
+
directionTest: function(input) {
|
|
14315
|
+
var options = this.options;
|
|
14316
|
+
var hasMoved = true;
|
|
14317
|
+
var distance = input.distance;
|
|
14318
|
+
var direction = input.direction;
|
|
14319
|
+
var x2 = input.deltaX;
|
|
14320
|
+
var y2 = input.deltaY;
|
|
14321
|
+
if (!(direction & options.direction)) {
|
|
14322
|
+
if (options.direction & DIRECTION_HORIZONTAL) {
|
|
14323
|
+
direction = x2 === 0 ? DIRECTION_NONE : x2 < 0 ? DIRECTION_LEFT : DIRECTION_RIGHT;
|
|
14324
|
+
hasMoved = x2 != this.pX;
|
|
14325
|
+
distance = Math.abs(input.deltaX);
|
|
14326
|
+
} else {
|
|
14327
|
+
direction = y2 === 0 ? DIRECTION_NONE : y2 < 0 ? DIRECTION_UP : DIRECTION_DOWN;
|
|
14328
|
+
hasMoved = y2 != this.pY;
|
|
14329
|
+
distance = Math.abs(input.deltaY);
|
|
14330
|
+
}
|
|
14331
|
+
}
|
|
14332
|
+
input.direction = direction;
|
|
14333
|
+
return hasMoved && distance > options.threshold && direction & options.direction;
|
|
14334
|
+
},
|
|
14335
|
+
attrTest: function(input) {
|
|
14336
|
+
return AttrRecognizer.prototype.attrTest.call(this, input) && (this.state & STATE_BEGAN || !(this.state & STATE_BEGAN) && this.directionTest(input));
|
|
14337
|
+
},
|
|
14338
|
+
emit: function(input) {
|
|
14339
|
+
this.pX = input.deltaX;
|
|
14340
|
+
this.pY = input.deltaY;
|
|
14341
|
+
var direction = directionStr(input.direction);
|
|
14342
|
+
if (direction) {
|
|
14343
|
+
input.additionalEvent = this.options.event + direction;
|
|
14344
|
+
}
|
|
14345
|
+
this._super.emit.call(this, input);
|
|
14288
14346
|
}
|
|
14289
|
-
|
|
14290
|
-
|
|
14291
|
-
|
|
14292
|
-
attrTest: function(input) {
|
|
14293
|
-
return AttrRecognizer.prototype.attrTest.call(this, input) && (this.state & STATE_BEGAN || !(this.state & STATE_BEGAN) && this.directionTest(input));
|
|
14294
|
-
},
|
|
14295
|
-
emit: function(input) {
|
|
14296
|
-
this.pX = input.deltaX;
|
|
14297
|
-
this.pY = input.deltaY;
|
|
14298
|
-
var direction = directionStr(input.direction);
|
|
14299
|
-
if (direction) {
|
|
14300
|
-
input.additionalEvent = this.options.event + direction;
|
|
14301
|
-
}
|
|
14302
|
-
this._super.emit.call(this, input);
|
|
14347
|
+
});
|
|
14348
|
+
function PinchRecognizer() {
|
|
14349
|
+
AttrRecognizer.apply(this, arguments);
|
|
14303
14350
|
}
|
|
14304
|
-
|
|
14305
|
-
|
|
14306
|
-
|
|
14307
|
-
|
|
14308
|
-
|
|
14309
|
-
|
|
14310
|
-
|
|
14311
|
-
|
|
14312
|
-
|
|
14313
|
-
|
|
14314
|
-
|
|
14315
|
-
|
|
14316
|
-
|
|
14317
|
-
|
|
14318
|
-
|
|
14319
|
-
|
|
14320
|
-
|
|
14321
|
-
|
|
14322
|
-
|
|
14323
|
-
|
|
14324
|
-
|
|
14325
|
-
|
|
14326
|
-
var inOut = input.scale < 1 ? "in" : "out";
|
|
14327
|
-
input.additionalEvent = this.options.event + inOut;
|
|
14351
|
+
inherit(PinchRecognizer, AttrRecognizer, {
|
|
14352
|
+
/**
|
|
14353
|
+
* @namespace
|
|
14354
|
+
* @memberof PinchRecognizer
|
|
14355
|
+
*/
|
|
14356
|
+
defaults: {
|
|
14357
|
+
event: "pinch",
|
|
14358
|
+
threshold: 0,
|
|
14359
|
+
pointers: 2
|
|
14360
|
+
},
|
|
14361
|
+
getTouchAction: function() {
|
|
14362
|
+
return [TOUCH_ACTION_NONE];
|
|
14363
|
+
},
|
|
14364
|
+
attrTest: function(input) {
|
|
14365
|
+
return this._super.attrTest.call(this, input) && (Math.abs(input.scale - 1) > this.options.threshold || this.state & STATE_BEGAN);
|
|
14366
|
+
},
|
|
14367
|
+
emit: function(input) {
|
|
14368
|
+
if (input.scale !== 1) {
|
|
14369
|
+
var inOut = input.scale < 1 ? "in" : "out";
|
|
14370
|
+
input.additionalEvent = this.options.event + inOut;
|
|
14371
|
+
}
|
|
14372
|
+
this._super.emit.call(this, input);
|
|
14328
14373
|
}
|
|
14329
|
-
|
|
14374
|
+
});
|
|
14375
|
+
function PressRecognizer() {
|
|
14376
|
+
Recognizer.apply(this, arguments);
|
|
14377
|
+
this._timer = null;
|
|
14378
|
+
this._input = null;
|
|
14330
14379
|
}
|
|
14331
|
-
|
|
14332
|
-
|
|
14333
|
-
|
|
14334
|
-
|
|
14335
|
-
|
|
14336
|
-
|
|
14337
|
-
|
|
14338
|
-
|
|
14339
|
-
|
|
14340
|
-
|
|
14341
|
-
|
|
14342
|
-
|
|
14343
|
-
|
|
14344
|
-
|
|
14345
|
-
|
|
14346
|
-
|
|
14347
|
-
|
|
14348
|
-
|
|
14349
|
-
|
|
14350
|
-
|
|
14351
|
-
|
|
14352
|
-
|
|
14353
|
-
|
|
14354
|
-
|
|
14355
|
-
|
|
14356
|
-
|
|
14357
|
-
|
|
14358
|
-
|
|
14359
|
-
|
|
14360
|
-
|
|
14361
|
-
|
|
14362
|
-
|
|
14363
|
-
|
|
14364
|
-
|
|
14365
|
-
|
|
14366
|
-
|
|
14367
|
-
|
|
14368
|
-
|
|
14369
|
-
|
|
14370
|
-
|
|
14371
|
-
|
|
14372
|
-
|
|
14373
|
-
|
|
14374
|
-
|
|
14375
|
-
|
|
14376
|
-
|
|
14377
|
-
|
|
14378
|
-
|
|
14379
|
-
if (input && input.eventType & INPUT_END) {
|
|
14380
|
-
this.manager.emit(this.options.event + "up", input);
|
|
14381
|
-
} else {
|
|
14382
|
-
this._input.timeStamp = now();
|
|
14383
|
-
this.manager.emit(this.options.event, this._input);
|
|
14380
|
+
inherit(PressRecognizer, Recognizer, {
|
|
14381
|
+
/**
|
|
14382
|
+
* @namespace
|
|
14383
|
+
* @memberof PressRecognizer
|
|
14384
|
+
*/
|
|
14385
|
+
defaults: {
|
|
14386
|
+
event: "press",
|
|
14387
|
+
pointers: 1,
|
|
14388
|
+
time: 251,
|
|
14389
|
+
// minimal time of the pointer to be pressed
|
|
14390
|
+
threshold: 9
|
|
14391
|
+
// a minimal movement is ok, but keep it low
|
|
14392
|
+
},
|
|
14393
|
+
getTouchAction: function() {
|
|
14394
|
+
return [TOUCH_ACTION_AUTO];
|
|
14395
|
+
},
|
|
14396
|
+
process: function(input) {
|
|
14397
|
+
var options = this.options;
|
|
14398
|
+
var validPointers = input.pointers.length === options.pointers;
|
|
14399
|
+
var validMovement = input.distance < options.threshold;
|
|
14400
|
+
var validTime = input.deltaTime > options.time;
|
|
14401
|
+
this._input = input;
|
|
14402
|
+
if (!validMovement || !validPointers || input.eventType & (INPUT_END | INPUT_CANCEL) && !validTime) {
|
|
14403
|
+
this.reset();
|
|
14404
|
+
} else if (input.eventType & INPUT_START) {
|
|
14405
|
+
this.reset();
|
|
14406
|
+
this._timer = setTimeoutContext(function() {
|
|
14407
|
+
this.state = STATE_RECOGNIZED;
|
|
14408
|
+
this.tryEmit();
|
|
14409
|
+
}, options.time, this);
|
|
14410
|
+
} else if (input.eventType & INPUT_END) {
|
|
14411
|
+
return STATE_RECOGNIZED;
|
|
14412
|
+
}
|
|
14413
|
+
return STATE_FAILED;
|
|
14414
|
+
},
|
|
14415
|
+
reset: function() {
|
|
14416
|
+
clearTimeout(this._timer);
|
|
14417
|
+
},
|
|
14418
|
+
emit: function(input) {
|
|
14419
|
+
if (this.state !== STATE_RECOGNIZED) {
|
|
14420
|
+
return;
|
|
14421
|
+
}
|
|
14422
|
+
if (input && input.eventType & INPUT_END) {
|
|
14423
|
+
this.manager.emit(this.options.event + "up", input);
|
|
14424
|
+
} else {
|
|
14425
|
+
this._input.timeStamp = now();
|
|
14426
|
+
this.manager.emit(this.options.event, this._input);
|
|
14427
|
+
}
|
|
14384
14428
|
}
|
|
14429
|
+
});
|
|
14430
|
+
function RotateRecognizer() {
|
|
14431
|
+
AttrRecognizer.apply(this, arguments);
|
|
14385
14432
|
}
|
|
14386
|
-
|
|
14387
|
-
|
|
14388
|
-
|
|
14389
|
-
|
|
14390
|
-
|
|
14391
|
-
|
|
14392
|
-
|
|
14393
|
-
|
|
14394
|
-
|
|
14395
|
-
|
|
14396
|
-
|
|
14397
|
-
|
|
14398
|
-
|
|
14399
|
-
|
|
14400
|
-
|
|
14401
|
-
return [TOUCH_ACTION_NONE];
|
|
14402
|
-
},
|
|
14403
|
-
attrTest: function(input) {
|
|
14404
|
-
return this._super.attrTest.call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
|
14405
|
-
}
|
|
14406
|
-
});
|
|
14407
|
-
function SwipeRecognizer() {
|
|
14408
|
-
AttrRecognizer.apply(this, arguments);
|
|
14409
|
-
}
|
|
14410
|
-
inherit(SwipeRecognizer, AttrRecognizer, {
|
|
14411
|
-
/**
|
|
14412
|
-
* @namespace
|
|
14413
|
-
* @memberof SwipeRecognizer
|
|
14414
|
-
*/
|
|
14415
|
-
defaults: {
|
|
14416
|
-
event: "swipe",
|
|
14417
|
-
threshold: 10,
|
|
14418
|
-
velocity: 0.3,
|
|
14419
|
-
direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
|
|
14420
|
-
pointers: 1
|
|
14421
|
-
},
|
|
14422
|
-
getTouchAction: function() {
|
|
14423
|
-
return PanRecognizer.prototype.getTouchAction.call(this);
|
|
14424
|
-
},
|
|
14425
|
-
attrTest: function(input) {
|
|
14426
|
-
var direction = this.options.direction;
|
|
14427
|
-
var velocity;
|
|
14428
|
-
if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
|
|
14429
|
-
velocity = input.overallVelocity;
|
|
14430
|
-
} else if (direction & DIRECTION_HORIZONTAL) {
|
|
14431
|
-
velocity = input.overallVelocityX;
|
|
14432
|
-
} else if (direction & DIRECTION_VERTICAL) {
|
|
14433
|
-
velocity = input.overallVelocityY;
|
|
14434
|
-
}
|
|
14435
|
-
return this._super.attrTest.call(this, input) && direction & input.offsetDirection && input.distance > this.options.threshold && input.maxPointers == this.options.pointers && abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
|
|
14436
|
-
},
|
|
14437
|
-
emit: function(input) {
|
|
14438
|
-
var direction = directionStr(input.offsetDirection);
|
|
14439
|
-
if (direction) {
|
|
14440
|
-
this.manager.emit(this.options.event + direction, input);
|
|
14433
|
+
inherit(RotateRecognizer, AttrRecognizer, {
|
|
14434
|
+
/**
|
|
14435
|
+
* @namespace
|
|
14436
|
+
* @memberof RotateRecognizer
|
|
14437
|
+
*/
|
|
14438
|
+
defaults: {
|
|
14439
|
+
event: "rotate",
|
|
14440
|
+
threshold: 0,
|
|
14441
|
+
pointers: 2
|
|
14442
|
+
},
|
|
14443
|
+
getTouchAction: function() {
|
|
14444
|
+
return [TOUCH_ACTION_NONE];
|
|
14445
|
+
},
|
|
14446
|
+
attrTest: function(input) {
|
|
14447
|
+
return this._super.attrTest.call(this, input) && (Math.abs(input.rotation) > this.options.threshold || this.state & STATE_BEGAN);
|
|
14441
14448
|
}
|
|
14442
|
-
|
|
14449
|
+
});
|
|
14450
|
+
function SwipeRecognizer() {
|
|
14451
|
+
AttrRecognizer.apply(this, arguments);
|
|
14443
14452
|
}
|
|
14444
|
-
|
|
14445
|
-
|
|
14446
|
-
|
|
14447
|
-
|
|
14448
|
-
|
|
14449
|
-
|
|
14450
|
-
|
|
14451
|
-
|
|
14452
|
-
|
|
14453
|
-
|
|
14454
|
-
|
|
14455
|
-
|
|
14456
|
-
|
|
14457
|
-
|
|
14458
|
-
|
|
14459
|
-
|
|
14460
|
-
|
|
14461
|
-
|
|
14462
|
-
|
|
14463
|
-
|
|
14464
|
-
|
|
14465
|
-
|
|
14466
|
-
|
|
14467
|
-
|
|
14468
|
-
|
|
14469
|
-
|
|
14470
|
-
|
|
14471
|
-
|
|
14472
|
-
|
|
14473
|
-
|
|
14474
|
-
|
|
14475
|
-
|
|
14476
|
-
|
|
14477
|
-
var validMovement = input.distance < options.threshold;
|
|
14478
|
-
var validTouchTime = input.deltaTime < options.time;
|
|
14479
|
-
this.reset();
|
|
14480
|
-
if (input.eventType & INPUT_START && this.count === 0) {
|
|
14481
|
-
return this.failTimeout();
|
|
14453
|
+
inherit(SwipeRecognizer, AttrRecognizer, {
|
|
14454
|
+
/**
|
|
14455
|
+
* @namespace
|
|
14456
|
+
* @memberof SwipeRecognizer
|
|
14457
|
+
*/
|
|
14458
|
+
defaults: {
|
|
14459
|
+
event: "swipe",
|
|
14460
|
+
threshold: 10,
|
|
14461
|
+
velocity: 0.3,
|
|
14462
|
+
direction: DIRECTION_HORIZONTAL | DIRECTION_VERTICAL,
|
|
14463
|
+
pointers: 1
|
|
14464
|
+
},
|
|
14465
|
+
getTouchAction: function() {
|
|
14466
|
+
return PanRecognizer.prototype.getTouchAction.call(this);
|
|
14467
|
+
},
|
|
14468
|
+
attrTest: function(input) {
|
|
14469
|
+
var direction = this.options.direction;
|
|
14470
|
+
var velocity;
|
|
14471
|
+
if (direction & (DIRECTION_HORIZONTAL | DIRECTION_VERTICAL)) {
|
|
14472
|
+
velocity = input.overallVelocity;
|
|
14473
|
+
} else if (direction & DIRECTION_HORIZONTAL) {
|
|
14474
|
+
velocity = input.overallVelocityX;
|
|
14475
|
+
} else if (direction & DIRECTION_VERTICAL) {
|
|
14476
|
+
velocity = input.overallVelocityY;
|
|
14477
|
+
}
|
|
14478
|
+
return this._super.attrTest.call(this, input) && direction & input.offsetDirection && input.distance > this.options.threshold && input.maxPointers == this.options.pointers && abs(velocity) > this.options.velocity && input.eventType & INPUT_END;
|
|
14479
|
+
},
|
|
14480
|
+
emit: function(input) {
|
|
14481
|
+
var direction = directionStr(input.offsetDirection);
|
|
14482
|
+
if (direction) {
|
|
14483
|
+
this.manager.emit(this.options.event + direction, input);
|
|
14484
|
+
}
|
|
14485
|
+
this.manager.emit(this.options.event, input);
|
|
14482
14486
|
}
|
|
14483
|
-
|
|
14484
|
-
|
|
14487
|
+
});
|
|
14488
|
+
function TapRecognizer() {
|
|
14489
|
+
Recognizer.apply(this, arguments);
|
|
14490
|
+
this.pTime = false;
|
|
14491
|
+
this.pCenter = false;
|
|
14492
|
+
this._timer = null;
|
|
14493
|
+
this._input = null;
|
|
14494
|
+
this.count = 0;
|
|
14495
|
+
}
|
|
14496
|
+
inherit(TapRecognizer, Recognizer, {
|
|
14497
|
+
/**
|
|
14498
|
+
* @namespace
|
|
14499
|
+
* @memberof PinchRecognizer
|
|
14500
|
+
*/
|
|
14501
|
+
defaults: {
|
|
14502
|
+
event: "tap",
|
|
14503
|
+
pointers: 1,
|
|
14504
|
+
taps: 1,
|
|
14505
|
+
interval: 300,
|
|
14506
|
+
// max time between the multi-tap taps
|
|
14507
|
+
time: 250,
|
|
14508
|
+
// max time of the pointer to be down (like finger on the screen)
|
|
14509
|
+
threshold: 9,
|
|
14510
|
+
// a minimal movement is ok, but keep it low
|
|
14511
|
+
posThreshold: 10
|
|
14512
|
+
// a multi-tap can be a bit off the initial position
|
|
14513
|
+
},
|
|
14514
|
+
getTouchAction: function() {
|
|
14515
|
+
return [TOUCH_ACTION_MANIPULATION];
|
|
14516
|
+
},
|
|
14517
|
+
process: function(input) {
|
|
14518
|
+
var options = this.options;
|
|
14519
|
+
var validPointers = input.pointers.length === options.pointers;
|
|
14520
|
+
var validMovement = input.distance < options.threshold;
|
|
14521
|
+
var validTouchTime = input.deltaTime < options.time;
|
|
14522
|
+
this.reset();
|
|
14523
|
+
if (input.eventType & INPUT_START && this.count === 0) {
|
|
14485
14524
|
return this.failTimeout();
|
|
14486
14525
|
}
|
|
14487
|
-
|
|
14488
|
-
|
|
14489
|
-
|
|
14490
|
-
|
|
14491
|
-
|
|
14492
|
-
this.
|
|
14493
|
-
|
|
14494
|
-
this.
|
|
14495
|
-
|
|
14496
|
-
|
|
14497
|
-
var tapCount = this.count % options.taps;
|
|
14498
|
-
if (tapCount === 0) {
|
|
14499
|
-
if (!this.hasRequireFailures()) {
|
|
14500
|
-
return STATE_RECOGNIZED;
|
|
14526
|
+
if (validMovement && validTouchTime && validPointers) {
|
|
14527
|
+
if (input.eventType != INPUT_END) {
|
|
14528
|
+
return this.failTimeout();
|
|
14529
|
+
}
|
|
14530
|
+
var validInterval = this.pTime ? input.timeStamp - this.pTime < options.interval : true;
|
|
14531
|
+
var validMultiTap = !this.pCenter || getDistance(this.pCenter, input.center) < options.posThreshold;
|
|
14532
|
+
this.pTime = input.timeStamp;
|
|
14533
|
+
this.pCenter = input.center;
|
|
14534
|
+
if (!validMultiTap || !validInterval) {
|
|
14535
|
+
this.count = 1;
|
|
14501
14536
|
} else {
|
|
14502
|
-
this.
|
|
14503
|
-
|
|
14504
|
-
|
|
14505
|
-
|
|
14506
|
-
|
|
14537
|
+
this.count += 1;
|
|
14538
|
+
}
|
|
14539
|
+
this._input = input;
|
|
14540
|
+
var tapCount = this.count % options.taps;
|
|
14541
|
+
if (tapCount === 0) {
|
|
14542
|
+
if (!this.hasRequireFailures()) {
|
|
14543
|
+
return STATE_RECOGNIZED;
|
|
14544
|
+
} else {
|
|
14545
|
+
this._timer = setTimeoutContext(function() {
|
|
14546
|
+
this.state = STATE_RECOGNIZED;
|
|
14547
|
+
this.tryEmit();
|
|
14548
|
+
}, options.interval, this);
|
|
14549
|
+
return STATE_BEGAN;
|
|
14550
|
+
}
|
|
14507
14551
|
}
|
|
14508
14552
|
}
|
|
14553
|
+
return STATE_FAILED;
|
|
14554
|
+
},
|
|
14555
|
+
failTimeout: function() {
|
|
14556
|
+
this._timer = setTimeoutContext(function() {
|
|
14557
|
+
this.state = STATE_FAILED;
|
|
14558
|
+
}, this.options.interval, this);
|
|
14559
|
+
return STATE_FAILED;
|
|
14560
|
+
},
|
|
14561
|
+
reset: function() {
|
|
14562
|
+
clearTimeout(this._timer);
|
|
14563
|
+
},
|
|
14564
|
+
emit: function() {
|
|
14565
|
+
if (this.state == STATE_RECOGNIZED) {
|
|
14566
|
+
this._input.tapCount = this.count;
|
|
14567
|
+
this.manager.emit(this.options.event, this._input);
|
|
14568
|
+
}
|
|
14509
14569
|
}
|
|
14510
|
-
|
|
14511
|
-
|
|
14512
|
-
|
|
14513
|
-
|
|
14514
|
-
|
|
14515
|
-
}, this.options.interval, this);
|
|
14516
|
-
return STATE_FAILED;
|
|
14517
|
-
},
|
|
14518
|
-
reset: function() {
|
|
14519
|
-
clearTimeout(this._timer);
|
|
14520
|
-
},
|
|
14521
|
-
emit: function() {
|
|
14522
|
-
if (this.state == STATE_RECOGNIZED) {
|
|
14523
|
-
this._input.tapCount = this.count;
|
|
14524
|
-
this.manager.emit(this.options.event, this._input);
|
|
14525
|
-
}
|
|
14570
|
+
});
|
|
14571
|
+
function Hammer2(element, options) {
|
|
14572
|
+
options = options || {};
|
|
14573
|
+
options.recognizers = ifUndefined(options.recognizers, Hammer2.defaults.preset);
|
|
14574
|
+
return new Manager(element, options);
|
|
14526
14575
|
}
|
|
14527
|
-
|
|
14528
|
-
|
|
14529
|
-
options = options || {};
|
|
14530
|
-
options.recognizers = ifUndefined(options.recognizers, Hammer2.defaults.preset);
|
|
14531
|
-
return new Manager(element, options);
|
|
14532
|
-
}
|
|
14533
|
-
Hammer2.VERSION = "2.0.7";
|
|
14534
|
-
Hammer2.defaults = {
|
|
14535
|
-
/**
|
|
14536
|
-
* set if DOM events are being triggered.
|
|
14537
|
-
* But this is slower and unused by simple implementations, so disabled by default.
|
|
14538
|
-
* @type {Boolean}
|
|
14539
|
-
* @default false
|
|
14540
|
-
*/
|
|
14541
|
-
domEvents: false,
|
|
14542
|
-
/**
|
|
14543
|
-
* The value for the touchAction property/fallback.
|
|
14544
|
-
* When set to `compute` it will magically set the correct value based on the added recognizers.
|
|
14545
|
-
* @type {String}
|
|
14546
|
-
* @default compute
|
|
14547
|
-
*/
|
|
14548
|
-
touchAction: TOUCH_ACTION_COMPUTE,
|
|
14549
|
-
/**
|
|
14550
|
-
* @type {Boolean}
|
|
14551
|
-
* @default true
|
|
14552
|
-
*/
|
|
14553
|
-
enable: true,
|
|
14554
|
-
/**
|
|
14555
|
-
* EXPERIMENTAL FEATURE -- can be removed/changed
|
|
14556
|
-
* Change the parent input target element.
|
|
14557
|
-
* If Null, then it is being set the to main element.
|
|
14558
|
-
* @type {Null|EventTarget}
|
|
14559
|
-
* @default null
|
|
14560
|
-
*/
|
|
14561
|
-
inputTarget: null,
|
|
14562
|
-
/**
|
|
14563
|
-
* force an input class
|
|
14564
|
-
* @type {Null|Function}
|
|
14565
|
-
* @default null
|
|
14566
|
-
*/
|
|
14567
|
-
inputClass: null,
|
|
14568
|
-
/**
|
|
14569
|
-
* Default recognizer setup when calling `Hammer()`
|
|
14570
|
-
* When creating a new Manager these will be skipped.
|
|
14571
|
-
* @type {Array}
|
|
14572
|
-
*/
|
|
14573
|
-
preset: [
|
|
14574
|
-
// RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
|
|
14575
|
-
[RotateRecognizer, { enable: false }],
|
|
14576
|
-
[PinchRecognizer, { enable: false }, ["rotate"]],
|
|
14577
|
-
[SwipeRecognizer, { direction: DIRECTION_HORIZONTAL }],
|
|
14578
|
-
[PanRecognizer, { direction: DIRECTION_HORIZONTAL }, ["swipe"]],
|
|
14579
|
-
[TapRecognizer],
|
|
14580
|
-
[TapRecognizer, { event: "doubletap", taps: 2 }, ["tap"]],
|
|
14581
|
-
[PressRecognizer]
|
|
14582
|
-
],
|
|
14583
|
-
/**
|
|
14584
|
-
* Some CSS properties can be used to improve the working of Hammer.
|
|
14585
|
-
* Add them to this method and they will be set when creating a new Manager.
|
|
14586
|
-
* @namespace
|
|
14587
|
-
*/
|
|
14588
|
-
cssProps: {
|
|
14576
|
+
Hammer2.VERSION = "2.0.7";
|
|
14577
|
+
Hammer2.defaults = {
|
|
14589
14578
|
/**
|
|
14590
|
-
*
|
|
14591
|
-
*
|
|
14592
|
-
* @
|
|
14579
|
+
* set if DOM events are being triggered.
|
|
14580
|
+
* But this is slower and unused by simple implementations, so disabled by default.
|
|
14581
|
+
* @type {Boolean}
|
|
14582
|
+
* @default false
|
|
14593
14583
|
*/
|
|
14594
|
-
|
|
14584
|
+
domEvents: false,
|
|
14595
14585
|
/**
|
|
14596
|
-
*
|
|
14586
|
+
* The value for the touchAction property/fallback.
|
|
14587
|
+
* When set to `compute` it will magically set the correct value based on the added recognizers.
|
|
14597
14588
|
* @type {String}
|
|
14598
|
-
* @default
|
|
14589
|
+
* @default compute
|
|
14599
14590
|
*/
|
|
14600
|
-
|
|
14591
|
+
touchAction: TOUCH_ACTION_COMPUTE,
|
|
14601
14592
|
/**
|
|
14602
|
-
*
|
|
14603
|
-
*
|
|
14604
|
-
* a callout containing information about the link. This property allows you to disable that callout.
|
|
14605
|
-
* @type {String}
|
|
14606
|
-
* @default 'none'
|
|
14593
|
+
* @type {Boolean}
|
|
14594
|
+
* @default true
|
|
14607
14595
|
*/
|
|
14608
|
-
|
|
14596
|
+
enable: true,
|
|
14609
14597
|
/**
|
|
14610
|
-
*
|
|
14611
|
-
*
|
|
14612
|
-
*
|
|
14598
|
+
* EXPERIMENTAL FEATURE -- can be removed/changed
|
|
14599
|
+
* Change the parent input target element.
|
|
14600
|
+
* If Null, then it is being set the to main element.
|
|
14601
|
+
* @type {Null|EventTarget}
|
|
14602
|
+
* @default null
|
|
14613
14603
|
*/
|
|
14614
|
-
|
|
14604
|
+
inputTarget: null,
|
|
14615
14605
|
/**
|
|
14616
|
-
*
|
|
14617
|
-
* @type {
|
|
14618
|
-
* @default
|
|
14606
|
+
* force an input class
|
|
14607
|
+
* @type {Null|Function}
|
|
14608
|
+
* @default null
|
|
14619
14609
|
*/
|
|
14620
|
-
|
|
14610
|
+
inputClass: null,
|
|
14621
14611
|
/**
|
|
14622
|
-
*
|
|
14623
|
-
*
|
|
14624
|
-
* @type {
|
|
14625
|
-
* @default 'rgba(0,0,0,0)'
|
|
14612
|
+
* Default recognizer setup when calling `Hammer()`
|
|
14613
|
+
* When creating a new Manager these will be skipped.
|
|
14614
|
+
* @type {Array}
|
|
14626
14615
|
*/
|
|
14627
|
-
|
|
14628
|
-
|
|
14629
|
-
|
|
14630
|
-
|
|
14631
|
-
|
|
14632
|
-
|
|
14633
|
-
|
|
14634
|
-
|
|
14635
|
-
|
|
14636
|
-
|
|
14637
|
-
|
|
14638
|
-
|
|
14639
|
-
|
|
14640
|
-
|
|
14641
|
-
|
|
14642
|
-
|
|
14643
|
-
|
|
14644
|
-
|
|
14645
|
-
|
|
14646
|
-
|
|
14647
|
-
|
|
14648
|
-
|
|
14649
|
-
|
|
14650
|
-
|
|
14651
|
-
|
|
14652
|
-
|
|
14653
|
-
|
|
14654
|
-
|
|
14655
|
-
|
|
14656
|
-
|
|
14657
|
-
|
|
14658
|
-
|
|
14659
|
-
|
|
14660
|
-
|
|
14661
|
-
|
|
14662
|
-
|
|
14663
|
-
|
|
14664
|
-
|
|
14665
|
-
|
|
14666
|
-
|
|
14667
|
-
|
|
14668
|
-
|
|
14669
|
-
|
|
14670
|
-
|
|
14671
|
-
|
|
14672
|
-
|
|
14673
|
-
|
|
14674
|
-
|
|
14675
|
-
|
|
14676
|
-
|
|
14677
|
-
|
|
14678
|
-
|
|
14679
|
-
|
|
14680
|
-
|
|
14681
|
-
|
|
14682
|
-
recognize: function(inputData) {
|
|
14683
|
-
var session = this.session;
|
|
14684
|
-
if (session.stopped) {
|
|
14685
|
-
return;
|
|
14686
|
-
}
|
|
14687
|
-
this.touchAction.preventDefaults(inputData);
|
|
14688
|
-
var recognizer;
|
|
14689
|
-
var recognizers = this.recognizers;
|
|
14690
|
-
var curRecognizer = session.curRecognizer;
|
|
14691
|
-
if (!curRecognizer || curRecognizer && curRecognizer.state & STATE_RECOGNIZED) {
|
|
14692
|
-
curRecognizer = session.curRecognizer = null;
|
|
14616
|
+
preset: [
|
|
14617
|
+
// RecognizerClass, options, [recognizeWith, ...], [requireFailure, ...]
|
|
14618
|
+
[RotateRecognizer, { enable: false }],
|
|
14619
|
+
[PinchRecognizer, { enable: false }, ["rotate"]],
|
|
14620
|
+
[SwipeRecognizer, { direction: DIRECTION_HORIZONTAL }],
|
|
14621
|
+
[PanRecognizer, { direction: DIRECTION_HORIZONTAL }, ["swipe"]],
|
|
14622
|
+
[TapRecognizer],
|
|
14623
|
+
[TapRecognizer, { event: "doubletap", taps: 2 }, ["tap"]],
|
|
14624
|
+
[PressRecognizer]
|
|
14625
|
+
],
|
|
14626
|
+
/**
|
|
14627
|
+
* Some CSS properties can be used to improve the working of Hammer.
|
|
14628
|
+
* Add them to this method and they will be set when creating a new Manager.
|
|
14629
|
+
* @namespace
|
|
14630
|
+
*/
|
|
14631
|
+
cssProps: {
|
|
14632
|
+
/**
|
|
14633
|
+
* Disables text selection to improve the dragging gesture. Mainly for desktop browsers.
|
|
14634
|
+
* @type {String}
|
|
14635
|
+
* @default 'none'
|
|
14636
|
+
*/
|
|
14637
|
+
userSelect: "none",
|
|
14638
|
+
/**
|
|
14639
|
+
* Disable the Windows Phone grippers when pressing an element.
|
|
14640
|
+
* @type {String}
|
|
14641
|
+
* @default 'none'
|
|
14642
|
+
*/
|
|
14643
|
+
touchSelect: "none",
|
|
14644
|
+
/**
|
|
14645
|
+
* Disables the default callout shown when you touch and hold a touch target.
|
|
14646
|
+
* On iOS, when you touch and hold a touch target such as a link, Safari displays
|
|
14647
|
+
* a callout containing information about the link. This property allows you to disable that callout.
|
|
14648
|
+
* @type {String}
|
|
14649
|
+
* @default 'none'
|
|
14650
|
+
*/
|
|
14651
|
+
touchCallout: "none",
|
|
14652
|
+
/**
|
|
14653
|
+
* Specifies whether zooming is enabled. Used by IE10>
|
|
14654
|
+
* @type {String}
|
|
14655
|
+
* @default 'none'
|
|
14656
|
+
*/
|
|
14657
|
+
contentZooming: "none",
|
|
14658
|
+
/**
|
|
14659
|
+
* Specifies that an entire element should be draggable instead of its contents. Mainly for desktop browsers.
|
|
14660
|
+
* @type {String}
|
|
14661
|
+
* @default 'none'
|
|
14662
|
+
*/
|
|
14663
|
+
userDrag: "none",
|
|
14664
|
+
/**
|
|
14665
|
+
* Overrides the highlight color shown when the user taps a link or a JavaScript
|
|
14666
|
+
* clickable element in iOS. This property obeys the alpha value, if specified.
|
|
14667
|
+
* @type {String}
|
|
14668
|
+
* @default 'rgba(0,0,0,0)'
|
|
14669
|
+
*/
|
|
14670
|
+
tapHighlightColor: "rgba(0,0,0,0)"
|
|
14693
14671
|
}
|
|
14694
|
-
|
|
14695
|
-
|
|
14696
|
-
|
|
14697
|
-
|
|
14698
|
-
|
|
14699
|
-
|
|
14700
|
-
|
|
14701
|
-
|
|
14702
|
-
|
|
14672
|
+
};
|
|
14673
|
+
var STOP = 1;
|
|
14674
|
+
var FORCED_STOP = 2;
|
|
14675
|
+
function Manager(element, options) {
|
|
14676
|
+
this.options = assign({}, Hammer2.defaults, options || {});
|
|
14677
|
+
this.options.inputTarget = this.options.inputTarget || element;
|
|
14678
|
+
this.handlers = {};
|
|
14679
|
+
this.session = {};
|
|
14680
|
+
this.recognizers = [];
|
|
14681
|
+
this.oldCssProps = {};
|
|
14682
|
+
this.element = element;
|
|
14683
|
+
this.input = createInputInstance(this);
|
|
14684
|
+
this.touchAction = new TouchAction(this, this.options.touchAction);
|
|
14685
|
+
toggleCssProps(this, true);
|
|
14686
|
+
each2(this.options.recognizers, function(item) {
|
|
14687
|
+
var recognizer = this.add(new item[0](item[1]));
|
|
14688
|
+
item[2] && recognizer.recognizeWith(item[2]);
|
|
14689
|
+
item[3] && recognizer.requireFailure(item[3]);
|
|
14690
|
+
}, this);
|
|
14691
|
+
}
|
|
14692
|
+
Manager.prototype = {
|
|
14693
|
+
/**
|
|
14694
|
+
* set options
|
|
14695
|
+
* @param {Object} options
|
|
14696
|
+
* @returns {Manager}
|
|
14697
|
+
*/
|
|
14698
|
+
set: function(options) {
|
|
14699
|
+
assign(this.options, options);
|
|
14700
|
+
if (options.touchAction) {
|
|
14701
|
+
this.touchAction.update();
|
|
14703
14702
|
}
|
|
14704
|
-
if (
|
|
14705
|
-
|
|
14703
|
+
if (options.inputTarget) {
|
|
14704
|
+
this.input.destroy();
|
|
14705
|
+
this.input.target = options.inputTarget;
|
|
14706
|
+
this.input.init();
|
|
14706
14707
|
}
|
|
14707
|
-
|
|
14708
|
-
}
|
|
14709
|
-
|
|
14710
|
-
|
|
14711
|
-
|
|
14712
|
-
|
|
14713
|
-
|
|
14714
|
-
|
|
14715
|
-
|
|
14716
|
-
|
|
14708
|
+
return this;
|
|
14709
|
+
},
|
|
14710
|
+
/**
|
|
14711
|
+
* stop recognizing for this session.
|
|
14712
|
+
* This session will be discarded, when a new [input]start event is fired.
|
|
14713
|
+
* When forced, the recognizer cycle is stopped immediately.
|
|
14714
|
+
* @param {Boolean} [force]
|
|
14715
|
+
*/
|
|
14716
|
+
stop: function(force) {
|
|
14717
|
+
this.session.stopped = force ? FORCED_STOP : STOP;
|
|
14718
|
+
},
|
|
14719
|
+
/**
|
|
14720
|
+
* run the recognizers!
|
|
14721
|
+
* called by the inputHandler function on every movement of the pointers (touches)
|
|
14722
|
+
* it walks through all the recognizers and tries to detect the gesture that is being made
|
|
14723
|
+
* @param {Object} inputData
|
|
14724
|
+
*/
|
|
14725
|
+
recognize: function(inputData) {
|
|
14726
|
+
var session = this.session;
|
|
14727
|
+
if (session.stopped) {
|
|
14728
|
+
return;
|
|
14729
|
+
}
|
|
14730
|
+
this.touchAction.preventDefaults(inputData);
|
|
14731
|
+
var recognizer;
|
|
14732
|
+
var recognizers = this.recognizers;
|
|
14733
|
+
var curRecognizer = session.curRecognizer;
|
|
14734
|
+
if (!curRecognizer || curRecognizer && curRecognizer.state & STATE_RECOGNIZED) {
|
|
14735
|
+
curRecognizer = session.curRecognizer = null;
|
|
14736
|
+
}
|
|
14737
|
+
var i2 = 0;
|
|
14738
|
+
while (i2 < recognizers.length) {
|
|
14739
|
+
recognizer = recognizers[i2];
|
|
14740
|
+
if (session.stopped !== FORCED_STOP && // 1
|
|
14741
|
+
(!curRecognizer || recognizer == curRecognizer || // 2
|
|
14742
|
+
recognizer.canRecognizeWith(curRecognizer))) {
|
|
14743
|
+
recognizer.recognize(inputData);
|
|
14744
|
+
} else {
|
|
14745
|
+
recognizer.reset();
|
|
14746
|
+
}
|
|
14747
|
+
if (!curRecognizer && recognizer.state & (STATE_BEGAN | STATE_CHANGED | STATE_ENDED)) {
|
|
14748
|
+
curRecognizer = session.curRecognizer = recognizer;
|
|
14749
|
+
}
|
|
14750
|
+
i2++;
|
|
14751
|
+
}
|
|
14752
|
+
},
|
|
14753
|
+
/**
|
|
14754
|
+
* get a recognizer by its event name.
|
|
14755
|
+
* @param {Recognizer|String} recognizer
|
|
14756
|
+
* @returns {Recognizer|Null}
|
|
14757
|
+
*/
|
|
14758
|
+
get: function(recognizer) {
|
|
14759
|
+
if (recognizer instanceof Recognizer) {
|
|
14760
|
+
return recognizer;
|
|
14761
|
+
}
|
|
14762
|
+
var recognizers = this.recognizers;
|
|
14763
|
+
for (var i2 = 0; i2 < recognizers.length; i2++) {
|
|
14764
|
+
if (recognizers[i2].options.event == recognizer) {
|
|
14765
|
+
return recognizers[i2];
|
|
14766
|
+
}
|
|
14767
|
+
}
|
|
14768
|
+
return null;
|
|
14769
|
+
},
|
|
14770
|
+
/**
|
|
14771
|
+
* add a recognizer to the manager
|
|
14772
|
+
* existing recognizers with the same event name will be removed
|
|
14773
|
+
* @param {Recognizer} recognizer
|
|
14774
|
+
* @returns {Recognizer|Manager}
|
|
14775
|
+
*/
|
|
14776
|
+
add: function(recognizer) {
|
|
14777
|
+
if (invokeArrayArg(recognizer, "add", this)) {
|
|
14778
|
+
return this;
|
|
14779
|
+
}
|
|
14780
|
+
var existing = this.get(recognizer.options.event);
|
|
14781
|
+
if (existing) {
|
|
14782
|
+
this.remove(existing);
|
|
14783
|
+
}
|
|
14784
|
+
this.recognizers.push(recognizer);
|
|
14785
|
+
recognizer.manager = this;
|
|
14786
|
+
this.touchAction.update();
|
|
14717
14787
|
return recognizer;
|
|
14718
|
-
}
|
|
14719
|
-
|
|
14720
|
-
|
|
14721
|
-
|
|
14722
|
-
|
|
14788
|
+
},
|
|
14789
|
+
/**
|
|
14790
|
+
* remove a recognizer by name or instance
|
|
14791
|
+
* @param {Recognizer|String} recognizer
|
|
14792
|
+
* @returns {Manager}
|
|
14793
|
+
*/
|
|
14794
|
+
remove: function(recognizer) {
|
|
14795
|
+
if (invokeArrayArg(recognizer, "remove", this)) {
|
|
14796
|
+
return this;
|
|
14797
|
+
}
|
|
14798
|
+
recognizer = this.get(recognizer);
|
|
14799
|
+
if (recognizer) {
|
|
14800
|
+
var recognizers = this.recognizers;
|
|
14801
|
+
var index2 = inArray(recognizers, recognizer);
|
|
14802
|
+
if (index2 !== -1) {
|
|
14803
|
+
recognizers.splice(index2, 1);
|
|
14804
|
+
this.touchAction.update();
|
|
14805
|
+
}
|
|
14723
14806
|
}
|
|
14724
|
-
}
|
|
14725
|
-
return null;
|
|
14726
|
-
},
|
|
14727
|
-
/**
|
|
14728
|
-
* add a recognizer to the manager
|
|
14729
|
-
* existing recognizers with the same event name will be removed
|
|
14730
|
-
* @param {Recognizer} recognizer
|
|
14731
|
-
* @returns {Recognizer|Manager}
|
|
14732
|
-
*/
|
|
14733
|
-
add: function(recognizer) {
|
|
14734
|
-
if (invokeArrayArg(recognizer, "add", this)) {
|
|
14735
14807
|
return this;
|
|
14736
|
-
}
|
|
14737
|
-
|
|
14738
|
-
|
|
14739
|
-
|
|
14740
|
-
|
|
14741
|
-
|
|
14742
|
-
|
|
14743
|
-
|
|
14744
|
-
|
|
14745
|
-
|
|
14746
|
-
|
|
14747
|
-
|
|
14748
|
-
|
|
14749
|
-
|
|
14750
|
-
|
|
14751
|
-
|
|
14752
|
-
|
|
14808
|
+
},
|
|
14809
|
+
/**
|
|
14810
|
+
* bind event
|
|
14811
|
+
* @param {String} events
|
|
14812
|
+
* @param {Function} handler
|
|
14813
|
+
* @returns {EventEmitter} this
|
|
14814
|
+
*/
|
|
14815
|
+
on: function(events, handler) {
|
|
14816
|
+
if (events === undefined$1) {
|
|
14817
|
+
return;
|
|
14818
|
+
}
|
|
14819
|
+
if (handler === undefined$1) {
|
|
14820
|
+
return;
|
|
14821
|
+
}
|
|
14822
|
+
var handlers = this.handlers;
|
|
14823
|
+
each2(splitStr(events), function(event) {
|
|
14824
|
+
handlers[event] = handlers[event] || [];
|
|
14825
|
+
handlers[event].push(handler);
|
|
14826
|
+
});
|
|
14753
14827
|
return this;
|
|
14754
|
-
}
|
|
14755
|
-
|
|
14756
|
-
|
|
14757
|
-
|
|
14758
|
-
|
|
14759
|
-
|
|
14760
|
-
|
|
14761
|
-
|
|
14828
|
+
},
|
|
14829
|
+
/**
|
|
14830
|
+
* unbind event, leave emit blank to remove all handlers
|
|
14831
|
+
* @param {String} events
|
|
14832
|
+
* @param {Function} [handler]
|
|
14833
|
+
* @returns {EventEmitter} this
|
|
14834
|
+
*/
|
|
14835
|
+
off: function(events, handler) {
|
|
14836
|
+
if (events === undefined$1) {
|
|
14837
|
+
return;
|
|
14762
14838
|
}
|
|
14839
|
+
var handlers = this.handlers;
|
|
14840
|
+
each2(splitStr(events), function(event) {
|
|
14841
|
+
if (!handler) {
|
|
14842
|
+
delete handlers[event];
|
|
14843
|
+
} else {
|
|
14844
|
+
handlers[event] && handlers[event].splice(inArray(handlers[event], handler), 1);
|
|
14845
|
+
}
|
|
14846
|
+
});
|
|
14847
|
+
return this;
|
|
14848
|
+
},
|
|
14849
|
+
/**
|
|
14850
|
+
* emit event to the listeners
|
|
14851
|
+
* @param {String} event
|
|
14852
|
+
* @param {Object} data
|
|
14853
|
+
*/
|
|
14854
|
+
emit: function(event, data) {
|
|
14855
|
+
if (this.options.domEvents) {
|
|
14856
|
+
triggerDomEvent(event, data);
|
|
14857
|
+
}
|
|
14858
|
+
var handlers = this.handlers[event] && this.handlers[event].slice();
|
|
14859
|
+
if (!handlers || !handlers.length) {
|
|
14860
|
+
return;
|
|
14861
|
+
}
|
|
14862
|
+
data.type = event;
|
|
14863
|
+
data.preventDefault = function() {
|
|
14864
|
+
data.srcEvent.preventDefault();
|
|
14865
|
+
};
|
|
14866
|
+
var i2 = 0;
|
|
14867
|
+
while (i2 < handlers.length) {
|
|
14868
|
+
handlers[i2](data);
|
|
14869
|
+
i2++;
|
|
14870
|
+
}
|
|
14871
|
+
},
|
|
14872
|
+
/**
|
|
14873
|
+
* destroy the manager and unbinds all events
|
|
14874
|
+
* it doesn't unbind dom events, that is the user own responsibility
|
|
14875
|
+
*/
|
|
14876
|
+
destroy: function() {
|
|
14877
|
+
this.element && toggleCssProps(this, false);
|
|
14878
|
+
this.handlers = {};
|
|
14879
|
+
this.session = {};
|
|
14880
|
+
this.input.destroy();
|
|
14881
|
+
this.element = null;
|
|
14763
14882
|
}
|
|
14764
|
-
|
|
14765
|
-
|
|
14766
|
-
|
|
14767
|
-
|
|
14768
|
-
* @param {String} events
|
|
14769
|
-
* @param {Function} handler
|
|
14770
|
-
* @returns {EventEmitter} this
|
|
14771
|
-
*/
|
|
14772
|
-
on: function(events, handler) {
|
|
14773
|
-
if (events === undefined$1) {
|
|
14774
|
-
return;
|
|
14775
|
-
}
|
|
14776
|
-
if (handler === undefined$1) {
|
|
14777
|
-
return;
|
|
14778
|
-
}
|
|
14779
|
-
var handlers = this.handlers;
|
|
14780
|
-
each2(splitStr(events), function(event) {
|
|
14781
|
-
handlers[event] = handlers[event] || [];
|
|
14782
|
-
handlers[event].push(handler);
|
|
14783
|
-
});
|
|
14784
|
-
return this;
|
|
14785
|
-
},
|
|
14786
|
-
/**
|
|
14787
|
-
* unbind event, leave emit blank to remove all handlers
|
|
14788
|
-
* @param {String} events
|
|
14789
|
-
* @param {Function} [handler]
|
|
14790
|
-
* @returns {EventEmitter} this
|
|
14791
|
-
*/
|
|
14792
|
-
off: function(events, handler) {
|
|
14793
|
-
if (events === undefined$1) {
|
|
14883
|
+
};
|
|
14884
|
+
function toggleCssProps(manager, add2) {
|
|
14885
|
+
var element = manager.element;
|
|
14886
|
+
if (!element.style) {
|
|
14794
14887
|
return;
|
|
14795
14888
|
}
|
|
14796
|
-
var
|
|
14797
|
-
each2(
|
|
14798
|
-
|
|
14799
|
-
|
|
14889
|
+
var prop;
|
|
14890
|
+
each2(manager.options.cssProps, function(value, name) {
|
|
14891
|
+
prop = prefixed(element.style, name);
|
|
14892
|
+
if (add2) {
|
|
14893
|
+
manager.oldCssProps[prop] = element.style[prop];
|
|
14894
|
+
element.style[prop] = value;
|
|
14800
14895
|
} else {
|
|
14801
|
-
|
|
14896
|
+
element.style[prop] = manager.oldCssProps[prop] || "";
|
|
14802
14897
|
}
|
|
14803
14898
|
});
|
|
14804
|
-
|
|
14805
|
-
|
|
14806
|
-
/**
|
|
14807
|
-
* emit event to the listeners
|
|
14808
|
-
* @param {String} event
|
|
14809
|
-
* @param {Object} data
|
|
14810
|
-
*/
|
|
14811
|
-
emit: function(event, data) {
|
|
14812
|
-
if (this.options.domEvents) {
|
|
14813
|
-
triggerDomEvent(event, data);
|
|
14814
|
-
}
|
|
14815
|
-
var handlers = this.handlers[event] && this.handlers[event].slice();
|
|
14816
|
-
if (!handlers || !handlers.length) {
|
|
14817
|
-
return;
|
|
14899
|
+
if (!add2) {
|
|
14900
|
+
manager.oldCssProps = {};
|
|
14818
14901
|
}
|
|
14819
|
-
data.type = event;
|
|
14820
|
-
data.preventDefault = function() {
|
|
14821
|
-
data.srcEvent.preventDefault();
|
|
14822
|
-
};
|
|
14823
|
-
var i2 = 0;
|
|
14824
|
-
while (i2 < handlers.length) {
|
|
14825
|
-
handlers[i2](data);
|
|
14826
|
-
i2++;
|
|
14827
|
-
}
|
|
14828
|
-
},
|
|
14829
|
-
/**
|
|
14830
|
-
* destroy the manager and unbinds all events
|
|
14831
|
-
* it doesn't unbind dom events, that is the user own responsibility
|
|
14832
|
-
*/
|
|
14833
|
-
destroy: function() {
|
|
14834
|
-
this.element && toggleCssProps(this, false);
|
|
14835
|
-
this.handlers = {};
|
|
14836
|
-
this.session = {};
|
|
14837
|
-
this.input.destroy();
|
|
14838
|
-
this.element = null;
|
|
14839
|
-
}
|
|
14840
|
-
};
|
|
14841
|
-
function toggleCssProps(manager, add2) {
|
|
14842
|
-
var element = manager.element;
|
|
14843
|
-
if (!element.style) {
|
|
14844
|
-
return;
|
|
14845
14902
|
}
|
|
14846
|
-
|
|
14847
|
-
|
|
14848
|
-
|
|
14849
|
-
|
|
14850
|
-
|
|
14851
|
-
|
|
14852
|
-
|
|
14853
|
-
|
|
14854
|
-
|
|
14903
|
+
function triggerDomEvent(event, data) {
|
|
14904
|
+
var gestureEvent = document2.createEvent("Event");
|
|
14905
|
+
gestureEvent.initEvent(event, true, true);
|
|
14906
|
+
gestureEvent.gesture = data;
|
|
14907
|
+
data.target.dispatchEvent(gestureEvent);
|
|
14908
|
+
}
|
|
14909
|
+
assign(Hammer2, {
|
|
14910
|
+
INPUT_START,
|
|
14911
|
+
INPUT_MOVE,
|
|
14912
|
+
INPUT_END,
|
|
14913
|
+
INPUT_CANCEL,
|
|
14914
|
+
STATE_POSSIBLE,
|
|
14915
|
+
STATE_BEGAN,
|
|
14916
|
+
STATE_CHANGED,
|
|
14917
|
+
STATE_ENDED,
|
|
14918
|
+
STATE_RECOGNIZED,
|
|
14919
|
+
STATE_CANCELLED,
|
|
14920
|
+
STATE_FAILED,
|
|
14921
|
+
DIRECTION_NONE,
|
|
14922
|
+
DIRECTION_LEFT,
|
|
14923
|
+
DIRECTION_RIGHT,
|
|
14924
|
+
DIRECTION_UP,
|
|
14925
|
+
DIRECTION_DOWN,
|
|
14926
|
+
DIRECTION_HORIZONTAL,
|
|
14927
|
+
DIRECTION_VERTICAL,
|
|
14928
|
+
DIRECTION_ALL,
|
|
14929
|
+
Manager,
|
|
14930
|
+
Input,
|
|
14931
|
+
TouchAction,
|
|
14932
|
+
TouchInput,
|
|
14933
|
+
MouseInput,
|
|
14934
|
+
PointerEventInput,
|
|
14935
|
+
TouchMouseInput,
|
|
14936
|
+
SingleTouchInput,
|
|
14937
|
+
Recognizer,
|
|
14938
|
+
AttrRecognizer,
|
|
14939
|
+
Tap: TapRecognizer,
|
|
14940
|
+
Pan: PanRecognizer,
|
|
14941
|
+
Swipe: SwipeRecognizer,
|
|
14942
|
+
Pinch: PinchRecognizer,
|
|
14943
|
+
Rotate: RotateRecognizer,
|
|
14944
|
+
Press: PressRecognizer,
|
|
14945
|
+
on: addEventListeners,
|
|
14946
|
+
off: removeEventListeners,
|
|
14947
|
+
each: each2,
|
|
14948
|
+
merge: merge2,
|
|
14949
|
+
extend,
|
|
14950
|
+
assign,
|
|
14951
|
+
inherit,
|
|
14952
|
+
bindFn,
|
|
14953
|
+
prefixed
|
|
14855
14954
|
});
|
|
14856
|
-
|
|
14857
|
-
|
|
14858
|
-
|
|
14859
|
-
|
|
14860
|
-
|
|
14861
|
-
|
|
14862
|
-
|
|
14863
|
-
|
|
14864
|
-
|
|
14865
|
-
|
|
14866
|
-
|
|
14867
|
-
|
|
14868
|
-
INPUT_MOVE,
|
|
14869
|
-
INPUT_END,
|
|
14870
|
-
INPUT_CANCEL,
|
|
14871
|
-
STATE_POSSIBLE,
|
|
14872
|
-
STATE_BEGAN,
|
|
14873
|
-
STATE_CHANGED,
|
|
14874
|
-
STATE_ENDED,
|
|
14875
|
-
STATE_RECOGNIZED,
|
|
14876
|
-
STATE_CANCELLED,
|
|
14877
|
-
STATE_FAILED,
|
|
14878
|
-
DIRECTION_NONE,
|
|
14879
|
-
DIRECTION_LEFT,
|
|
14880
|
-
DIRECTION_RIGHT,
|
|
14881
|
-
DIRECTION_UP,
|
|
14882
|
-
DIRECTION_DOWN,
|
|
14883
|
-
DIRECTION_HORIZONTAL,
|
|
14884
|
-
DIRECTION_VERTICAL,
|
|
14885
|
-
DIRECTION_ALL,
|
|
14886
|
-
Manager,
|
|
14887
|
-
Input,
|
|
14888
|
-
TouchAction,
|
|
14889
|
-
TouchInput,
|
|
14890
|
-
MouseInput,
|
|
14891
|
-
PointerEventInput,
|
|
14892
|
-
TouchMouseInput,
|
|
14893
|
-
SingleTouchInput,
|
|
14894
|
-
Recognizer,
|
|
14895
|
-
AttrRecognizer,
|
|
14896
|
-
Tap: TapRecognizer,
|
|
14897
|
-
Pan: PanRecognizer,
|
|
14898
|
-
Swipe: SwipeRecognizer,
|
|
14899
|
-
Pinch: PinchRecognizer,
|
|
14900
|
-
Rotate: RotateRecognizer,
|
|
14901
|
-
Press: PressRecognizer,
|
|
14902
|
-
on: addEventListeners,
|
|
14903
|
-
off: removeEventListeners,
|
|
14904
|
-
each: each2,
|
|
14905
|
-
merge: merge2,
|
|
14906
|
-
extend,
|
|
14907
|
-
assign,
|
|
14908
|
-
inherit,
|
|
14909
|
-
bindFn,
|
|
14910
|
-
prefixed
|
|
14911
|
-
});
|
|
14912
|
-
var freeGlobal = typeof window2 !== "undefined" ? window2 : typeof self !== "undefined" ? self : {};
|
|
14913
|
-
freeGlobal.Hammer = Hammer2;
|
|
14914
|
-
if (module.exports) {
|
|
14915
|
-
module.exports = Hammer2;
|
|
14916
|
-
} else {
|
|
14917
|
-
window2[exportName] = Hammer2;
|
|
14918
|
-
}
|
|
14919
|
-
})(window, document, "Hammer");
|
|
14920
|
-
})(hammer);
|
|
14921
|
-
var hammerExports = hammer.exports;
|
|
14955
|
+
var freeGlobal = typeof window2 !== "undefined" ? window2 : typeof self !== "undefined" ? self : {};
|
|
14956
|
+
freeGlobal.Hammer = Hammer2;
|
|
14957
|
+
if (module.exports) {
|
|
14958
|
+
module.exports = Hammer2;
|
|
14959
|
+
} else {
|
|
14960
|
+
window2[exportName] = Hammer2;
|
|
14961
|
+
}
|
|
14962
|
+
})(window, document, "Hammer");
|
|
14963
|
+
})(hammer);
|
|
14964
|
+
return hammer.exports;
|
|
14965
|
+
}
|
|
14966
|
+
var hammerExports = requireHammer();
|
|
14922
14967
|
const Hammer = /* @__PURE__ */ getDefaultExportFromCjs(hammerExports);
|
|
14923
14968
|
/*!
|
|
14924
|
-
* chartjs-plugin-zoom v2.
|
|
14925
|
-
*
|
|
14926
|
-
* (c) 2016-
|
|
14969
|
+
* chartjs-plugin-zoom v2.0.1
|
|
14970
|
+
* undefined
|
|
14971
|
+
* (c) 2016-2023 chartjs-plugin-zoom Contributors
|
|
14927
14972
|
* Released under the MIT License
|
|
14928
14973
|
*/
|
|
14929
14974
|
const getModifierKey = (opts) => opts && opts.enabled && opts.modifierKey;
|
|
@@ -15000,9 +15045,7 @@ function getState(chart2) {
|
|
|
15000
15045
|
originalScaleLimits: {},
|
|
15001
15046
|
updatedScaleLimits: {},
|
|
15002
15047
|
handlers: {},
|
|
15003
|
-
panDelta: {}
|
|
15004
|
-
dragging: false,
|
|
15005
|
-
panning: false
|
|
15048
|
+
panDelta: {}
|
|
15006
15049
|
};
|
|
15007
15050
|
chartStates$1.set(chart2, state);
|
|
15008
15051
|
}
|
|
@@ -15011,43 +15054,20 @@ function getState(chart2) {
|
|
|
15011
15054
|
function removeState(chart2) {
|
|
15012
15055
|
chartStates$1.delete(chart2);
|
|
15013
15056
|
}
|
|
15014
|
-
function zoomDelta(
|
|
15015
|
-
const
|
|
15057
|
+
function zoomDelta(scale, zoom2, center) {
|
|
15058
|
+
const range = scale.max - scale.min;
|
|
15059
|
+
const newRange = range * (zoom2 - 1);
|
|
15060
|
+
const centerPoint = scale.isHorizontal() ? center.x : center.y;
|
|
15061
|
+
const minPercent = Math.max(0, Math.min(
|
|
15062
|
+
1,
|
|
15063
|
+
(scale.getValueForPixel(centerPoint) - scale.min) / range || 0
|
|
15064
|
+
));
|
|
15016
15065
|
const maxPercent = 1 - minPercent;
|
|
15017
15066
|
return {
|
|
15018
15067
|
min: newRange * minPercent,
|
|
15019
15068
|
max: newRange * maxPercent
|
|
15020
15069
|
};
|
|
15021
15070
|
}
|
|
15022
|
-
function getValueAtPoint(scale, point) {
|
|
15023
|
-
const pixel = scale.isHorizontal() ? point.x : point.y;
|
|
15024
|
-
return scale.getValueForPixel(pixel);
|
|
15025
|
-
}
|
|
15026
|
-
function linearZoomDelta(scale, zoom2, center) {
|
|
15027
|
-
const range = scale.max - scale.min;
|
|
15028
|
-
const newRange = range * (zoom2 - 1);
|
|
15029
|
-
const centerValue = getValueAtPoint(scale, center);
|
|
15030
|
-
return zoomDelta(centerValue, scale.min, range, newRange);
|
|
15031
|
-
}
|
|
15032
|
-
function logarithmicZoomRange(scale, zoom2, center) {
|
|
15033
|
-
const centerValue = getValueAtPoint(scale, center);
|
|
15034
|
-
if (centerValue === void 0) {
|
|
15035
|
-
return { min: scale.min, max: scale.max };
|
|
15036
|
-
}
|
|
15037
|
-
const logMin = Math.log10(scale.min);
|
|
15038
|
-
const logMax = Math.log10(scale.max);
|
|
15039
|
-
const logCenter = Math.log10(centerValue);
|
|
15040
|
-
const logRange = logMax - logMin;
|
|
15041
|
-
const newLogRange = logRange * (zoom2 - 1);
|
|
15042
|
-
const delta = zoomDelta(logCenter, logMin, logRange, newLogRange);
|
|
15043
|
-
return {
|
|
15044
|
-
min: Math.pow(10, logMin + delta.min),
|
|
15045
|
-
max: Math.pow(10, logMax - delta.max)
|
|
15046
|
-
};
|
|
15047
|
-
}
|
|
15048
|
-
function getScaleLimits$1(scale, limits) {
|
|
15049
|
-
return limits && (limits[scale.id] || limits[scale.axis]) || {};
|
|
15050
|
-
}
|
|
15051
15071
|
function getLimit(state, scale, scaleLimits, prop, fallback) {
|
|
15052
15072
|
let limit = scaleLimits[prop];
|
|
15053
15073
|
if (limit === "original") {
|
|
@@ -15056,7 +15076,7 @@ function getLimit(state, scale, scaleLimits, prop, fallback) {
|
|
|
15056
15076
|
}
|
|
15057
15077
|
return valueOrDefault$1(limit, fallback);
|
|
15058
15078
|
}
|
|
15059
|
-
function
|
|
15079
|
+
function getRange(scale, pixel0, pixel1) {
|
|
15060
15080
|
const v0 = scale.getValueForPixel(pixel0);
|
|
15061
15081
|
const v1 = scale.getValueForPixel(pixel1);
|
|
15062
15082
|
return {
|
|
@@ -15064,19 +15084,17 @@ function linearRange(scale, pixel0, pixel1) {
|
|
|
15064
15084
|
max: Math.max(v0, v1)
|
|
15065
15085
|
};
|
|
15066
15086
|
}
|
|
15067
|
-
function
|
|
15087
|
+
function updateRange(scale, { min, max }, limits, zoom2 = false) {
|
|
15088
|
+
const state = getState(scale.chart);
|
|
15089
|
+
const { id, axis, options: scaleOpts } = scale;
|
|
15090
|
+
const scaleLimits = limits && (limits[id] || limits[axis]) || {};
|
|
15091
|
+
const { minRange = 0 } = scaleLimits;
|
|
15092
|
+
const minLimit = getLimit(state, scale, scaleLimits, "min", -Infinity);
|
|
15093
|
+
const maxLimit = getLimit(state, scale, scaleLimits, "max", Infinity);
|
|
15094
|
+
const range = zoom2 ? Math.max(max - min, minRange) : scale.max - scale.min;
|
|
15068
15095
|
const offset = (range - max + min) / 2;
|
|
15069
15096
|
min -= offset;
|
|
15070
15097
|
max += offset;
|
|
15071
|
-
const origMin = originalLimits.min.options ?? originalLimits.min.scale;
|
|
15072
|
-
const origMax = originalLimits.max.options ?? originalLimits.max.scale;
|
|
15073
|
-
const epsilon = range / 1e6;
|
|
15074
|
-
if (almostEquals$1(min, origMin, epsilon)) {
|
|
15075
|
-
min = origMin;
|
|
15076
|
-
}
|
|
15077
|
-
if (almostEquals$1(max, origMax, epsilon)) {
|
|
15078
|
-
max = origMax;
|
|
15079
|
-
}
|
|
15080
15098
|
if (min < minLimit) {
|
|
15081
15099
|
min = minLimit;
|
|
15082
15100
|
max = Math.min(minLimit + range, maxLimit);
|
|
@@ -15084,40 +15102,18 @@ function fixRange(range, { min, max, minLimit, maxLimit }, originalLimits) {
|
|
|
15084
15102
|
max = maxLimit;
|
|
15085
15103
|
min = Math.max(maxLimit - range, minLimit);
|
|
15086
15104
|
}
|
|
15087
|
-
|
|
15088
|
-
|
|
15089
|
-
|
|
15090
|
-
|
|
15091
|
-
const { options: scaleOpts } = scale;
|
|
15092
|
-
const scaleLimits = getScaleLimits$1(scale, limits);
|
|
15093
|
-
const { minRange = 0 } = scaleLimits;
|
|
15094
|
-
const minLimit = getLimit(state, scale, scaleLimits, "min", -Infinity);
|
|
15095
|
-
const maxLimit = getLimit(state, scale, scaleLimits, "max", Infinity);
|
|
15096
|
-
if (zoom2 === "pan" && (min < minLimit || max > maxLimit)) {
|
|
15097
|
-
return true;
|
|
15098
|
-
}
|
|
15099
|
-
const scaleRange = scale.max - scale.min;
|
|
15100
|
-
const range = zoom2 ? Math.max(max - min, minRange) : scaleRange;
|
|
15101
|
-
if (zoom2 && range === minRange && scaleRange <= minRange) {
|
|
15102
|
-
return true;
|
|
15103
|
-
}
|
|
15104
|
-
const newRange = fixRange(range, { min, max, minLimit, maxLimit }, state.originalScaleLimits[scale.id]);
|
|
15105
|
-
scaleOpts.min = newRange.min;
|
|
15106
|
-
scaleOpts.max = newRange.max;
|
|
15107
|
-
state.updatedScaleLimits[scale.id] = newRange;
|
|
15108
|
-
return scale.parse(newRange.min) !== scale.min || scale.parse(newRange.max) !== scale.max;
|
|
15105
|
+
scaleOpts.min = min;
|
|
15106
|
+
scaleOpts.max = max;
|
|
15107
|
+
state.updatedScaleLimits[scale.id] = { min, max };
|
|
15108
|
+
return scale.parse(min) !== scale.min || scale.parse(max) !== scale.max;
|
|
15109
15109
|
}
|
|
15110
15110
|
function zoomNumericalScale(scale, zoom2, center, limits) {
|
|
15111
|
-
const delta =
|
|
15111
|
+
const delta = zoomDelta(scale, zoom2, center);
|
|
15112
15112
|
const newRange = { min: scale.min + delta.min, max: scale.max - delta.max };
|
|
15113
15113
|
return updateRange(scale, newRange, limits, true);
|
|
15114
15114
|
}
|
|
15115
|
-
function zoomLogarithmicScale(scale, zoom2, center, limits) {
|
|
15116
|
-
const newRange = logarithmicZoomRange(scale, zoom2, center);
|
|
15117
|
-
return updateRange(scale, newRange, limits, true);
|
|
15118
|
-
}
|
|
15119
15115
|
function zoomRectNumericalScale(scale, from2, to2, limits) {
|
|
15120
|
-
updateRange(scale,
|
|
15116
|
+
updateRange(scale, getRange(scale, from2, to2), limits, true);
|
|
15121
15117
|
}
|
|
15122
15118
|
const integerChange = (v2) => v2 === 0 || isNaN(v2) ? 0 : v2 < 0 ? Math.min(Math.round(v2), -1) : Math.max(Math.round(v2), 1);
|
|
15123
15119
|
function existCategoryFromMaxZoom(scale) {
|
|
@@ -15131,7 +15127,7 @@ function existCategoryFromMaxZoom(scale) {
|
|
|
15131
15127
|
}
|
|
15132
15128
|
}
|
|
15133
15129
|
function zoomCategoryScale(scale, zoom2, center, limits) {
|
|
15134
|
-
const delta =
|
|
15130
|
+
const delta = zoomDelta(scale, zoom2, center);
|
|
15135
15131
|
if (scale.min === scale.max && zoom2 < 1) {
|
|
15136
15132
|
existCategoryFromMaxZoom(scale);
|
|
15137
15133
|
}
|
|
@@ -15162,32 +15158,40 @@ function panCategoryScale(scale, delta, limits) {
|
|
|
15162
15158
|
}
|
|
15163
15159
|
const OFFSETS = {
|
|
15164
15160
|
second: 500,
|
|
15161
|
+
// 500 ms
|
|
15165
15162
|
minute: 30 * 1e3,
|
|
15163
|
+
// 30 s
|
|
15166
15164
|
hour: 30 * 60 * 1e3,
|
|
15165
|
+
// 30 m
|
|
15167
15166
|
day: 12 * 60 * 60 * 1e3,
|
|
15167
|
+
// 12 h
|
|
15168
15168
|
week: 3.5 * 24 * 60 * 60 * 1e3,
|
|
15169
|
+
// 3.5 d
|
|
15169
15170
|
month: 15 * 24 * 60 * 60 * 1e3,
|
|
15171
|
+
// 15 d
|
|
15170
15172
|
quarter: 60 * 24 * 60 * 60 * 1e3,
|
|
15173
|
+
// 60 d
|
|
15171
15174
|
year: 182 * 24 * 60 * 60 * 1e3
|
|
15175
|
+
// 182 d
|
|
15172
15176
|
};
|
|
15173
|
-
function panNumericalScale(scale, delta, limits,
|
|
15177
|
+
function panNumericalScale(scale, delta, limits, canZoom = false) {
|
|
15174
15178
|
const { min: prevStart, max: prevEnd, options } = scale;
|
|
15175
15179
|
const round2 = options.time && options.time.round;
|
|
15176
15180
|
const offset = OFFSETS[round2] || 0;
|
|
15177
15181
|
const newMin = scale.getValueForPixel(scale.getPixelForValue(prevStart + offset) - delta);
|
|
15178
15182
|
const newMax = scale.getValueForPixel(scale.getPixelForValue(prevEnd + offset) - delta);
|
|
15179
|
-
|
|
15183
|
+
const { min: minLimit = -Infinity, max: maxLimit = Infinity } = canZoom && limits && limits[scale.axis] || {};
|
|
15184
|
+
if (isNaN(newMin) || isNaN(newMax) || newMin < minLimit || newMax > maxLimit) {
|
|
15180
15185
|
return true;
|
|
15181
15186
|
}
|
|
15182
|
-
return updateRange(scale, { min: newMin, max: newMax }, limits,
|
|
15187
|
+
return updateRange(scale, { min: newMin, max: newMax }, limits, canZoom);
|
|
15183
15188
|
}
|
|
15184
15189
|
function panNonLinearScale(scale, delta, limits) {
|
|
15185
15190
|
return panNumericalScale(scale, delta, limits, true);
|
|
15186
15191
|
}
|
|
15187
15192
|
const zoomFunctions = {
|
|
15188
15193
|
category: zoomCategoryScale,
|
|
15189
|
-
default: zoomNumericalScale
|
|
15190
|
-
logarithmic: zoomLogarithmicScale
|
|
15194
|
+
default: zoomNumericalScale
|
|
15191
15195
|
};
|
|
15192
15196
|
const zoomRectFunctions = {
|
|
15193
15197
|
default: zoomRectNumericalScale
|
|
@@ -15232,9 +15236,9 @@ function doZoom(scale, amount, center, limits) {
|
|
|
15232
15236
|
const fn = zoomFunctions[scale.type] || zoomFunctions.default;
|
|
15233
15237
|
callback$1(fn, [scale, amount, center, limits]);
|
|
15234
15238
|
}
|
|
15235
|
-
function doZoomRect(scale, from2, to2, limits) {
|
|
15239
|
+
function doZoomRect(scale, amount, from2, to2, limits) {
|
|
15236
15240
|
const fn = zoomRectFunctions[scale.type] || zoomRectFunctions.default;
|
|
15237
|
-
callback$1(fn, [scale, from2, to2, limits]);
|
|
15241
|
+
callback$1(fn, [scale, amount, from2, to2, limits]);
|
|
15238
15242
|
}
|
|
15239
15243
|
function getCenter(chart2) {
|
|
15240
15244
|
const ca = chart2.chartArea;
|
|
@@ -15243,7 +15247,7 @@ function getCenter(chart2) {
|
|
|
15243
15247
|
y: (ca.top + ca.bottom) / 2
|
|
15244
15248
|
};
|
|
15245
15249
|
}
|
|
15246
|
-
function zoom(chart2, amount, transition = "none"
|
|
15250
|
+
function zoom(chart2, amount, transition = "none") {
|
|
15247
15251
|
const { x: x2 = 1, y: y2 = 1, focalPoint = getCenter(chart2) } = typeof amount === "number" ? { x: amount, y: amount } : amount;
|
|
15248
15252
|
const state = getState(chart2);
|
|
15249
15253
|
const { options: { limits, zoom: zoomOptions } } = state;
|
|
@@ -15259,9 +15263,9 @@ function zoom(chart2, amount, transition = "none", trigger = "api") {
|
|
|
15259
15263
|
}
|
|
15260
15264
|
});
|
|
15261
15265
|
chart2.update(transition);
|
|
15262
|
-
callback$1(zoomOptions.onZoom, [{ chart: chart2
|
|
15266
|
+
callback$1(zoomOptions.onZoom, [{ chart: chart2 }]);
|
|
15263
15267
|
}
|
|
15264
|
-
function zoomRect(chart2, p0, p1, transition = "none"
|
|
15268
|
+
function zoomRect(chart2, p0, p1, transition = "none") {
|
|
15265
15269
|
const state = getState(chart2);
|
|
15266
15270
|
const { options: { limits, zoom: zoomOptions } } = state;
|
|
15267
15271
|
const { mode = "xy" } = zoomOptions;
|
|
@@ -15276,16 +15280,13 @@ function zoomRect(chart2, p0, p1, transition = "none", trigger = "api") {
|
|
|
15276
15280
|
}
|
|
15277
15281
|
});
|
|
15278
15282
|
chart2.update(transition);
|
|
15279
|
-
callback$1(zoomOptions.onZoom, [{ chart: chart2
|
|
15283
|
+
callback$1(zoomOptions.onZoom, [{ chart: chart2 }]);
|
|
15280
15284
|
}
|
|
15281
|
-
function zoomScale(chart2, scaleId, range, transition = "none"
|
|
15282
|
-
|
|
15283
|
-
const state = getState(chart2);
|
|
15284
|
-
storeOriginalScaleLimits(chart2, state);
|
|
15285
|
+
function zoomScale(chart2, scaleId, range, transition = "none") {
|
|
15286
|
+
storeOriginalScaleLimits(chart2, getState(chart2));
|
|
15285
15287
|
const scale = chart2.scales[scaleId];
|
|
15286
15288
|
updateRange(scale, range, void 0, true);
|
|
15287
15289
|
chart2.update(transition);
|
|
15288
|
-
callback$1((_a2 = state.options.zoom) == null ? void 0 : _a2.onZoom, [{ chart: chart2, trigger }]);
|
|
15289
15290
|
}
|
|
15290
15291
|
function resetZoom(chart2, transition = "default") {
|
|
15291
15292
|
const state = getState(chart2);
|
|
@@ -15299,7 +15300,6 @@ function resetZoom(chart2, transition = "default") {
|
|
|
15299
15300
|
delete scaleOptions.min;
|
|
15300
15301
|
delete scaleOptions.max;
|
|
15301
15302
|
}
|
|
15302
|
-
delete state.updatedScaleLimits[scale.id];
|
|
15303
15303
|
});
|
|
15304
15304
|
chart2.update(transition);
|
|
15305
15305
|
callback$1(state.options.zoom.onZoomComplete, [{ chart: chart2 }]);
|
|
@@ -15367,14 +15367,6 @@ function getInitialScaleBounds(chart2) {
|
|
|
15367
15367
|
}
|
|
15368
15368
|
return scaleBounds;
|
|
15369
15369
|
}
|
|
15370
|
-
function getZoomedScaleBounds(chart2) {
|
|
15371
|
-
const state = getState(chart2);
|
|
15372
|
-
const scaleBounds = {};
|
|
15373
|
-
for (const scaleId of Object.keys(chart2.scales)) {
|
|
15374
|
-
scaleBounds[scaleId] = state.updatedScaleLimits[scaleId];
|
|
15375
|
-
}
|
|
15376
|
-
return scaleBounds;
|
|
15377
|
-
}
|
|
15378
15370
|
function isZoomedOrPanned(chart2) {
|
|
15379
15371
|
const scaleBounds = getInitialScaleBounds(chart2);
|
|
15380
15372
|
for (const scaleId of Object.keys(chart2.scales)) {
|
|
@@ -15388,11 +15380,6 @@ function isZoomedOrPanned(chart2) {
|
|
|
15388
15380
|
}
|
|
15389
15381
|
return false;
|
|
15390
15382
|
}
|
|
15391
|
-
function isZoomingOrPanning(chart2) {
|
|
15392
|
-
const state = getState(chart2);
|
|
15393
|
-
return state.panning || state.dragging;
|
|
15394
|
-
}
|
|
15395
|
-
const clamp$1 = (x2, from2, to2) => Math.min(to2, Math.max(from2, x2));
|
|
15396
15383
|
function removeHandler(chart2, type) {
|
|
15397
15384
|
const { handlers } = getState(chart2);
|
|
15398
15385
|
const handler = handlers[type];
|
|
@@ -15410,8 +15397,7 @@ function addHandler(chart2, target, type, handler) {
|
|
|
15410
15397
|
removeHandler(chart2, type);
|
|
15411
15398
|
handlers[type] = (event) => handler(chart2, event, options);
|
|
15412
15399
|
handlers[type].target = target;
|
|
15413
|
-
|
|
15414
|
-
target.addEventListener(type, handlers[type], { passive });
|
|
15400
|
+
target.addEventListener(type, handlers[type]);
|
|
15415
15401
|
}
|
|
15416
15402
|
function mouseMove(chart2, event) {
|
|
15417
15403
|
const state = getState(chart2);
|
|
@@ -15431,20 +15417,10 @@ function keyDown(chart2, event) {
|
|
|
15431
15417
|
state.dragStart = state.dragEnd = null;
|
|
15432
15418
|
chart2.update("none");
|
|
15433
15419
|
}
|
|
15434
|
-
function getPointPosition(event, chart2) {
|
|
15435
|
-
if (event.target !== chart2.canvas) {
|
|
15436
|
-
const canvasArea = chart2.canvas.getBoundingClientRect();
|
|
15437
|
-
return {
|
|
15438
|
-
x: event.clientX - canvasArea.left,
|
|
15439
|
-
y: event.clientY - canvasArea.top
|
|
15440
|
-
};
|
|
15441
|
-
}
|
|
15442
|
-
return getRelativePosition$2(event, chart2);
|
|
15443
|
-
}
|
|
15444
15420
|
function zoomStart(chart2, event, zoomOptions) {
|
|
15445
15421
|
const { onZoomStart, onZoomRejected } = zoomOptions;
|
|
15446
15422
|
if (onZoomStart) {
|
|
15447
|
-
const point =
|
|
15423
|
+
const point = getRelativePosition$2(event, chart2);
|
|
15448
15424
|
if (callback$1(onZoomStart, [{ chart: chart2, event, point }]) === false) {
|
|
15449
15425
|
callback$1(onZoomRejected, [{ chart: chart2, event }]);
|
|
15450
15426
|
return false;
|
|
@@ -15452,12 +15428,6 @@ function zoomStart(chart2, event, zoomOptions) {
|
|
|
15452
15428
|
}
|
|
15453
15429
|
}
|
|
15454
15430
|
function mouseDown(chart2, event) {
|
|
15455
|
-
if (chart2.legend) {
|
|
15456
|
-
const point = getRelativePosition$2(event, chart2);
|
|
15457
|
-
if (_isPointInArea$1(point, chart2.legend)) {
|
|
15458
|
-
return;
|
|
15459
|
-
}
|
|
15460
|
-
}
|
|
15461
15431
|
const state = getState(chart2);
|
|
15462
15432
|
const { pan: panOptions, zoom: zoomOptions = {} } = state.options;
|
|
15463
15433
|
if (event.button !== 0 || keyPressed(getModifierKey(panOptions), event) || keyNotPressed(getModifierKey(zoomOptions.drag), event)) {
|
|
@@ -15467,52 +15437,30 @@ function mouseDown(chart2, event) {
|
|
|
15467
15437
|
return;
|
|
15468
15438
|
}
|
|
15469
15439
|
state.dragStart = event;
|
|
15470
|
-
addHandler(chart2, chart2.canvas
|
|
15440
|
+
addHandler(chart2, chart2.canvas, "mousemove", mouseMove);
|
|
15471
15441
|
addHandler(chart2, window.document, "keydown", keyDown);
|
|
15472
15442
|
}
|
|
15473
|
-
function
|
|
15474
|
-
let width = end.x - begin.x;
|
|
15475
|
-
let height = end.y - begin.y;
|
|
15476
|
-
const ratio = Math.abs(width / height);
|
|
15477
|
-
if (ratio > aspectRatio) {
|
|
15478
|
-
width = Math.sign(width) * Math.abs(height * aspectRatio);
|
|
15479
|
-
} else if (ratio < aspectRatio) {
|
|
15480
|
-
height = Math.sign(height) * Math.abs(width / aspectRatio);
|
|
15481
|
-
}
|
|
15482
|
-
end.x = begin.x + width;
|
|
15483
|
-
end.y = begin.y + height;
|
|
15484
|
-
}
|
|
15485
|
-
function applyMinMaxProps(rect, chartArea, points, { min, max, prop }) {
|
|
15486
|
-
rect[min] = clamp$1(Math.min(points.begin[prop], points.end[prop]), chartArea[min], chartArea[max]);
|
|
15487
|
-
rect[max] = clamp$1(Math.max(points.begin[prop], points.end[prop]), chartArea[min], chartArea[max]);
|
|
15488
|
-
}
|
|
15489
|
-
function getRelativePoints(chart2, pointEvents, maintainAspectRatio) {
|
|
15490
|
-
const points = {
|
|
15491
|
-
begin: getPointPosition(pointEvents.dragStart, chart2),
|
|
15492
|
-
end: getPointPosition(pointEvents.dragEnd, chart2)
|
|
15493
|
-
};
|
|
15494
|
-
if (maintainAspectRatio) {
|
|
15495
|
-
const aspectRatio = chart2.chartArea.width / chart2.chartArea.height;
|
|
15496
|
-
applyAspectRatio(points, aspectRatio);
|
|
15497
|
-
}
|
|
15498
|
-
return points;
|
|
15499
|
-
}
|
|
15500
|
-
function computeDragRect(chart2, mode, pointEvents, maintainAspectRatio) {
|
|
15443
|
+
function computeDragRect(chart2, mode, beginPointEvent, endPointEvent) {
|
|
15501
15444
|
const xEnabled = directionEnabled(mode, "x", chart2);
|
|
15502
15445
|
const yEnabled = directionEnabled(mode, "y", chart2);
|
|
15503
|
-
|
|
15504
|
-
const
|
|
15505
|
-
const
|
|
15446
|
+
let { top: top2, left: left2, right: right2, bottom: bottom2, width: chartWidth, height: chartHeight } = chart2.chartArea;
|
|
15447
|
+
const beginPoint = getRelativePosition$2(beginPointEvent, chart2);
|
|
15448
|
+
const endPoint = getRelativePosition$2(endPointEvent, chart2);
|
|
15506
15449
|
if (xEnabled) {
|
|
15507
|
-
|
|
15450
|
+
left2 = Math.min(beginPoint.x, endPoint.x);
|
|
15451
|
+
right2 = Math.max(beginPoint.x, endPoint.x);
|
|
15508
15452
|
}
|
|
15509
15453
|
if (yEnabled) {
|
|
15510
|
-
|
|
15454
|
+
top2 = Math.min(beginPoint.y, endPoint.y);
|
|
15455
|
+
bottom2 = Math.max(beginPoint.y, endPoint.y);
|
|
15511
15456
|
}
|
|
15512
|
-
const width =
|
|
15513
|
-
const height =
|
|
15457
|
+
const width = right2 - left2;
|
|
15458
|
+
const height = bottom2 - top2;
|
|
15514
15459
|
return {
|
|
15515
|
-
|
|
15460
|
+
left: left2,
|
|
15461
|
+
top: top2,
|
|
15462
|
+
right: right2,
|
|
15463
|
+
bottom: bottom2,
|
|
15516
15464
|
width,
|
|
15517
15465
|
height,
|
|
15518
15466
|
zoomX: xEnabled && width ? 1 + (chartWidth - width) / chartWidth : 1,
|
|
@@ -15525,8 +15473,8 @@ function mouseUp(chart2, event) {
|
|
|
15525
15473
|
return;
|
|
15526
15474
|
}
|
|
15527
15475
|
removeHandler(chart2, "mousemove");
|
|
15528
|
-
const { mode, onZoomComplete, drag: { threshold = 0
|
|
15529
|
-
const rect = computeDragRect(chart2, mode,
|
|
15476
|
+
const { mode, onZoomComplete, drag: { threshold = 0 } } = state.options.zoom;
|
|
15477
|
+
const rect = computeDragRect(chart2, mode, state.dragStart, event);
|
|
15530
15478
|
const distanceX = directionEnabled(mode, "x", chart2) ? rect.width : 0;
|
|
15531
15479
|
const distanceY = directionEnabled(mode, "y", chart2) ? rect.height : 0;
|
|
15532
15480
|
const distance = Math.sqrt(distanceX * distanceX + distanceY * distanceY);
|
|
@@ -15536,9 +15484,8 @@ function mouseUp(chart2, event) {
|
|
|
15536
15484
|
chart2.update("none");
|
|
15537
15485
|
return;
|
|
15538
15486
|
}
|
|
15539
|
-
zoomRect(chart2, { x: rect.left, y: rect.top }, { x: rect.right, y: rect.bottom }, "zoom"
|
|
15540
|
-
state.dragging = false;
|
|
15541
|
-
state.filterNextClick = true;
|
|
15487
|
+
zoomRect(chart2, { x: rect.left, y: rect.top }, { x: rect.right, y: rect.bottom }, "zoom");
|
|
15488
|
+
setTimeout(() => state.dragging = false, 500);
|
|
15542
15489
|
callback$1(onZoomComplete, [{ chart: chart2 }]);
|
|
15543
15490
|
}
|
|
15544
15491
|
function wheelPreconditions(chart2, event, zoomOptions) {
|
|
@@ -15563,18 +15510,19 @@ function wheel(chart2, event) {
|
|
|
15563
15510
|
return;
|
|
15564
15511
|
}
|
|
15565
15512
|
const rect = event.target.getBoundingClientRect();
|
|
15566
|
-
const speed = zoomOptions.wheel.speed;
|
|
15567
|
-
const percentage = event.deltaY >= 0 ? 2 - 1 / (1 - speed) : 1 + speed;
|
|
15513
|
+
const speed = 1 + (event.deltaY >= 0 ? -zoomOptions.wheel.speed : zoomOptions.wheel.speed);
|
|
15568
15514
|
const amount = {
|
|
15569
|
-
x:
|
|
15570
|
-
y:
|
|
15515
|
+
x: speed,
|
|
15516
|
+
y: speed,
|
|
15571
15517
|
focalPoint: {
|
|
15572
15518
|
x: event.clientX - rect.left,
|
|
15573
15519
|
y: event.clientY - rect.top
|
|
15574
15520
|
}
|
|
15575
15521
|
};
|
|
15576
|
-
zoom(chart2, amount
|
|
15577
|
-
|
|
15522
|
+
zoom(chart2, amount);
|
|
15523
|
+
if (onZoomComplete) {
|
|
15524
|
+
onZoomComplete();
|
|
15525
|
+
}
|
|
15578
15526
|
}
|
|
15579
15527
|
function addDebouncedHandler(chart2, name, handler, delay) {
|
|
15580
15528
|
if (handler) {
|
|
@@ -15654,19 +15602,13 @@ function handlePinch(chart2, state, e2) {
|
|
|
15654
15602
|
y: center.y - rect.top
|
|
15655
15603
|
}
|
|
15656
15604
|
};
|
|
15657
|
-
zoom(chart2, amount
|
|
15605
|
+
zoom(chart2, amount);
|
|
15658
15606
|
state.scale = e2.scale;
|
|
15659
15607
|
}
|
|
15660
15608
|
}
|
|
15661
|
-
function startPinch(chart2, state
|
|
15609
|
+
function startPinch(chart2, state) {
|
|
15662
15610
|
if (state.options.zoom.pinch.enabled) {
|
|
15663
|
-
|
|
15664
|
-
if (callback$1(state.options.zoom.onZoomStart, [{ chart: chart2, event, point }]) === false) {
|
|
15665
|
-
state.scale = null;
|
|
15666
|
-
callback$1(state.options.zoom.onZoomRejected, [{ chart: chart2, event }]);
|
|
15667
|
-
} else {
|
|
15668
|
-
state.scale = 1;
|
|
15669
|
-
}
|
|
15611
|
+
state.scale = 1;
|
|
15670
15612
|
}
|
|
15671
15613
|
}
|
|
15672
15614
|
function endPinch(chart2, state, e2) {
|
|
@@ -15699,13 +15641,13 @@ function startPan(chart2, state, event) {
|
|
|
15699
15641
|
}
|
|
15700
15642
|
state.panScales = getEnabledScalesByPoint(state.options.pan, point, chart2);
|
|
15701
15643
|
state.delta = { x: 0, y: 0 };
|
|
15644
|
+
clearTimeout(state.panEndTimeout);
|
|
15702
15645
|
handlePan(chart2, state, event);
|
|
15703
15646
|
}
|
|
15704
15647
|
function endPan(chart2, state) {
|
|
15705
15648
|
state.delta = null;
|
|
15706
15649
|
if (state.panning) {
|
|
15707
|
-
state.panning = false;
|
|
15708
|
-
state.filterNextClick = true;
|
|
15650
|
+
state.panEndTimeout = setTimeout(() => state.panning = false, 500);
|
|
15709
15651
|
callback$1(state.options.pan.onPanComplete, [{ chart: chart2 }]);
|
|
15710
15652
|
}
|
|
15711
15653
|
}
|
|
@@ -15717,7 +15659,7 @@ function startHammer(chart2, options) {
|
|
|
15717
15659
|
const mc = new Hammer.Manager(canvas2);
|
|
15718
15660
|
if (zoomOptions && zoomOptions.pinch.enabled) {
|
|
15719
15661
|
mc.add(new Hammer.Pinch());
|
|
15720
|
-
mc.on("pinchstart", (
|
|
15662
|
+
mc.on("pinchstart", () => startPinch(chart2, state));
|
|
15721
15663
|
mc.on("pinch", (e2) => handlePinch(chart2, state, e2));
|
|
15722
15664
|
mc.on("pinchend", (e2) => endPinch(chart2, state, e2));
|
|
15723
15665
|
}
|
|
@@ -15745,29 +15687,14 @@ function stopHammer(chart2) {
|
|
|
15745
15687
|
hammers.delete(chart2);
|
|
15746
15688
|
}
|
|
15747
15689
|
}
|
|
15748
|
-
|
|
15749
|
-
var _a2, _b2, _c2, _d2;
|
|
15750
|
-
const { pan: oldPan, zoom: oldZoom } = oldOptions;
|
|
15751
|
-
const { pan: newPan, zoom: newZoom } = newOptions;
|
|
15752
|
-
if (((_b2 = (_a2 = oldZoom == null ? void 0 : oldZoom.zoom) == null ? void 0 : _a2.pinch) == null ? void 0 : _b2.enabled) !== ((_d2 = (_c2 = newZoom == null ? void 0 : newZoom.zoom) == null ? void 0 : _c2.pinch) == null ? void 0 : _d2.enabled)) {
|
|
15753
|
-
return true;
|
|
15754
|
-
}
|
|
15755
|
-
if ((oldPan == null ? void 0 : oldPan.enabled) !== (newPan == null ? void 0 : newPan.enabled)) {
|
|
15756
|
-
return true;
|
|
15757
|
-
}
|
|
15758
|
-
if ((oldPan == null ? void 0 : oldPan.threshold) !== (newPan == null ? void 0 : newPan.threshold)) {
|
|
15759
|
-
return true;
|
|
15760
|
-
}
|
|
15761
|
-
return false;
|
|
15762
|
-
}
|
|
15763
|
-
var version$2 = "2.2.0";
|
|
15690
|
+
var version$2 = "2.0.1";
|
|
15764
15691
|
function draw$2(chart2, caller, options) {
|
|
15765
15692
|
const dragOptions = options.zoom.drag;
|
|
15766
15693
|
const { dragStart, dragEnd } = getState(chart2);
|
|
15767
15694
|
if (dragOptions.drawTime !== caller || !dragEnd) {
|
|
15768
15695
|
return;
|
|
15769
15696
|
}
|
|
15770
|
-
const { left: left2, top: top2, width, height } = computeDragRect(chart2, options.zoom.mode,
|
|
15697
|
+
const { left: left2, top: top2, width, height } = computeDragRect(chart2, options.zoom.mode, dragStart, dragEnd);
|
|
15771
15698
|
const ctx = chart2.ctx;
|
|
15772
15699
|
ctx.save();
|
|
15773
15700
|
ctx.beginPath();
|
|
@@ -15826,30 +15753,17 @@ var plugin$1 = {
|
|
|
15826
15753
|
chart2.resetZoom = (transition) => resetZoom(chart2, transition);
|
|
15827
15754
|
chart2.getZoomLevel = () => getZoomLevel(chart2);
|
|
15828
15755
|
chart2.getInitialScaleBounds = () => getInitialScaleBounds(chart2);
|
|
15829
|
-
chart2.getZoomedScaleBounds = () => getZoomedScaleBounds(chart2);
|
|
15830
15756
|
chart2.isZoomedOrPanned = () => isZoomedOrPanned(chart2);
|
|
15831
|
-
chart2.isZoomingOrPanning = () => isZoomingOrPanning(chart2);
|
|
15832
15757
|
},
|
|
15833
|
-
beforeEvent(chart2
|
|
15834
|
-
|
|
15758
|
+
beforeEvent(chart2) {
|
|
15759
|
+
const state = getState(chart2);
|
|
15760
|
+
if (state.panning || state.dragging) {
|
|
15835
15761
|
return false;
|
|
15836
15762
|
}
|
|
15837
|
-
if (event.type === "click" || event.type === "mouseup") {
|
|
15838
|
-
const state = getState(chart2);
|
|
15839
|
-
if (state.filterNextClick) {
|
|
15840
|
-
state.filterNextClick = false;
|
|
15841
|
-
return false;
|
|
15842
|
-
}
|
|
15843
|
-
}
|
|
15844
15763
|
},
|
|
15845
15764
|
beforeUpdate: function(chart2, args, options) {
|
|
15846
15765
|
const state = getState(chart2);
|
|
15847
|
-
const previousOptions = state.options;
|
|
15848
15766
|
state.options = options;
|
|
15849
|
-
if (hammerOptionsChanged(previousOptions, options)) {
|
|
15850
|
-
stopHammer(chart2);
|
|
15851
|
-
startHammer(chart2, options);
|
|
15852
|
-
}
|
|
15853
15767
|
addListeners(chart2, options);
|
|
15854
15768
|
},
|
|
15855
15769
|
beforeDatasetsDraw(chart2, _args, options) {
|
|
@@ -17363,6 +17277,7 @@ function drawPointStyle(ctx, { x: x2, y: y2, radius, rotation, style, rad }) {
|
|
|
17363
17277
|
let xOffset, yOffset, size, cornerRadius;
|
|
17364
17278
|
ctx.beginPath();
|
|
17365
17279
|
switch (style) {
|
|
17280
|
+
// Default includes circle
|
|
17366
17281
|
default:
|
|
17367
17282
|
ctx.arc(x2, y2, radius, 0, TAU$1);
|
|
17368
17283
|
ctx.closePath();
|
|
@@ -17393,6 +17308,7 @@ function drawPointStyle(ctx, { x: x2, y: y2, radius, rotation, style, rad }) {
|
|
|
17393
17308
|
break;
|
|
17394
17309
|
}
|
|
17395
17310
|
rad += QUARTER_PI$1;
|
|
17311
|
+
/* falls through */
|
|
17396
17312
|
case "rectRot":
|
|
17397
17313
|
xOffset = Math.cos(rad) * radius;
|
|
17398
17314
|
yOffset = Math.sin(rad) * radius;
|
|
@@ -17404,6 +17320,7 @@ function drawPointStyle(ctx, { x: x2, y: y2, radius, rotation, style, rad }) {
|
|
|
17404
17320
|
break;
|
|
17405
17321
|
case "crossRot":
|
|
17406
17322
|
rad += QUARTER_PI$1;
|
|
17323
|
+
/* falls through */
|
|
17407
17324
|
case "cross":
|
|
17408
17325
|
xOffset = Math.cos(rad) * radius;
|
|
17409
17326
|
yOffset = Math.sin(rad) * radius;
|
|
@@ -20784,35 +20701,43 @@ function createSingletonDndContext(backend, context = getGlobalContext(), option
|
|
|
20784
20701
|
function getGlobalContext() {
|
|
20785
20702
|
return typeof global !== "undefined" ? global : window;
|
|
20786
20703
|
}
|
|
20787
|
-
var fastDeepEqual
|
|
20788
|
-
|
|
20789
|
-
|
|
20790
|
-
|
|
20791
|
-
|
|
20792
|
-
|
|
20793
|
-
|
|
20794
|
-
|
|
20704
|
+
var fastDeepEqual;
|
|
20705
|
+
var hasRequiredFastDeepEqual;
|
|
20706
|
+
function requireFastDeepEqual() {
|
|
20707
|
+
if (hasRequiredFastDeepEqual) return fastDeepEqual;
|
|
20708
|
+
hasRequiredFastDeepEqual = 1;
|
|
20709
|
+
fastDeepEqual = function equal(a2, b2) {
|
|
20710
|
+
if (a2 === b2) return true;
|
|
20711
|
+
if (a2 && b2 && typeof a2 == "object" && typeof b2 == "object") {
|
|
20712
|
+
if (a2.constructor !== b2.constructor) return false;
|
|
20713
|
+
var length, i2, keys;
|
|
20714
|
+
if (Array.isArray(a2)) {
|
|
20715
|
+
length = a2.length;
|
|
20716
|
+
if (length != b2.length) return false;
|
|
20717
|
+
for (i2 = length; i2-- !== 0; )
|
|
20718
|
+
if (!equal(a2[i2], b2[i2])) return false;
|
|
20719
|
+
return true;
|
|
20720
|
+
}
|
|
20721
|
+
if (a2.constructor === RegExp) return a2.source === b2.source && a2.flags === b2.flags;
|
|
20722
|
+
if (a2.valueOf !== Object.prototype.valueOf) return a2.valueOf() === b2.valueOf();
|
|
20723
|
+
if (a2.toString !== Object.prototype.toString) return a2.toString() === b2.toString();
|
|
20724
|
+
keys = Object.keys(a2);
|
|
20725
|
+
length = keys.length;
|
|
20726
|
+
if (length !== Object.keys(b2).length) return false;
|
|
20795
20727
|
for (i2 = length; i2-- !== 0; )
|
|
20796
|
-
if (!
|
|
20728
|
+
if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
|
|
20729
|
+
for (i2 = length; i2-- !== 0; ) {
|
|
20730
|
+
var key = keys[i2];
|
|
20731
|
+
if (!equal(a2[key], b2[key])) return false;
|
|
20732
|
+
}
|
|
20797
20733
|
return true;
|
|
20798
20734
|
}
|
|
20799
|
-
|
|
20800
|
-
|
|
20801
|
-
|
|
20802
|
-
|
|
20803
|
-
|
|
20804
|
-
|
|
20805
|
-
for (i2 = length; i2-- !== 0; )
|
|
20806
|
-
if (!Object.prototype.hasOwnProperty.call(b2, keys[i2])) return false;
|
|
20807
|
-
for (i2 = length; i2-- !== 0; ) {
|
|
20808
|
-
var key = keys[i2];
|
|
20809
|
-
if (!equal(a2[key], b2[key])) return false;
|
|
20810
|
-
}
|
|
20811
|
-
return true;
|
|
20812
|
-
}
|
|
20813
|
-
return a2 !== a2 && b2 !== b2;
|
|
20814
|
-
};
|
|
20815
|
-
const isEqual = /* @__PURE__ */ getDefaultExportFromCjs(fastDeepEqual);
|
|
20735
|
+
return a2 !== a2 && b2 !== b2;
|
|
20736
|
+
};
|
|
20737
|
+
return fastDeepEqual;
|
|
20738
|
+
}
|
|
20739
|
+
var fastDeepEqualExports = requireFastDeepEqual();
|
|
20740
|
+
const isEqual = /* @__PURE__ */ getDefaultExportFromCjs(fastDeepEqualExports);
|
|
20816
20741
|
const useIsomorphicLayoutEffect$1 = typeof window !== "undefined" ? useLayoutEffect : useEffect;
|
|
20817
20742
|
function useCollector(monitor, collect, onUpdate) {
|
|
20818
20743
|
const [collected, setCollected] = useState(
|
|
@@ -23500,6 +23425,18 @@ function toArray(arrayLike) {
|
|
|
23500
23425
|
}
|
|
23501
23426
|
return arr;
|
|
23502
23427
|
}
|
|
23428
|
+
let styleProps = null;
|
|
23429
|
+
function getStyleProperties(options = {}) {
|
|
23430
|
+
if (styleProps) {
|
|
23431
|
+
return styleProps;
|
|
23432
|
+
}
|
|
23433
|
+
if (options.includeStyleProperties) {
|
|
23434
|
+
styleProps = options.includeStyleProperties;
|
|
23435
|
+
return styleProps;
|
|
23436
|
+
}
|
|
23437
|
+
styleProps = toArray(window.getComputedStyle(document.documentElement));
|
|
23438
|
+
return styleProps;
|
|
23439
|
+
}
|
|
23503
23440
|
function px(node, styleProperty) {
|
|
23504
23441
|
const win = node.ownerDocument.defaultView || window;
|
|
23505
23442
|
const val = win.getComputedStyle(node).getPropertyValue(styleProperty);
|
|
@@ -23601,19 +23538,19 @@ function formatCSSText(style) {
|
|
|
23601
23538
|
const content = style.getPropertyValue("content");
|
|
23602
23539
|
return `${style.cssText} content: '${content.replace(/'|"/g, "")}';`;
|
|
23603
23540
|
}
|
|
23604
|
-
function formatCSSProperties(style) {
|
|
23605
|
-
return
|
|
23541
|
+
function formatCSSProperties(style, options) {
|
|
23542
|
+
return getStyleProperties(options).map((name) => {
|
|
23606
23543
|
const value = style.getPropertyValue(name);
|
|
23607
23544
|
const priority = style.getPropertyPriority(name);
|
|
23608
23545
|
return `${name}: ${value}${priority ? " !important" : ""};`;
|
|
23609
23546
|
}).join(" ");
|
|
23610
23547
|
}
|
|
23611
|
-
function getPseudoElementStyle(className, pseudo, style) {
|
|
23548
|
+
function getPseudoElementStyle(className, pseudo, style, options) {
|
|
23612
23549
|
const selector = `.${className}:${pseudo}`;
|
|
23613
|
-
const cssText = style.cssText ? formatCSSText(style) : formatCSSProperties(style);
|
|
23550
|
+
const cssText = style.cssText ? formatCSSText(style) : formatCSSProperties(style, options);
|
|
23614
23551
|
return document.createTextNode(`${selector}{${cssText}}`);
|
|
23615
23552
|
}
|
|
23616
|
-
function clonePseudoElement(nativeNode, clonedNode, pseudo) {
|
|
23553
|
+
function clonePseudoElement(nativeNode, clonedNode, pseudo, options) {
|
|
23617
23554
|
const style = window.getComputedStyle(nativeNode, pseudo);
|
|
23618
23555
|
const content = style.getPropertyValue("content");
|
|
23619
23556
|
if (content === "" || content === "none") {
|
|
@@ -23626,12 +23563,12 @@ function clonePseudoElement(nativeNode, clonedNode, pseudo) {
|
|
|
23626
23563
|
return;
|
|
23627
23564
|
}
|
|
23628
23565
|
const styleElement = document.createElement("style");
|
|
23629
|
-
styleElement.appendChild(getPseudoElementStyle(className, pseudo, style));
|
|
23566
|
+
styleElement.appendChild(getPseudoElementStyle(className, pseudo, style, options));
|
|
23630
23567
|
clonedNode.appendChild(styleElement);
|
|
23631
23568
|
}
|
|
23632
|
-
function clonePseudoElements(nativeNode, clonedNode) {
|
|
23633
|
-
clonePseudoElement(nativeNode, clonedNode, ":before");
|
|
23634
|
-
clonePseudoElement(nativeNode, clonedNode, ":after");
|
|
23569
|
+
function clonePseudoElements(nativeNode, clonedNode, options) {
|
|
23570
|
+
clonePseudoElement(nativeNode, clonedNode, ":before", options);
|
|
23571
|
+
clonePseudoElement(nativeNode, clonedNode, ":after", options);
|
|
23635
23572
|
}
|
|
23636
23573
|
const WOFF = "application/font-woff";
|
|
23637
23574
|
const JPEG = "image/jpeg";
|
|
@@ -23747,11 +23684,11 @@ async function cloneVideoElement(video, options) {
|
|
|
23747
23684
|
const dataURL = await resourceToDataURL(poster, contentType, options);
|
|
23748
23685
|
return createImage(dataURL);
|
|
23749
23686
|
}
|
|
23750
|
-
async function cloneIFrameElement(iframe) {
|
|
23687
|
+
async function cloneIFrameElement(iframe, options) {
|
|
23751
23688
|
var _a2;
|
|
23752
23689
|
try {
|
|
23753
23690
|
if ((_a2 = iframe === null || iframe === void 0 ? void 0 : iframe.contentDocument) === null || _a2 === void 0 ? void 0 : _a2.body) {
|
|
23754
|
-
return await cloneNode(iframe.contentDocument.body,
|
|
23691
|
+
return await cloneNode(iframe.contentDocument.body, options, true);
|
|
23755
23692
|
}
|
|
23756
23693
|
} catch (_b2) {
|
|
23757
23694
|
}
|
|
@@ -23765,7 +23702,7 @@ async function cloneSingleNode(node, options) {
|
|
|
23765
23702
|
return cloneVideoElement(node, options);
|
|
23766
23703
|
}
|
|
23767
23704
|
if (isInstanceOfElement(node, HTMLIFrameElement)) {
|
|
23768
|
-
return cloneIFrameElement(node);
|
|
23705
|
+
return cloneIFrameElement(node, options);
|
|
23769
23706
|
}
|
|
23770
23707
|
return node.cloneNode(isSVGElement(node));
|
|
23771
23708
|
}
|
|
@@ -23794,7 +23731,7 @@ async function cloneChildren(nativeNode, clonedNode, options) {
|
|
|
23794
23731
|
}), Promise.resolve());
|
|
23795
23732
|
return clonedNode;
|
|
23796
23733
|
}
|
|
23797
|
-
function cloneCSSStyle(nativeNode, clonedNode) {
|
|
23734
|
+
function cloneCSSStyle(nativeNode, clonedNode, options) {
|
|
23798
23735
|
const targetStyle = clonedNode.style;
|
|
23799
23736
|
if (!targetStyle) {
|
|
23800
23737
|
return;
|
|
@@ -23804,7 +23741,7 @@ function cloneCSSStyle(nativeNode, clonedNode) {
|
|
|
23804
23741
|
targetStyle.cssText = sourceStyle.cssText;
|
|
23805
23742
|
targetStyle.transformOrigin = sourceStyle.transformOrigin;
|
|
23806
23743
|
} else {
|
|
23807
|
-
|
|
23744
|
+
getStyleProperties(options).forEach((name) => {
|
|
23808
23745
|
let value = sourceStyle.getPropertyValue(name);
|
|
23809
23746
|
if (name === "font-size" && value.endsWith("px")) {
|
|
23810
23747
|
const reducedFont = Math.floor(parseFloat(value.substring(0, value.length - 2))) - 0.1;
|
|
@@ -23837,10 +23774,10 @@ function cloneSelectValue(nativeNode, clonedNode) {
|
|
|
23837
23774
|
}
|
|
23838
23775
|
}
|
|
23839
23776
|
}
|
|
23840
|
-
function decorate(nativeNode, clonedNode) {
|
|
23777
|
+
function decorate(nativeNode, clonedNode, options) {
|
|
23841
23778
|
if (isInstanceOfElement(clonedNode, Element)) {
|
|
23842
|
-
cloneCSSStyle(nativeNode, clonedNode);
|
|
23843
|
-
clonePseudoElements(nativeNode, clonedNode);
|
|
23779
|
+
cloneCSSStyle(nativeNode, clonedNode, options);
|
|
23780
|
+
clonePseudoElements(nativeNode, clonedNode, options);
|
|
23844
23781
|
cloneInputValue(nativeNode, clonedNode);
|
|
23845
23782
|
cloneSelectValue(nativeNode, clonedNode);
|
|
23846
23783
|
}
|
|
@@ -23886,7 +23823,7 @@ async function cloneNode(node, options, isRoot) {
|
|
|
23886
23823
|
if (!isRoot && options.filter && !options.filter(node)) {
|
|
23887
23824
|
return null;
|
|
23888
23825
|
}
|
|
23889
|
-
return Promise.resolve(node).then((clonedNode) => cloneSingleNode(clonedNode, options)).then((clonedNode) => cloneChildren(node, clonedNode, options)).then((clonedNode) => decorate(node, clonedNode)).then((clonedNode) => ensureSVGSymbols(clonedNode, options));
|
|
23826
|
+
return Promise.resolve(node).then((clonedNode) => cloneSingleNode(clonedNode, options)).then((clonedNode) => cloneChildren(node, clonedNode, options)).then((clonedNode) => decorate(node, clonedNode, options)).then((clonedNode) => ensureSVGSymbols(clonedNode, options));
|
|
23890
23827
|
}
|
|
23891
23828
|
const URL_REGEX = /url\((['"]?)([^'"]+?)\1\)/g;
|
|
23892
23829
|
const URL_WITH_FORMAT_REGEX = /url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g;
|
|
@@ -23952,12 +23889,8 @@ async function embedProp(propName, node, options) {
|
|
|
23952
23889
|
return false;
|
|
23953
23890
|
}
|
|
23954
23891
|
async function embedBackground(clonedNode, options) {
|
|
23955
|
-
|
|
23956
|
-
|
|
23957
|
-
}
|
|
23958
|
-
if (!await embedProp("mask", clonedNode, options)) {
|
|
23959
|
-
await embedProp("mask-image", clonedNode, options);
|
|
23960
|
-
}
|
|
23892
|
+
await embedProp("background", clonedNode, options) || await embedProp("background-image", clonedNode, options);
|
|
23893
|
+
await embedProp("mask", clonedNode, options) || await embedProp("-webkit-mask", clonedNode, options) || await embedProp("mask-image", clonedNode, options) || await embedProp("-webkit-mask-image", clonedNode, options);
|
|
23961
23894
|
}
|
|
23962
23895
|
async function embedImageNode(clonedNode, options) {
|
|
23963
23896
|
const isImageElement = isInstanceOfElement(clonedNode, HTMLImageElement);
|
|
@@ -24113,7 +24046,7 @@ async function getCSSRules(styleSheets, options) {
|
|
|
24113
24046
|
const inline = styleSheets.find((a2) => a2.href == null) || document.styleSheets[0];
|
|
24114
24047
|
if (sheet.href != null) {
|
|
24115
24048
|
deferreds.push(fetchCSS(sheet.href).then((metadata) => embedFonts(metadata, options)).then((cssText) => parseCSS(cssText).forEach((rule) => {
|
|
24116
|
-
inline.insertRule(rule,
|
|
24049
|
+
inline.insertRule(rule, inline.cssRules.length);
|
|
24117
24050
|
})).catch((err) => {
|
|
24118
24051
|
console.error("Error loading remote stylesheet", err);
|
|
24119
24052
|
}));
|
|
@@ -24226,200 +24159,206 @@ async function toPng(node, options = {}) {
|
|
|
24226
24159
|
return canvas2.toDataURL();
|
|
24227
24160
|
}
|
|
24228
24161
|
var dist = { exports: {} };
|
|
24229
|
-
|
|
24230
|
-
|
|
24231
|
-
|
|
24232
|
-
|
|
24233
|
-
|
|
24234
|
-
|
|
24235
|
-
|
|
24236
|
-
|
|
24237
|
-
|
|
24238
|
-
|
|
24239
|
-
|
|
24240
|
-
|
|
24241
|
-
|
|
24242
|
-
|
|
24243
|
-
|
|
24244
|
-
|
|
24245
|
-
|
|
24246
|
-
|
|
24247
|
-
|
|
24248
|
-
|
|
24249
|
-
return e4
|
|
24250
|
-
|
|
24251
|
-
|
|
24252
|
-
|
|
24253
|
-
|
|
24254
|
-
|
|
24255
|
-
|
|
24256
|
-
|
|
24257
|
-
|
|
24258
|
-
|
|
24259
|
-
|
|
24260
|
-
|
|
24261
|
-
|
|
24262
|
-
|
|
24263
|
-
|
|
24264
|
-
|
|
24265
|
-
|
|
24266
|
-
|
|
24267
|
-
|
|
24162
|
+
var hasRequiredDist;
|
|
24163
|
+
function requireDist() {
|
|
24164
|
+
if (hasRequiredDist) return dist.exports;
|
|
24165
|
+
hasRequiredDist = 1;
|
|
24166
|
+
(function(module, exports) {
|
|
24167
|
+
!function(e2, t) {
|
|
24168
|
+
module.exports = t(React__default);
|
|
24169
|
+
}(window, function(e2) {
|
|
24170
|
+
return function(e3) {
|
|
24171
|
+
var t = {};
|
|
24172
|
+
function n2(o2) {
|
|
24173
|
+
if (t[o2]) return t[o2].exports;
|
|
24174
|
+
var r2 = t[o2] = { i: o2, l: false, exports: {} };
|
|
24175
|
+
return e3[o2].call(r2.exports, r2, r2.exports, n2), r2.l = true, r2.exports;
|
|
24176
|
+
}
|
|
24177
|
+
return n2.m = e3, n2.c = t, n2.d = function(e4, t2, o2) {
|
|
24178
|
+
n2.o(e4, t2) || Object.defineProperty(e4, t2, { enumerable: true, get: o2 });
|
|
24179
|
+
}, n2.r = function(e4) {
|
|
24180
|
+
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e4, Symbol.toStringTag, { value: "Module" }), Object.defineProperty(e4, "__esModule", { value: true });
|
|
24181
|
+
}, n2.t = function(e4, t2) {
|
|
24182
|
+
if (1 & t2 && (e4 = n2(e4)), 8 & t2) return e4;
|
|
24183
|
+
if (4 & t2 && "object" == typeof e4 && e4 && e4.__esModule) return e4;
|
|
24184
|
+
var o2 = /* @__PURE__ */ Object.create(null);
|
|
24185
|
+
if (n2.r(o2), Object.defineProperty(o2, "default", { enumerable: true, value: e4 }), 2 & t2 && "string" != typeof e4) for (var r2 in e4) n2.d(o2, r2, (function(t3) {
|
|
24186
|
+
return e4[t3];
|
|
24187
|
+
}).bind(null, r2));
|
|
24188
|
+
return o2;
|
|
24189
|
+
}, n2.n = function(e4) {
|
|
24190
|
+
var t2 = e4 && e4.__esModule ? function() {
|
|
24191
|
+
return e4.default;
|
|
24192
|
+
} : function() {
|
|
24193
|
+
return e4;
|
|
24194
|
+
};
|
|
24195
|
+
return n2.d(t2, "a", t2), t2;
|
|
24196
|
+
}, n2.o = function(e4, t2) {
|
|
24197
|
+
return Object.prototype.hasOwnProperty.call(e4, t2);
|
|
24198
|
+
}, n2.p = "/dist/", n2(n2.s = 4);
|
|
24199
|
+
}([function(e3, t, n2) {
|
|
24200
|
+
e3.exports = n2(5)();
|
|
24201
|
+
}, function(t, n2) {
|
|
24202
|
+
t.exports = e2;
|
|
24203
|
+
}, function(e3, t, n2) {
|
|
24204
|
+
(function(n3) {
|
|
24205
|
+
var o2, r2, a2;
|
|
24206
|
+
r2 = [], void 0 === (a2 = "function" == typeof (o2 = function() {
|
|
24207
|
+
function t2(e4, t3, n4) {
|
|
24208
|
+
var o4 = new XMLHttpRequest();
|
|
24209
|
+
o4.open("GET", e4), o4.responseType = "blob", o4.onload = function() {
|
|
24210
|
+
c2(o4.response, t3, n4);
|
|
24211
|
+
}, o4.onerror = function() {
|
|
24212
|
+
console.error("could not download file");
|
|
24213
|
+
}, o4.send();
|
|
24214
|
+
}
|
|
24215
|
+
function o3(e4) {
|
|
24216
|
+
var t3 = new XMLHttpRequest();
|
|
24217
|
+
t3.open("HEAD", e4, false);
|
|
24218
|
+
try {
|
|
24219
|
+
t3.send();
|
|
24220
|
+
} catch (e5) {
|
|
24221
|
+
}
|
|
24222
|
+
return 200 <= t3.status && 299 >= t3.status;
|
|
24223
|
+
}
|
|
24224
|
+
function r3(e4) {
|
|
24225
|
+
try {
|
|
24226
|
+
e4.dispatchEvent(new MouseEvent("click"));
|
|
24227
|
+
} catch (n4) {
|
|
24228
|
+
var t3 = document.createEvent("MouseEvents");
|
|
24229
|
+
t3.initMouseEvent("click", true, true, window, 0, 0, 0, 80, 20, false, false, false, false, 0, null), e4.dispatchEvent(t3);
|
|
24230
|
+
}
|
|
24231
|
+
}
|
|
24232
|
+
var a3 = "object" == typeof window && window.window === window ? window : "object" == typeof self && self.self === self ? self : "object" == typeof n3 && n3.global === n3 ? n3 : void 0, i2 = a3.navigator && /Macintosh/.test(navigator.userAgent) && /AppleWebKit/.test(navigator.userAgent) && !/Safari/.test(navigator.userAgent), c2 = a3.saveAs || ("object" != typeof window || window !== a3 ? function() {
|
|
24233
|
+
} : "download" in HTMLAnchorElement.prototype && !i2 ? function(e4, n4, i3) {
|
|
24234
|
+
var c3 = a3.URL || a3.webkitURL, s2 = document.createElement("a");
|
|
24235
|
+
n4 = n4 || e4.name || "download", s2.download = n4, s2.rel = "noopener", "string" == typeof e4 ? (s2.href = e4, s2.origin === location.origin ? r3(s2) : o3(s2.href) ? t2(e4, n4, i3) : r3(s2, s2.target = "_blank")) : (s2.href = c3.createObjectURL(e4), setTimeout(function() {
|
|
24236
|
+
c3.revokeObjectURL(s2.href);
|
|
24237
|
+
}, 4e4), setTimeout(function() {
|
|
24238
|
+
r3(s2);
|
|
24239
|
+
}, 0));
|
|
24240
|
+
} : "msSaveOrOpenBlob" in navigator ? function(e4, n4, a4) {
|
|
24241
|
+
if (n4 = n4 || e4.name || "download", "string" != typeof e4) navigator.msSaveOrOpenBlob(function(e5, t3) {
|
|
24242
|
+
return void 0 === t3 ? t3 = { autoBom: false } : "object" != typeof t3 && (console.warn("Deprecated: Expected third argument to be a object"), t3 = { autoBom: !t3 }), t3.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e5.type) ? new Blob(["\uFEFF", e5], { type: e5.type }) : e5;
|
|
24243
|
+
}(e4, a4), n4);
|
|
24244
|
+
else if (o3(e4)) t2(e4, n4, a4);
|
|
24245
|
+
else {
|
|
24246
|
+
var i3 = document.createElement("a");
|
|
24247
|
+
i3.href = e4, i3.target = "_blank", setTimeout(function() {
|
|
24248
|
+
r3(i3);
|
|
24249
|
+
});
|
|
24250
|
+
}
|
|
24251
|
+
} : function(e4, n4, o4, r4) {
|
|
24252
|
+
if ((r4 = r4 || open("", "_blank")) && (r4.document.title = r4.document.body.innerText = "downloading..."), "string" == typeof e4) return t2(e4, n4, o4);
|
|
24253
|
+
var c3 = "application/octet-stream" === e4.type, s2 = /constructor/i.test(a3.HTMLElement) || a3.safari, u2 = /CriOS\/[\d]+/.test(navigator.userAgent);
|
|
24254
|
+
if ((u2 || c3 && s2 || i2) && "undefined" != typeof FileReader) {
|
|
24255
|
+
var l2 = new FileReader();
|
|
24256
|
+
l2.onloadend = function() {
|
|
24257
|
+
var e5 = l2.result;
|
|
24258
|
+
e5 = u2 ? e5 : e5.replace(/^data:[^;]*;/, "data:attachment/file;"), r4 ? r4.location.href = e5 : location = e5, r4 = null;
|
|
24259
|
+
}, l2.readAsDataURL(e4);
|
|
24260
|
+
} else {
|
|
24261
|
+
var f2 = a3.URL || a3.webkitURL, p2 = f2.createObjectURL(e4);
|
|
24262
|
+
r4 ? r4.location = p2 : location.href = p2, r4 = null, setTimeout(function() {
|
|
24263
|
+
f2.revokeObjectURL(p2);
|
|
24264
|
+
}, 4e4);
|
|
24265
|
+
}
|
|
24266
|
+
});
|
|
24267
|
+
a3.saveAs = c2.saveAs = c2, e3.exports = c2;
|
|
24268
|
+
}) ? o2.apply(t, r2) : o2) || (e3.exports = a2);
|
|
24269
|
+
}).call(this, n2(7));
|
|
24270
|
+
}, function(e3, t, n2) {
|
|
24268
24271
|
var o2, r2, a2;
|
|
24269
24272
|
r2 = [], void 0 === (a2 = "function" == typeof (o2 = function() {
|
|
24270
|
-
function
|
|
24271
|
-
|
|
24272
|
-
|
|
24273
|
-
|
|
24274
|
-
|
|
24275
|
-
|
|
24276
|
-
}
|
|
24277
|
-
|
|
24278
|
-
|
|
24279
|
-
|
|
24280
|
-
|
|
24273
|
+
return function(e4, t2, n3) {
|
|
24274
|
+
t2 = t2 || "", n3 = n3 || 512;
|
|
24275
|
+
for (var o3 = atob(e4), r3 = [], a3 = 0; a3 < o3.length; a3 += n3) {
|
|
24276
|
+
for (var i2 = o3.slice(a3, a3 + n3), c2 = new Array(i2.length), s2 = 0; s2 < i2.length; s2++) c2[s2] = i2.charCodeAt(s2);
|
|
24277
|
+
var u2 = new Uint8Array(c2);
|
|
24278
|
+
r3.push(u2);
|
|
24279
|
+
}
|
|
24280
|
+
return new Blob(r3, { type: t2 });
|
|
24281
|
+
};
|
|
24282
|
+
}) ? o2.apply(t, r2) : o2) || (e3.exports = a2);
|
|
24283
|
+
}, function(e3, t, n2) {
|
|
24284
|
+
n2.r(t), n2.d(t, "defaultDownloadName", function() {
|
|
24285
|
+
return p2;
|
|
24286
|
+
}), n2.d(t, "triggerBase64Download", function() {
|
|
24287
|
+
return y2;
|
|
24288
|
+
}), n2.d(t, "getExtFromBase64", function() {
|
|
24289
|
+
return b2;
|
|
24290
|
+
});
|
|
24291
|
+
var o2 = n2(1), r2 = n2.n(o2), a2 = n2(0), i2 = n2.n(a2), c2 = n2(2), s2 = n2(3);
|
|
24292
|
+
function u2() {
|
|
24293
|
+
return (u2 = Object.assign || function(e4) {
|
|
24294
|
+
for (var t2 = 1; t2 < arguments.length; t2++) {
|
|
24295
|
+
var n3 = arguments[t2];
|
|
24296
|
+
for (var o3 in n3) Object.prototype.hasOwnProperty.call(n3, o3) && (e4[o3] = n3[o3]);
|
|
24297
|
+
}
|
|
24298
|
+
return e4;
|
|
24299
|
+
}).apply(this, arguments);
|
|
24300
|
+
}
|
|
24301
|
+
var l2 = { png: "image/png", jpeg: "image/jpeg", jpg: "image/jpg" }, f2 = { png: "data:".concat(l2.png, ";base64"), jpeg: "data:".concat(l2.jpeg, ";base64"), jpg: "data:".concat(l2.jpg, ";base64") }, p2 = "download", d2 = function(e4) {
|
|
24302
|
+
var t2 = e4.base64, n3 = e4.children, o3 = e4.downloadName, a3 = e4.onDownloadSuccess, i3 = e4.onDownloadError, c3 = e4.Tag, s3 = e4.className, l3 = e4.style, f3 = e4.extraAttributes;
|
|
24303
|
+
return r2.a.createElement(c3, u2({}, f3, { onClick: function() {
|
|
24281
24304
|
try {
|
|
24282
|
-
|
|
24305
|
+
y2(t2, o3), a3 && a3({ base64: t2 });
|
|
24283
24306
|
} catch (e5) {
|
|
24307
|
+
console.error(e5), i3 && i3(e5);
|
|
24284
24308
|
}
|
|
24285
|
-
|
|
24286
|
-
|
|
24287
|
-
|
|
24288
|
-
|
|
24289
|
-
|
|
24290
|
-
|
|
24291
|
-
|
|
24292
|
-
|
|
24309
|
+
}, className: s3, style: l3 }), n3);
|
|
24310
|
+
};
|
|
24311
|
+
function y2(e4) {
|
|
24312
|
+
var t2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : p2, n3 = b2(e4), o3 = f2[n3], r3 = l2[n3], a3 = e4.replace("".concat(o3, ","), ""), i3 = s2(a3, r3), u3 = new File([i3], "".concat(t2, ".").concat(n3), { type: o3 });
|
|
24313
|
+
c2.saveAs(u3);
|
|
24314
|
+
}
|
|
24315
|
+
function b2(e4) {
|
|
24316
|
+
var t2;
|
|
24317
|
+
if ("string" == typeof e4 && (t2 = Object.keys(f2).find(function(t3) {
|
|
24318
|
+
return 0 === e4.indexOf(f2[t3]);
|
|
24319
|
+
})), t2) return t2;
|
|
24320
|
+
throw new Error("props.base64 on <Base64Downloader/> has invalid or undefined extension. expected ".concat(Object.keys(l2).join(", ")));
|
|
24321
|
+
}
|
|
24322
|
+
d2.defaultProps = { className: "", style: {}, downloadName: p2, Tag: "button", extraAttributes: {} }, d2.propTypes = { base64: i2.a.string.isRequired, children: i2.a.oneOfType([i2.a.node, i2.a.string]).isRequired, downloadName: i2.a.string, onDownloadSuccess: i2.a.func, onDownloadError: i2.a.func, Tag: i2.a.string, className: i2.a.string, style: i2.a.object, extraAttributes: i2.a.object }, t.default = d2;
|
|
24323
|
+
}, function(e3, t, n2) {
|
|
24324
|
+
var o2 = n2(6);
|
|
24325
|
+
function r2() {
|
|
24326
|
+
}
|
|
24327
|
+
function a2() {
|
|
24328
|
+
}
|
|
24329
|
+
a2.resetWarningCache = r2, e3.exports = function() {
|
|
24330
|
+
function e4(e5, t3, n4, r3, a3, i2) {
|
|
24331
|
+
if (i2 !== o2) {
|
|
24332
|
+
var c2 = new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");
|
|
24333
|
+
throw c2.name = "Invariant Violation", c2;
|
|
24293
24334
|
}
|
|
24294
24335
|
}
|
|
24295
|
-
|
|
24296
|
-
|
|
24297
|
-
var c3 = a3.URL || a3.webkitURL, s2 = document.createElement("a");
|
|
24298
|
-
n4 = n4 || e4.name || "download", s2.download = n4, s2.rel = "noopener", "string" == typeof e4 ? (s2.href = e4, s2.origin === location.origin ? r3(s2) : o3(s2.href) ? t2(e4, n4, i3) : r3(s2, s2.target = "_blank")) : (s2.href = c3.createObjectURL(e4), setTimeout(function() {
|
|
24299
|
-
c3.revokeObjectURL(s2.href);
|
|
24300
|
-
}, 4e4), setTimeout(function() {
|
|
24301
|
-
r3(s2);
|
|
24302
|
-
}, 0));
|
|
24303
|
-
} : "msSaveOrOpenBlob" in navigator ? function(e4, n4, a4) {
|
|
24304
|
-
if (n4 = n4 || e4.name || "download", "string" != typeof e4) navigator.msSaveOrOpenBlob(function(e5, t3) {
|
|
24305
|
-
return void 0 === t3 ? t3 = { autoBom: false } : "object" != typeof t3 && (console.warn("Deprecated: Expected third argument to be a object"), t3 = { autoBom: !t3 }), t3.autoBom && /^\s*(?:text\/\S*|application\/xml|\S*\/\S*\+xml)\s*;.*charset\s*=\s*utf-8/i.test(e5.type) ? new Blob(["\uFEFF", e5], { type: e5.type }) : e5;
|
|
24306
|
-
}(e4, a4), n4);
|
|
24307
|
-
else if (o3(e4)) t2(e4, n4, a4);
|
|
24308
|
-
else {
|
|
24309
|
-
var i3 = document.createElement("a");
|
|
24310
|
-
i3.href = e4, i3.target = "_blank", setTimeout(function() {
|
|
24311
|
-
r3(i3);
|
|
24312
|
-
});
|
|
24313
|
-
}
|
|
24314
|
-
} : function(e4, n4, o4, r4) {
|
|
24315
|
-
if ((r4 = r4 || open("", "_blank")) && (r4.document.title = r4.document.body.innerText = "downloading..."), "string" == typeof e4) return t2(e4, n4, o4);
|
|
24316
|
-
var c3 = "application/octet-stream" === e4.type, s2 = /constructor/i.test(a3.HTMLElement) || a3.safari, u2 = /CriOS\/[\d]+/.test(navigator.userAgent);
|
|
24317
|
-
if ((u2 || c3 && s2 || i2) && "undefined" != typeof FileReader) {
|
|
24318
|
-
var l2 = new FileReader();
|
|
24319
|
-
l2.onloadend = function() {
|
|
24320
|
-
var e5 = l2.result;
|
|
24321
|
-
e5 = u2 ? e5 : e5.replace(/^data:[^;]*;/, "data:attachment/file;"), r4 ? r4.location.href = e5 : location = e5, r4 = null;
|
|
24322
|
-
}, l2.readAsDataURL(e4);
|
|
24323
|
-
} else {
|
|
24324
|
-
var f2 = a3.URL || a3.webkitURL, p2 = f2.createObjectURL(e4);
|
|
24325
|
-
r4 ? r4.location = p2 : location.href = p2, r4 = null, setTimeout(function() {
|
|
24326
|
-
f2.revokeObjectURL(p2);
|
|
24327
|
-
}, 4e4);
|
|
24328
|
-
}
|
|
24329
|
-
});
|
|
24330
|
-
a3.saveAs = c2.saveAs = c2, e3.exports = c2;
|
|
24331
|
-
}) ? o2.apply(t, r2) : o2) || (e3.exports = a2);
|
|
24332
|
-
}).call(this, n2(7));
|
|
24333
|
-
}, function(e3, t, n2) {
|
|
24334
|
-
var o2, r2, a2;
|
|
24335
|
-
r2 = [], void 0 === (a2 = "function" == typeof (o2 = function() {
|
|
24336
|
-
return function(e4, t2, n3) {
|
|
24337
|
-
t2 = t2 || "", n3 = n3 || 512;
|
|
24338
|
-
for (var o3 = atob(e4), r3 = [], a3 = 0; a3 < o3.length; a3 += n3) {
|
|
24339
|
-
for (var i2 = o3.slice(a3, a3 + n3), c2 = new Array(i2.length), s2 = 0; s2 < i2.length; s2++) c2[s2] = i2.charCodeAt(s2);
|
|
24340
|
-
var u2 = new Uint8Array(c2);
|
|
24341
|
-
r3.push(u2);
|
|
24336
|
+
function t2() {
|
|
24337
|
+
return e4;
|
|
24342
24338
|
}
|
|
24343
|
-
|
|
24339
|
+
e4.isRequired = e4;
|
|
24340
|
+
var n3 = { array: e4, bool: e4, func: e4, number: e4, object: e4, string: e4, symbol: e4, any: e4, arrayOf: t2, element: e4, elementType: e4, instanceOf: t2, node: e4, objectOf: t2, oneOf: t2, oneOfType: t2, shape: t2, exact: t2, checkPropTypes: a2, resetWarningCache: r2 };
|
|
24341
|
+
return n3.PropTypes = n3, n3;
|
|
24344
24342
|
};
|
|
24345
|
-
}
|
|
24346
|
-
|
|
24347
|
-
|
|
24348
|
-
|
|
24349
|
-
|
|
24350
|
-
|
|
24351
|
-
|
|
24352
|
-
|
|
24353
|
-
|
|
24354
|
-
|
|
24355
|
-
|
|
24356
|
-
return (u2 = Object.assign || function(e4) {
|
|
24357
|
-
for (var t2 = 1; t2 < arguments.length; t2++) {
|
|
24358
|
-
var n3 = arguments[t2];
|
|
24359
|
-
for (var o3 in n3) Object.prototype.hasOwnProperty.call(n3, o3) && (e4[o3] = n3[o3]);
|
|
24360
|
-
}
|
|
24361
|
-
return e4;
|
|
24362
|
-
}).apply(this, arguments);
|
|
24363
|
-
}
|
|
24364
|
-
var l2 = { png: "image/png", jpeg: "image/jpeg", jpg: "image/jpg" }, f2 = { png: "data:".concat(l2.png, ";base64"), jpeg: "data:".concat(l2.jpeg, ";base64"), jpg: "data:".concat(l2.jpg, ";base64") }, p2 = "download", d2 = function(e4) {
|
|
24365
|
-
var t2 = e4.base64, n3 = e4.children, o3 = e4.downloadName, a3 = e4.onDownloadSuccess, i3 = e4.onDownloadError, c3 = e4.Tag, s3 = e4.className, l3 = e4.style, f3 = e4.extraAttributes;
|
|
24366
|
-
return r2.a.createElement(c3, u2({}, f3, { onClick: function() {
|
|
24367
|
-
try {
|
|
24368
|
-
y2(t2, o3), a3 && a3({ base64: t2 });
|
|
24369
|
-
} catch (e5) {
|
|
24370
|
-
console.error(e5), i3 && i3(e5);
|
|
24371
|
-
}
|
|
24372
|
-
}, className: s3, style: l3 }), n3);
|
|
24373
|
-
};
|
|
24374
|
-
function y2(e4) {
|
|
24375
|
-
var t2 = arguments.length > 1 && void 0 !== arguments[1] ? arguments[1] : p2, n3 = b2(e4), o3 = f2[n3], r3 = l2[n3], a3 = e4.replace("".concat(o3, ","), ""), i3 = s2(a3, r3), u3 = new File([i3], "".concat(t2, ".").concat(n3), { type: o3 });
|
|
24376
|
-
c2.saveAs(u3);
|
|
24377
|
-
}
|
|
24378
|
-
function b2(e4) {
|
|
24379
|
-
var t2;
|
|
24380
|
-
if ("string" == typeof e4 && (t2 = Object.keys(f2).find(function(t3) {
|
|
24381
|
-
return 0 === e4.indexOf(f2[t3]);
|
|
24382
|
-
})), t2) return t2;
|
|
24383
|
-
throw new Error("props.base64 on <Base64Downloader/> has invalid or undefined extension. expected ".concat(Object.keys(l2).join(", ")));
|
|
24384
|
-
}
|
|
24385
|
-
d2.defaultProps = { className: "", style: {}, downloadName: p2, Tag: "button", extraAttributes: {} }, d2.propTypes = { base64: i2.a.string.isRequired, children: i2.a.oneOfType([i2.a.node, i2.a.string]).isRequired, downloadName: i2.a.string, onDownloadSuccess: i2.a.func, onDownloadError: i2.a.func, Tag: i2.a.string, className: i2.a.string, style: i2.a.object, extraAttributes: i2.a.object }, t.default = d2;
|
|
24386
|
-
}, function(e3, t, n2) {
|
|
24387
|
-
var o2 = n2(6);
|
|
24388
|
-
function r2() {
|
|
24389
|
-
}
|
|
24390
|
-
function a2() {
|
|
24391
|
-
}
|
|
24392
|
-
a2.resetWarningCache = r2, e3.exports = function() {
|
|
24393
|
-
function e4(e5, t3, n4, r3, a3, i2) {
|
|
24394
|
-
if (i2 !== o2) {
|
|
24395
|
-
var c2 = new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");
|
|
24396
|
-
throw c2.name = "Invariant Violation", c2;
|
|
24397
|
-
}
|
|
24398
|
-
}
|
|
24399
|
-
function t2() {
|
|
24400
|
-
return e4;
|
|
24343
|
+
}, function(e3, t, n2) {
|
|
24344
|
+
e3.exports = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
|
|
24345
|
+
}, function(e3, t) {
|
|
24346
|
+
var n2;
|
|
24347
|
+
n2 = /* @__PURE__ */ function() {
|
|
24348
|
+
return this;
|
|
24349
|
+
}();
|
|
24350
|
+
try {
|
|
24351
|
+
n2 = n2 || new Function("return this")();
|
|
24352
|
+
} catch (e4) {
|
|
24353
|
+
"object" == typeof window && (n2 = window);
|
|
24401
24354
|
}
|
|
24402
|
-
|
|
24403
|
-
|
|
24404
|
-
|
|
24405
|
-
|
|
24406
|
-
|
|
24407
|
-
|
|
24408
|
-
|
|
24409
|
-
var n2;
|
|
24410
|
-
n2 = /* @__PURE__ */ function() {
|
|
24411
|
-
return this;
|
|
24412
|
-
}();
|
|
24413
|
-
try {
|
|
24414
|
-
n2 = n2 || new Function("return this")();
|
|
24415
|
-
} catch (e4) {
|
|
24416
|
-
"object" == typeof window && (n2 = window);
|
|
24417
|
-
}
|
|
24418
|
-
e3.exports = n2;
|
|
24419
|
-
}]);
|
|
24420
|
-
});
|
|
24421
|
-
})(dist);
|
|
24422
|
-
var distExports = dist.exports;
|
|
24355
|
+
e3.exports = n2;
|
|
24356
|
+
}]);
|
|
24357
|
+
});
|
|
24358
|
+
})(dist);
|
|
24359
|
+
return dist.exports;
|
|
24360
|
+
}
|
|
24361
|
+
var distExports = requireDist();
|
|
24423
24362
|
const downloadPgn = (chartRef, state) => {
|
|
24424
24363
|
var _a2;
|
|
24425
24364
|
const chart2 = chartRef.current;
|
|
@@ -41115,15 +41054,3 @@ export {
|
|
|
41115
41054
|
initializeLineChart
|
|
41116
41055
|
};
|
|
41117
41056
|
//# sourceMappingURL=index.js.map
|
|
41118
|
-
(function() {
|
|
41119
|
-
"use strict";
|
|
41120
|
-
try {
|
|
41121
|
-
if (typeof document != "undefined") {
|
|
41122
|
-
var elementStyle = document.createElement("style");
|
|
41123
|
-
elementStyle.appendChild(document.createTextNode("html[data-theme='dark'] ._chart_e3qdd_1 canvas {\n filter: invert(1) hue-rotate(180deg);\n}\n._chart_e3qdd_1 {\n border: 1px solid rgba(255, 255, 255, 0);\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n._chart_e3qdd_1 ._canvas_e3qdd_11 {\n flex-grow: 1;\n min-height: 0;\n position: relative;\n}\n._chart_e3qdd_1 ._canvas_e3qdd_11 canvas {\n width: 100% !important;\n height: 100% !important;\n}\n._chart_e3qdd_1._fixedHeight_e3qdd_20 {\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n height: auto;\n}\n._chart_e3qdd_1._stretchHeight_e3qdd_26 {\n display: flex;\n align-items: stretch;\n justify-content: stretch;\n height: 100%;\n}\n._chart_e3qdd_1._squareAspectRatio_e3qdd_32 {\n aspect-ratio: 1;\n min-height: 0;\n min-width: 0;\n}\n._chart_e3qdd_1:focus {\n outline: none;\n}\n._chart_e3qdd_1::-moz-focus-inner {\n border: 0;\n}\n._zoomForm_e3qdd_43 {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n top: 0;\n right: 0;\n}\n._zoomForm_e3qdd_43 ._zoomReset_e3qdd_51 {\n margin-left: 10px;\n}\n._zoomForm_e3qdd_43 ._help_e3qdd_54 {\n margin-left: 5px;\n line-height: 0;\n}\n._autoWeight_e3qdd_58 {\n width: auto;\n height: auto;\n}\n._table_e3qdd_62 {\n overflow: auto;\n}\n._controls_1edjs_1 {\n display: flex;\n align-items: center;\n gap: var(--padding-xs);\n}\n._buttons_1edjs_6 {\n display: flex;\n flex-grow: 1;\n align-items: flex-start;\n justify-content: flex-end;\n margin-left: auto;\n gap: var(--padding-xxs);\n}\n._legend_wpro0_1 {\n position: absolute;\n opacity: 0.9;\n display: flex;\n flex-direction: column;\n z-index: 1;\n}\n._legend_wpro0_1._isDragging_wpro0_8 {\n opacity: 0;\n}\n._legendItems_wpro0_11 {\n background-color: var(--color-background-raised);\n border: 1px solid var(--color-border);\n padding: 4px 8px;\n border-radius: 2px;\n overflow-y: auto;\n max-height: 100%;\n overflow: overlay;\n --scrollbar-color: #00000040;\n}\n._legendItems_wpro0_11::-webkit-scrollbar {\n display: block;\n width: 16px;\n z-index: 2;\n}\n._legendItems_wpro0_11::-webkit-scrollbar-button {\n display: none;\n}\n._legendItems_wpro0_11::-webkit-scrollbar-track {\n background-color: #00000000;\n}\n._legendItems_wpro0_11::-webkit-scrollbar-track-piece {\n background-color: #00000000;\n}\n._legendItems_wpro0_11::-webkit-scrollbar-thumb {\n background-color: #00000000;\n border: 5px solid transparent;\n border-radius: 24px;\n box-shadow: 4px 0px 0px 4px var(--scrollbar-color) inset;\n}\n._legendItems_wpro0_11::-webkit-scrollbar-corner {\n background: rgba(0, 0, 0, 0);\n}\n._legend_wpro0_1._isDragging_wpro0_8 ._legendItems_wpro0_11._legendItems_wpro0_11 {\n pointer-events: none;\n}\n._legend_wpro0_1._isHidden_wpro0_47 ._legendItems_wpro0_11._legendItems_wpro0_11 {\n display: none;\n}\n._legendToggle_wpro0_50 {\n position: absolute;\n top: 0;\n right: 0;\n transform: translate(50%, -50%);\n display: none;\n}\n._legend_wpro0_1._isHidden_wpro0_47 ._legendToggle_wpro0_50._legendToggle_wpro0_50,\n._legend_wpro0_1:hover ._legendToggle_wpro0_50._legendToggle_wpro0_50 {\n display: block;\n}\n._legend_wpro0_1:active ._legendToggle_wpro0_50._legendToggle_wpro0_50:not(:hover) {\n display: none;\n}\n._legend_wpro0_1._isHidden_wpro0_47 ._legendToggle_wpro0_50._legendToggle_wpro0_50 {\n position: static;\n transform: none;\n}\n._legend_wpro0_1._isDragging_wpro0_8 ._legendToggle_wpro0_50._legendToggle_wpro0_50 {\n display: none;\n}\n._legendItem_wpro0_11 {\n display: flex;\n align-items: flex-start;\n gap: 8px;\n user-select: none;\n cursor: pointer;\n font-size: 12px;\n line-height: 16px;\n}\n._legendItemSymbol_wpro0_80 {\n display: flex;\n align-items: center;\n height: 16px;\n position: relative;\n flex-shrink: 0;\n}\nhtml[data-theme='dark'] ._legendItemSymbol_wpro0_80._legendItemSymbol_wpro0_80 {\n filter: invert(1) hue-rotate(180deg);\n}\n._legendItemBox_wpro0_90 {\n width: 100%;\n height: 12px;\n display: block;\n}\n._legendItemLine_wpro0_95 {\n position: absolute;\n display: flex;\n top: 50%;\n left: 0;\n width: 100%;\n transform: translateY(-50%);\n}\n._legendItemPoint_wpro0_103 {\n position: absolute;\n display: flex;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n}\n._isHidden_wpro0_47 ._legendItemText_wpro0_110._legendItemText_wpro0_110 {\n text-decoration: line-through;\n}\n._scrollbars_wpro0_113 {\n overflow: overlay;\n --scrollbar-color: #00000040;\n}\n._scrollbars_wpro0_113::-webkit-scrollbar {\n display: block;\n width: 16px;\n z-index: 2;\n}\n._scrollbars_wpro0_113::-webkit-scrollbar-button {\n display: none;\n}\n._scrollbars_wpro0_113::-webkit-scrollbar-track {\n background-color: #00000000;\n}\n._scrollbars_wpro0_113::-webkit-scrollbar-track-piece {\n background-color: #00000000;\n}\n._scrollbars_wpro0_113::-webkit-scrollbar-thumb {\n background-color: #00000000;\n border: 5px solid transparent;\n border-radius: 24px;\n box-shadow: 4px 0px 0px 4px var(--scrollbar-color) inset;\n}\n._scrollbars_wpro0_113::-webkit-scrollbar-corner {\n background: rgba(0, 0, 0, 0);\n}\n._dropzoneContainer_wpro0_140 {\n position: absolute;\n}\n._dropzone_wpro0_140 {\n position: absolute;\n width: 50%;\n height: 50%;\n display: flex;\n}\n._dropzone_wpro0_140._left_wpro0_149 {\n left: 0;\n justify-content: flex-start;\n}\n._dropzone_wpro0_140._right_wpro0_153 {\n right: 0;\n justify-content: flex-end;\n}\n._dropzone_wpro0_140._top_wpro0_157 {\n top: 0;\n align-items: flex-start;\n}\n._dropzone_wpro0_140._bottom_wpro0_161 {\n bottom: 0;\n align-items: flex-end;\n}\n._dropzonePlaceholder_wpro0_165 {\n position: absolute;\n background-color: rgba(0, 0, 0, 0.05);\n display: none;\n}\n[data-theme='dark'] ._dropzonePlaceholder_wpro0_165 {\n background-color: rgba(255, 255, 255, 0.05);\n}\n._isActive_wpro0_173 ._dropzonePlaceholder_wpro0_165._dropzonePlaceholder_wpro0_165 {\n display: block;\n}\n._resizeContainer_wpro0_176 {\n position: absolute;\n inset: 0;\n z-index: -1;\n}\nhtml[data-theme='dark'] ._chart_1jdnu_1 canvas {\n filter: invert(1) hue-rotate(180deg);\n}\n._chart_1jdnu_1 {\n border: 1px solid rgba(255, 255, 255, 0);\n padding-top: 10px;\n position: relative;\n}\n._chart_1jdnu_1 canvas {\n width: 100% !important;\n height: 100% !important;\n}\n._chart_1jdnu_1._fixedHeight_1jdnu_13 {\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n height: auto;\n}\n._chart_1jdnu_1._stretchHeight_1jdnu_19 {\n display: flex;\n align-items: stretch;\n justify-content: stretch;\n height: 100%;\n}\n._chart_1jdnu_1:focus {\n border: 1px solid #85b7d9;\n outline: none;\n}\n._chart_1jdnu_1::-moz-focus-inner {\n border: 0;\n}\n._zoomForm_1jdnu_32 {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n top: 0;\n right: 0;\n}\n._zoomForm_1jdnu_32 ._zoomReset_1jdnu_40 {\n margin-left: 10px;\n}\n._zoomForm_1jdnu_32 ._help_1jdnu_43 {\n margin-left: 5px;\n line-height: 0;\n}\n._autoWeight_1jdnu_47 {\n width: 'auto';\n height: 'auto';\n}\nhtml[data-theme='dark'] ._chart_x1sru_1 canvas {\n filter: invert(1) hue-rotate(180deg);\n}\n._chart_x1sru_1 {\n border: 1px solid rgba(255, 255, 255, 0);\n position: relative;\n display: flex;\n flex-direction: column;\n}\n._chart_x1sru_1 ._canvas_x1sru_10 {\n flex-grow: 1;\n min-height: 0;\n position: relative;\n}\n._chart_x1sru_1 ._canvas_x1sru_10 canvas {\n width: 100% !important;\n height: 100% !important;\n}\n._chart_x1sru_1._fixedHeight_x1sru_19 {\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n height: auto;\n}\n._chart_x1sru_1._stretchHeight_x1sru_25 {\n display: flex;\n align-items: stretch;\n justify-content: stretch;\n height: 100%;\n}\n._chart_x1sru_1:focus {\n border: 1px solid #85b7d9;\n outline: none;\n}\n._chart_x1sru_1::-moz-focus-inner {\n border: 0;\n}\n._zoomForm_x1sru_38 {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n top: 0;\n right: 0;\n}\n._zoomForm_x1sru_38 ._zoomReset_x1sru_46 {\n margin-left: 10px;\n}\n._zoomForm_x1sru_38 ._help_x1sru_49 {\n margin-left: 5px;\n line-height: 0;\n}\n._autoWeight_x1sru_53 {\n width: auto;\n height: auto;\n}\n._actions_x1sru_57 {\n display: flex;\n align-items: center;\n justify-content: flex-end;\n}\nhtml[data-theme='dark'] ._chart_1qlu1_1 canvas {\n filter: invert(1) hue-rotate(180deg);\n}\n._chart_1qlu1_1 {\n border: 1px solid rgba(255, 255, 255, 0);\n position: relative;\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n._chart_1qlu1_1 ._canvas_1qlu1_11 {\n flex-grow: 1;\n min-height: 0;\n position: relative;\n}\n._chart_1qlu1_1 ._canvas_1qlu1_11 canvas {\n width: 100% !important;\n height: 100% !important;\n}\n._chart_1qlu1_1._fixedHeight_1qlu1_20 {\n display: flex;\n align-items: flex-start;\n justify-content: flex-start;\n height: auto;\n}\n._chart_1qlu1_1._stretchHeight_1qlu1_26 {\n display: flex;\n align-items: stretch;\n justify-content: stretch;\n height: 100%;\n}\n._chart_1qlu1_1._squareAspectRatio_1qlu1_32 {\n aspect-ratio: 1;\n min-height: 0;\n min-width: 0;\n}\n._chart_1qlu1_1:focus {\n outline: none;\n}\n._chart_1qlu1_1::-moz-focus-inner {\n border: 0;\n}\n._zoomForm_1qlu1_43 {\n position: absolute;\n display: flex;\n align-items: center;\n justify-content: center;\n top: 0;\n right: 0;\n}\n._zoomForm_1qlu1_43 ._zoomReset_1qlu1_51 {\n margin-left: 10px;\n}\n._zoomForm_1qlu1_43 ._help_1qlu1_54 {\n margin-left: 5px;\n line-height: 0;\n}\n._autoWeight_1qlu1_58 {\n width: 'auto';\n height: 'auto';\n}"));
|
|
41124
|
-
document.head.appendChild(elementStyle);
|
|
41125
|
-
}
|
|
41126
|
-
} catch (e) {
|
|
41127
|
-
console.error("vite-plugin-css-injected-by-js", e);
|
|
41128
|
-
}
|
|
41129
|
-
})();
|