@progress/kendo-charts 1.22.0 → 1.23.0-dev.202201170838
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/LICENSE.md +1 -1
- package/NOTICE.txt +119 -79
- package/dist/cdn/js/kendo-charts.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/common/keys.js +25 -0
- package/dist/es/common.js +1 -0
- package/dist/es/drawing-utils.js +27 -3
- package/dist/es/main.js +1 -0
- package/dist/es/map/attribution.js +158 -0
- package/dist/es/map/crs.js +277 -0
- package/dist/es/map/datums.js +16 -0
- package/dist/es/map/extent.js +129 -0
- package/dist/es/map/layers/bubble.js +185 -0
- package/dist/es/map/layers/layer.js +140 -0
- package/dist/es/map/layers/marker.js +347 -0
- package/dist/es/map/layers/shape.js +389 -0
- package/dist/es/map/layers/tile.js +491 -0
- package/dist/es/map/location.js +201 -0
- package/dist/es/map/map.js +945 -0
- package/dist/es/map/navigator.js +175 -0
- package/dist/es/map/scroller/draggable.js +454 -0
- package/dist/es/map/scroller/fx.js +119 -0
- package/dist/es/map/scroller/observable.js +175 -0
- package/dist/es/map/scroller/scroller.js +746 -0
- package/dist/es/map/scroller/user-events.js +713 -0
- package/dist/es/map/utils.js +450 -0
- package/dist/es/map/zoom.js +139 -0
- package/dist/es/map.js +1 -0
- package/dist/es/services/map-service.js +15 -0
- package/dist/es2015/common/keys.js +25 -0
- package/dist/es2015/common.js +1 -0
- package/dist/es2015/drawing-utils.js +43 -3
- package/dist/es2015/main.js +1 -0
- package/dist/es2015/map/attribution.js +148 -0
- package/dist/es2015/map/crs.js +233 -0
- package/dist/es2015/map/datums.js +16 -0
- package/dist/es2015/map/extent.js +115 -0
- package/dist/es2015/map/layers/bubble.js +167 -0
- package/dist/es2015/map/layers/layer.js +134 -0
- package/dist/es2015/map/layers/marker.js +327 -0
- package/dist/es2015/map/layers/shape.js +369 -0
- package/dist/es2015/map/layers/tile.js +465 -0
- package/dist/es2015/map/location.js +193 -0
- package/dist/es2015/map/map.js +915 -0
- package/dist/es2015/map/navigator.js +170 -0
- package/dist/es2015/map/scroller/draggable.js +418 -0
- package/dist/es2015/map/scroller/fx.js +112 -0
- package/dist/es2015/map/scroller/observable.js +165 -0
- package/dist/es2015/map/scroller/scroller.js +716 -0
- package/dist/es2015/map/scroller/user-events.js +695 -0
- package/dist/es2015/map/utils.js +450 -0
- package/dist/es2015/map/zoom.js +134 -0
- package/dist/es2015/map.js +1 -0
- package/dist/es2015/services/map-service.js +15 -0
- package/dist/npm/main.d.ts +1 -0
- package/dist/npm/main.js +6218 -342
- package/dist/npm/map.d.ts +4 -0
- package/dist/systemjs/kendo-charts.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
import {
|
|
2
|
+
deepExtend,
|
|
3
|
+
addClass,
|
|
4
|
+
keys,
|
|
5
|
+
setDefaultOptions
|
|
6
|
+
} from '../common';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
Observable
|
|
10
|
+
} from './scroller/observable';
|
|
11
|
+
|
|
12
|
+
import {
|
|
13
|
+
proxy,
|
|
14
|
+
on,
|
|
15
|
+
off,
|
|
16
|
+
setDefaultEvents,
|
|
17
|
+
convertToHtml
|
|
18
|
+
} from './utils';
|
|
19
|
+
|
|
20
|
+
const PAN = "pan";
|
|
21
|
+
|
|
22
|
+
const directionsMap = {
|
|
23
|
+
up: {
|
|
24
|
+
className: "k-navigator-n",
|
|
25
|
+
iconClass: "k-i-arrow-n"
|
|
26
|
+
},
|
|
27
|
+
down: {
|
|
28
|
+
className: "k-navigator-s",
|
|
29
|
+
iconClass: "k-i-arrow-s"
|
|
30
|
+
},
|
|
31
|
+
right: {
|
|
32
|
+
className: "k-navigator-e",
|
|
33
|
+
iconClass: "k-i-arrow-e"
|
|
34
|
+
},
|
|
35
|
+
left: {
|
|
36
|
+
className: "k-navigator-w",
|
|
37
|
+
iconClass: "k-i-arrow-w"
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
function createButton(direction) {
|
|
42
|
+
const html =
|
|
43
|
+
'<button class="k-button k-button-square k-rounded-full k-button-flat k-button-flat-base k-icon-button ' +
|
|
44
|
+
directionsMap[direction].className +
|
|
45
|
+
'" aria-label="move ' + direction + '">' +
|
|
46
|
+
'<span class="k-icon ' + directionsMap[direction].iconClass + '" />' +
|
|
47
|
+
'</button>';
|
|
48
|
+
|
|
49
|
+
return convertToHtml(html);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export class Navigator extends Observable {
|
|
53
|
+
constructor(element, options) {
|
|
54
|
+
super();
|
|
55
|
+
|
|
56
|
+
this.element = element;
|
|
57
|
+
this._initOptions(options);
|
|
58
|
+
|
|
59
|
+
const navigateUpButton = createButton("up");
|
|
60
|
+
const navigateRightlButton = createButton("right");
|
|
61
|
+
const navigateDownButton = createButton("down");
|
|
62
|
+
const navigateLeftButton = createButton("left");
|
|
63
|
+
|
|
64
|
+
this.element.appendChild(navigateUpButton);
|
|
65
|
+
this.element.appendChild(navigateRightlButton);
|
|
66
|
+
this.element.appendChild(navigateDownButton);
|
|
67
|
+
this.element.appendChild(navigateLeftButton);
|
|
68
|
+
|
|
69
|
+
addClass(this.element, 'k-widget k-navigator');
|
|
70
|
+
|
|
71
|
+
on(this.element, "click", ".k-button", proxy(this._click, this));
|
|
72
|
+
|
|
73
|
+
let parentElement = this.element.parentNode.closest("[data-role]");
|
|
74
|
+
|
|
75
|
+
this._keyroot = parentElement ? parentElement : this.element;
|
|
76
|
+
this._tabindex(this._keyroot);
|
|
77
|
+
|
|
78
|
+
this._keydownHandler = proxy(this._keydown, this);
|
|
79
|
+
on(this._keyroot, "keydown", this._keydownHandler);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
destroy() {
|
|
83
|
+
this.dispose();
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// originates from the kendo.jquery version
|
|
87
|
+
dispose() {
|
|
88
|
+
off(this._keyroot, "keydown", this._keydownHandler);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
_tabindex(target) {
|
|
92
|
+
const targetElement = target || this.wrapper || this.element;
|
|
93
|
+
|
|
94
|
+
let element = this.element,
|
|
95
|
+
TABINDEX = "tabindex",
|
|
96
|
+
tabindex = targetElement.getAttribute(TABINDEX) || element.getAttribute(TABINDEX);
|
|
97
|
+
|
|
98
|
+
element.removeAttribute(TABINDEX);
|
|
99
|
+
|
|
100
|
+
targetElement.setAttribute(TABINDEX, !isNaN(tabindex) ? tabindex : 0);
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
_initOptions(options) {
|
|
104
|
+
this.options = deepExtend({}, this.options, options);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
_pan(x, y) {
|
|
108
|
+
let panStep = this.options.panStep;
|
|
109
|
+
|
|
110
|
+
this.trigger(PAN, {
|
|
111
|
+
x: x * panStep,
|
|
112
|
+
y: y * panStep
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
_click(e) {
|
|
117
|
+
let x = 0;
|
|
118
|
+
let y = 0;
|
|
119
|
+
let button = e.currentTarget;
|
|
120
|
+
|
|
121
|
+
if (button.matches('.k-navigator-n')) {
|
|
122
|
+
y = 1;
|
|
123
|
+
} else if (button.matches('.k-navigator-s')) {
|
|
124
|
+
y = -1;
|
|
125
|
+
} else if (button.matches('.k-navigator-e')) {
|
|
126
|
+
x = 1;
|
|
127
|
+
} else if (button.matches('.k-navigator-w')) {
|
|
128
|
+
x = -1;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
this._pan(x, y);
|
|
132
|
+
|
|
133
|
+
e.preventDefault();
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/* eslint-disable indent */
|
|
137
|
+
_keydown(e) {
|
|
138
|
+
switch (e.which) {
|
|
139
|
+
case keys.UP:
|
|
140
|
+
this._pan(0, 1);
|
|
141
|
+
e.preventDefault();
|
|
142
|
+
break;
|
|
143
|
+
case keys.DOWN:
|
|
144
|
+
this._pan(0, -1);
|
|
145
|
+
e.preventDefault();
|
|
146
|
+
break;
|
|
147
|
+
case keys.RIGHT:
|
|
148
|
+
this._pan(1, 0);
|
|
149
|
+
e.preventDefault();
|
|
150
|
+
break;
|
|
151
|
+
case keys.LEFT:
|
|
152
|
+
this._pan(-1, 0);
|
|
153
|
+
e.preventDefault();
|
|
154
|
+
break;
|
|
155
|
+
default:
|
|
156
|
+
break;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
/* eslint-enable indent */
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
setDefaultOptions(Navigator, {
|
|
163
|
+
name: 'Navigator',
|
|
164
|
+
panStep: 1
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
setDefaultEvents(Navigator, [
|
|
169
|
+
PAN
|
|
170
|
+
]);
|
|
@@ -0,0 +1,418 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Class,
|
|
3
|
+
elementOffset
|
|
4
|
+
} from '../../common';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
Observable
|
|
8
|
+
} from './observable';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
getEventMap,
|
|
12
|
+
proxy,
|
|
13
|
+
getSupportedFeatures
|
|
14
|
+
} from '../utils';
|
|
15
|
+
|
|
16
|
+
const extend = Object.assign;
|
|
17
|
+
|
|
18
|
+
const CHANGE = 'change';
|
|
19
|
+
|
|
20
|
+
export class TapCapture extends Observable {
|
|
21
|
+
constructor(element, options) {
|
|
22
|
+
super();
|
|
23
|
+
let that = this,
|
|
24
|
+
domElement = element[0] || element;
|
|
25
|
+
|
|
26
|
+
that.capture = false;
|
|
27
|
+
|
|
28
|
+
const eventMap = getEventMap(navigator.userAgent);
|
|
29
|
+
|
|
30
|
+
if (domElement.addEventListener) {
|
|
31
|
+
eventMap.down.split(' ').forEach(function(event) {
|
|
32
|
+
domElement.addEventListener(event, proxy(that._press, that), true);
|
|
33
|
+
});
|
|
34
|
+
eventMap.up.split(' ').forEach(function(event) {
|
|
35
|
+
domElement.addEventListener(event, proxy(that._release, that), true);
|
|
36
|
+
});
|
|
37
|
+
} else {
|
|
38
|
+
eventMap.down.split(' ').forEach(function(event) {
|
|
39
|
+
domElement.attachEvent(event, proxy(that._press, that));
|
|
40
|
+
});
|
|
41
|
+
eventMap.up.split(' ').forEach(function(event) {
|
|
42
|
+
domElement.attachEvent(event, proxy(that._release, that));
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
that.bind([
|
|
47
|
+
'press',
|
|
48
|
+
'release'
|
|
49
|
+
], options || {});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
captureNext() {
|
|
53
|
+
this.capture = true;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
cancelCapture() {
|
|
57
|
+
this.capture = false;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
_press(e) {
|
|
61
|
+
let that = this;
|
|
62
|
+
|
|
63
|
+
that.trigger('press');
|
|
64
|
+
|
|
65
|
+
if (that.capture) {
|
|
66
|
+
e.preventDefault();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
_release(e) {
|
|
71
|
+
let that = this;
|
|
72
|
+
|
|
73
|
+
that.trigger('release');
|
|
74
|
+
|
|
75
|
+
if (that.capture) {
|
|
76
|
+
e.preventDefault();
|
|
77
|
+
that.cancelCapture();
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
export class PaneDimension extends Observable {
|
|
83
|
+
constructor(options) {
|
|
84
|
+
super();
|
|
85
|
+
let that = this;
|
|
86
|
+
that.forcedEnabled = false;
|
|
87
|
+
extend(that, options);
|
|
88
|
+
that.scale = 1;
|
|
89
|
+
|
|
90
|
+
if (that.horizontal) {
|
|
91
|
+
that.measure = 'offsetWidth';
|
|
92
|
+
that.scrollSize = 'scrollWidth';
|
|
93
|
+
that.axis = 'x';
|
|
94
|
+
} else {
|
|
95
|
+
that.measure = 'offsetHeight';
|
|
96
|
+
that.scrollSize = 'scrollHeight';
|
|
97
|
+
that.axis = 'y';
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
makeVirtual() {
|
|
102
|
+
extend(this, {
|
|
103
|
+
virtual: true,
|
|
104
|
+
forcedEnabled: true,
|
|
105
|
+
_virtualMin: 0,
|
|
106
|
+
_virtualMax: 0
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
virtualSize(min, max) {
|
|
111
|
+
if (this._virtualMin !== min || this._virtualMax !== max) {
|
|
112
|
+
this._virtualMin = min;
|
|
113
|
+
this._virtualMax = max;
|
|
114
|
+
this.update();
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
outOfBounds(offset) {
|
|
119
|
+
return offset > this.max || offset < this.min;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
forceEnabled() {
|
|
123
|
+
this.forcedEnabled = true;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
getSize() {
|
|
127
|
+
return this.container[this.measure];
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
getTotal() {
|
|
131
|
+
return this.element[this.scrollSize];
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
rescale(scale) {
|
|
135
|
+
this.scale = scale;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
update(silent) {
|
|
139
|
+
let that = this,
|
|
140
|
+
total = that.virtual ? that._virtualMax : that.getTotal(),
|
|
141
|
+
scaledTotal = total * that.scale,
|
|
142
|
+
size = that.getSize();
|
|
143
|
+
|
|
144
|
+
if (total === 0 && !that.forcedEnabled) {
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
that.max = that.virtual ? -that._virtualMin : 0;
|
|
149
|
+
that.size = size;
|
|
150
|
+
that.total = scaledTotal;
|
|
151
|
+
that.min = Math.min(that.max, size - scaledTotal);
|
|
152
|
+
that.minScale = size / total;
|
|
153
|
+
that.centerOffset = (scaledTotal - size) / 2;
|
|
154
|
+
that.enabled = that.forcedEnabled || scaledTotal > size;
|
|
155
|
+
|
|
156
|
+
if (!silent) {
|
|
157
|
+
that.trigger(CHANGE, that);
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export class PaneDimensions extends Observable {
|
|
163
|
+
constructor(options) {
|
|
164
|
+
super();
|
|
165
|
+
let that = this;
|
|
166
|
+
|
|
167
|
+
that.x = new PaneDimension(extend({
|
|
168
|
+
horizontal: true
|
|
169
|
+
}, options));
|
|
170
|
+
|
|
171
|
+
that.y = new PaneDimension(extend({
|
|
172
|
+
horizontal: false
|
|
173
|
+
}, options));
|
|
174
|
+
|
|
175
|
+
that.container = options.container;
|
|
176
|
+
that.forcedMinScale = options.minScale;
|
|
177
|
+
that.maxScale = options.maxScale || 100;
|
|
178
|
+
that.bind(CHANGE, options);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
rescale(newScale) {
|
|
182
|
+
this.x.rescale(newScale);
|
|
183
|
+
this.y.rescale(newScale);
|
|
184
|
+
this.refresh();
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
centerCoordinates() {
|
|
188
|
+
return {
|
|
189
|
+
x: Math.min(0, -this.x.centerOffset),
|
|
190
|
+
y: Math.min(0, -this.y.centerOffset)
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
refresh() {
|
|
195
|
+
let that = this;
|
|
196
|
+
that.x.update();
|
|
197
|
+
that.y.update();
|
|
198
|
+
that.enabled = that.x.enabled || that.y.enabled;
|
|
199
|
+
that.minScale = that.forcedMinScale || Math.min(that.x.minScale, that.y.minScale);
|
|
200
|
+
that.fitScale = Math.max(that.x.minScale, that.y.minScale);
|
|
201
|
+
that.trigger(CHANGE);
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
export class PaneAxis extends Observable {
|
|
206
|
+
constructor(options) {
|
|
207
|
+
super();
|
|
208
|
+
extend(this, options);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
outOfBounds() {
|
|
212
|
+
return this.dimension.outOfBounds(this.movable[this.axis]);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
dragMove(delta) {
|
|
216
|
+
let that = this,
|
|
217
|
+
dimension = that.dimension,
|
|
218
|
+
axis = that.axis,
|
|
219
|
+
movable = that.movable,
|
|
220
|
+
position = movable[axis] + delta;
|
|
221
|
+
|
|
222
|
+
if (!dimension.enabled) {
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
let dragDelta = delta;
|
|
227
|
+
|
|
228
|
+
if (position < dimension.min && delta < 0 || position > dimension.max && delta > 0) {
|
|
229
|
+
dragDelta *= that.resistance;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
movable.translateAxis(axis, dragDelta);
|
|
233
|
+
that.trigger(CHANGE, that);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
export class Pane extends Class {
|
|
238
|
+
constructor(options) {
|
|
239
|
+
super();
|
|
240
|
+
|
|
241
|
+
let that = this,
|
|
242
|
+
x, y,
|
|
243
|
+
resistance,
|
|
244
|
+
movable;
|
|
245
|
+
|
|
246
|
+
extend(that, {
|
|
247
|
+
elastic: true
|
|
248
|
+
}, options);
|
|
249
|
+
|
|
250
|
+
resistance = that.elastic ? 0.5 : 0;
|
|
251
|
+
movable = that.movable;
|
|
252
|
+
|
|
253
|
+
that.x = x = new PaneAxis({
|
|
254
|
+
axis: 'x',
|
|
255
|
+
dimension: that.dimensions.x,
|
|
256
|
+
resistance: resistance,
|
|
257
|
+
movable: movable
|
|
258
|
+
});
|
|
259
|
+
|
|
260
|
+
that.y = y = new PaneAxis({
|
|
261
|
+
axis: 'y',
|
|
262
|
+
dimension: that.dimensions.y,
|
|
263
|
+
resistance: resistance,
|
|
264
|
+
movable: movable
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
that.userEvents.bind([
|
|
268
|
+
'press',
|
|
269
|
+
'move',
|
|
270
|
+
'end',
|
|
271
|
+
'gesturestart',
|
|
272
|
+
'gesturechange'
|
|
273
|
+
], {
|
|
274
|
+
gesturestart(e) {
|
|
275
|
+
that.gesture = e;
|
|
276
|
+
|
|
277
|
+
that.offset = elementOffset(that.dimensions.container);
|
|
278
|
+
},
|
|
279
|
+
press(e) {
|
|
280
|
+
const closestAnchor = e.event.target.closest('a');
|
|
281
|
+
|
|
282
|
+
if (closestAnchor && closestAnchor.matches('[data-navigate-on-press=true]')) {
|
|
283
|
+
e.sender.cancel();
|
|
284
|
+
}
|
|
285
|
+
},
|
|
286
|
+
gesturechange(e) {
|
|
287
|
+
let previousGesture = that.gesture,
|
|
288
|
+
previousCenter = previousGesture.center,
|
|
289
|
+
center = e.center,
|
|
290
|
+
scaleDelta = e.distance / previousGesture.distance,
|
|
291
|
+
minScale = that.dimensions.minScale,
|
|
292
|
+
maxScale = that.dimensions.maxScale,
|
|
293
|
+
coordinates;
|
|
294
|
+
if (movable.scale <= minScale && scaleDelta < 1) {
|
|
295
|
+
scaleDelta += (1 - scaleDelta) * 0.8;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
if (movable.scale * scaleDelta >= maxScale) {
|
|
299
|
+
scaleDelta = maxScale / movable.scale;
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
let offsetX = movable.x + that.offset.left,
|
|
303
|
+
offsetY = movable.y + that.offset.top;
|
|
304
|
+
coordinates = {
|
|
305
|
+
x: (offsetX - previousCenter.x) * scaleDelta + center.x - offsetX,
|
|
306
|
+
y: (offsetY - previousCenter.y) * scaleDelta + center.y - offsetY
|
|
307
|
+
};
|
|
308
|
+
|
|
309
|
+
movable.scaleWith(scaleDelta);
|
|
310
|
+
|
|
311
|
+
x.dragMove(coordinates.x);
|
|
312
|
+
y.dragMove(coordinates.y);
|
|
313
|
+
|
|
314
|
+
that.dimensions.rescale(movable.scale);
|
|
315
|
+
that.gesture = e;
|
|
316
|
+
|
|
317
|
+
e.preventDefault();
|
|
318
|
+
},
|
|
319
|
+
move(e) {
|
|
320
|
+
if (e.event.target.tagName.match(/textarea|input/i)) {
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
if (x.dimension.enabled || y.dimension.enabled) {
|
|
325
|
+
x.dragMove(e.x.delta);
|
|
326
|
+
y.dragMove(e.y.delta);
|
|
327
|
+
e.preventDefault();
|
|
328
|
+
} else {
|
|
329
|
+
e.touch.skip();
|
|
330
|
+
}
|
|
331
|
+
},
|
|
332
|
+
end(e) {
|
|
333
|
+
e.preventDefault();
|
|
334
|
+
}
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
|
|
339
|
+
let translate = function(x, y, scale) {
|
|
340
|
+
return 'translate3d(' + x + 'px,' + y + 'px,0) scale(' + scale + ')';
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
export class Movable extends Observable {
|
|
344
|
+
constructor(element) {
|
|
345
|
+
super();
|
|
346
|
+
|
|
347
|
+
let that = this;
|
|
348
|
+
|
|
349
|
+
that.support = getSupportedFeatures();
|
|
350
|
+
this.transformStyle = this.support.transitions.prefix + 'Transform';
|
|
351
|
+
that.element = element;
|
|
352
|
+
that.element.style.webkitTransformOrigin = 'left top';
|
|
353
|
+
that.x = 0;
|
|
354
|
+
that.y = 0;
|
|
355
|
+
that.scale = 1;
|
|
356
|
+
|
|
357
|
+
const coordinates = translate(that.x, that.y, that.scale);
|
|
358
|
+
that.element.style[this.transformStyle] = coordinates;
|
|
359
|
+
|
|
360
|
+
that._saveCoordinates(coordinates);
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
translateAxis(axis, by) {
|
|
364
|
+
this[axis] += by;
|
|
365
|
+
this.refresh();
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
scaleTo(scale) {
|
|
369
|
+
this.scale = scale;
|
|
370
|
+
this.refresh();
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
scaleWith(scaleDelta) {
|
|
374
|
+
this.scale *= scaleDelta;
|
|
375
|
+
this.refresh();
|
|
376
|
+
}
|
|
377
|
+
|
|
378
|
+
translate(coordinates) {
|
|
379
|
+
this.x += coordinates.x;
|
|
380
|
+
this.y += coordinates.y;
|
|
381
|
+
this.refresh();
|
|
382
|
+
}
|
|
383
|
+
|
|
384
|
+
moveAxis(axis, value) {
|
|
385
|
+
this[axis] = value;
|
|
386
|
+
this.refresh();
|
|
387
|
+
}
|
|
388
|
+
|
|
389
|
+
moveTo(coordinates) {
|
|
390
|
+
extend(this, coordinates);
|
|
391
|
+
this.refresh();
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
refresh() {
|
|
395
|
+
let that = this,
|
|
396
|
+
x = that.x,
|
|
397
|
+
y = that.y,
|
|
398
|
+
newCoordinates;
|
|
399
|
+
|
|
400
|
+
if (that.round) {
|
|
401
|
+
x = Math.round(x);
|
|
402
|
+
y = Math.round(y);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
newCoordinates = translate(x, y, that.scale);
|
|
406
|
+
|
|
407
|
+
if (newCoordinates !== that.coordinates) {
|
|
408
|
+
that.element.style[this.transformStyle] = newCoordinates;
|
|
409
|
+
|
|
410
|
+
that._saveCoordinates(newCoordinates);
|
|
411
|
+
that.trigger(CHANGE);
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
_saveCoordinates(coordinates) {
|
|
416
|
+
this.coordinates = coordinates;
|
|
417
|
+
}
|
|
418
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Class
|
|
3
|
+
} from '../../common';
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
proxy,
|
|
7
|
+
now
|
|
8
|
+
} from '../utils';
|
|
9
|
+
|
|
10
|
+
const extend = Object.assign;
|
|
11
|
+
|
|
12
|
+
function animationFrame(callback) {
|
|
13
|
+
window.requestAnimationFrame(callback);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export class Animation extends Class {
|
|
17
|
+
constructor() {
|
|
18
|
+
super();
|
|
19
|
+
let that = this;
|
|
20
|
+
|
|
21
|
+
that._tickProxy = proxy(that._tick, that);
|
|
22
|
+
that._started = false;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
tick() { }
|
|
26
|
+
done() { }
|
|
27
|
+
onEnd() { }
|
|
28
|
+
onCancel() { }
|
|
29
|
+
|
|
30
|
+
start() {
|
|
31
|
+
if (!this.enabled()) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
if (!this.done()) {
|
|
36
|
+
this._started = true;
|
|
37
|
+
animationFrame(this._tickProxy);
|
|
38
|
+
} else {
|
|
39
|
+
this.onEnd();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
enabled() {
|
|
44
|
+
return true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
cancel() {
|
|
48
|
+
this._started = false;
|
|
49
|
+
this.onCancel();
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
_tick() {
|
|
53
|
+
let that = this;
|
|
54
|
+
|
|
55
|
+
if (!that._started) {
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
that.tick();
|
|
60
|
+
|
|
61
|
+
if (!that.done()) {
|
|
62
|
+
animationFrame(that._tickProxy);
|
|
63
|
+
} else {
|
|
64
|
+
that._started = false;
|
|
65
|
+
that.onEnd();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export class Transition extends Animation {
|
|
71
|
+
constructor(options) {
|
|
72
|
+
super();
|
|
73
|
+
extend(this, options);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
done() {
|
|
77
|
+
return this.timePassed() >= this.duration;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
timePassed() {
|
|
81
|
+
return Math.min(this.duration, now() - this.startDate);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
moveTo(options) {
|
|
85
|
+
let that = this,
|
|
86
|
+
movable = that.movable;
|
|
87
|
+
|
|
88
|
+
that.initial = movable[that.axis];
|
|
89
|
+
that.delta = options.location - that.initial;
|
|
90
|
+
that.duration = typeof options.duration === 'number' ? options.duration : 300;
|
|
91
|
+
that.tick = that._easeProxy(options.ease);
|
|
92
|
+
that.startDate = now();
|
|
93
|
+
that.start();
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
_easeProxy(ease) {
|
|
97
|
+
let that = this;
|
|
98
|
+
|
|
99
|
+
return function() {
|
|
100
|
+
that.movable.moveAxis(that.axis, ease(that.timePassed(), that.initial, that.delta, that.duration));
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
static easeOutExpo(t, b, c, d) {
|
|
105
|
+
return t === d ? b + c : c * (-Math.pow(2, -10 * t / d) + 1) + b;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
// static easeOutBack(t, b, c, d) {
|
|
109
|
+
// let s = 1.70158;
|
|
110
|
+
// return c * ((t = t / d - 1) * t * ((s + 1) * t + s) + 1) + b;
|
|
111
|
+
// }
|
|
112
|
+
}
|