three-render-objects 1.28.1 → 1.28.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.
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// Version 1.28.
|
|
1
|
+
// Version 1.28.2 three-render-objects - https://github.com/vasturiano/three-render-objects
|
|
2
2
|
(function (global, factory) {
|
|
3
3
|
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory(require('three')) :
|
|
4
4
|
typeof define === 'function' && define.amd ? define(['three'], factory) :
|
|
@@ -162,6 +162,9 @@
|
|
|
162
162
|
this.minDistance = 0;
|
|
163
163
|
this.maxDistance = Infinity;
|
|
164
164
|
|
|
165
|
+
this.minZoom = 0;
|
|
166
|
+
this.maxZoom = Infinity;
|
|
167
|
+
|
|
165
168
|
this.keys = [ 'KeyA' /*A*/, 'KeyS' /*S*/, 'KeyD' /*D*/ ];
|
|
166
169
|
|
|
167
170
|
this.mouseButtons = { LEFT: three$1.MOUSE.ROTATE, MIDDLE: three$1.MOUSE.DOLLY, RIGHT: three$1.MOUSE.PAN };
|
|
@@ -324,8 +327,13 @@
|
|
|
324
327
|
|
|
325
328
|
} else if ( scope.object.isOrthographicCamera ) {
|
|
326
329
|
|
|
327
|
-
|
|
328
|
-
|
|
330
|
+
scope.object.zoom = three$1.MathUtils.clamp( scope.object.zoom / factor, scope.minZoom, scope.maxZoom );
|
|
331
|
+
|
|
332
|
+
if ( lastZoom !== scope.object.zoom ) {
|
|
333
|
+
|
|
334
|
+
scope.object.updateProjectionMatrix();
|
|
335
|
+
|
|
336
|
+
}
|
|
329
337
|
|
|
330
338
|
} else {
|
|
331
339
|
|
|
@@ -345,8 +353,13 @@
|
|
|
345
353
|
|
|
346
354
|
} else if ( scope.object.isOrthographicCamera ) {
|
|
347
355
|
|
|
348
|
-
scope.object.zoom
|
|
349
|
-
|
|
356
|
+
scope.object.zoom = three$1.MathUtils.clamp( scope.object.zoom / factor, scope.minZoom, scope.maxZoom );
|
|
357
|
+
|
|
358
|
+
if ( lastZoom !== scope.object.zoom ) {
|
|
359
|
+
|
|
360
|
+
scope.object.updateProjectionMatrix();
|
|
361
|
+
|
|
362
|
+
}
|
|
350
363
|
|
|
351
364
|
} else {
|
|
352
365
|
|
|
@@ -930,7 +943,7 @@
|
|
|
930
943
|
|
|
931
944
|
}
|
|
932
945
|
|
|
933
|
-
//
|
|
946
|
+
// OrbitControls performs orbiting, dollying (zooming), and panning.
|
|
934
947
|
// Unlike TrackballControls, it maintains the "up" direction object.up (+Y by default).
|
|
935
948
|
//
|
|
936
949
|
// Orbit - left mouse / touch: one-finger move
|
|
@@ -1046,6 +1059,13 @@
|
|
|
1046
1059
|
|
|
1047
1060
|
};
|
|
1048
1061
|
|
|
1062
|
+
this.stopListenToKeyEvents = function () {
|
|
1063
|
+
|
|
1064
|
+
this._domElementKeyEvents.removeEventListener( 'keydown', onKeyDown );
|
|
1065
|
+
this._domElementKeyEvents = null;
|
|
1066
|
+
|
|
1067
|
+
};
|
|
1068
|
+
|
|
1049
1069
|
this.saveState = function () {
|
|
1050
1070
|
|
|
1051
1071
|
scope.target0.copy( scope.target );
|
|
@@ -1216,7 +1236,7 @@
|
|
|
1216
1236
|
scope.domElement.removeEventListener( 'contextmenu', onContextMenu );
|
|
1217
1237
|
|
|
1218
1238
|
scope.domElement.removeEventListener( 'pointerdown', onPointerDown );
|
|
1219
|
-
scope.domElement.removeEventListener( 'pointercancel',
|
|
1239
|
+
scope.domElement.removeEventListener( 'pointercancel', onPointerUp );
|
|
1220
1240
|
scope.domElement.removeEventListener( 'wheel', onMouseWheel );
|
|
1221
1241
|
|
|
1222
1242
|
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
|
@@ -1226,6 +1246,7 @@
|
|
|
1226
1246
|
if ( scope._domElementKeyEvents !== null ) {
|
|
1227
1247
|
|
|
1228
1248
|
scope._domElementKeyEvents.removeEventListener( 'keydown', onKeyDown );
|
|
1249
|
+
scope._domElementKeyEvents = null;
|
|
1229
1250
|
|
|
1230
1251
|
}
|
|
1231
1252
|
|
|
@@ -1797,26 +1818,20 @@
|
|
|
1797
1818
|
|
|
1798
1819
|
function onPointerUp( event ) {
|
|
1799
1820
|
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
if ( pointers.length === 0 ) {
|
|
1803
|
-
|
|
1804
|
-
scope.domElement.releasePointerCapture( event.pointerId );
|
|
1805
|
-
|
|
1806
|
-
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
|
1807
|
-
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
1821
|
+
removePointer( event );
|
|
1808
1822
|
|
|
1809
|
-
|
|
1823
|
+
if ( pointers.length === 0 ) {
|
|
1810
1824
|
|
|
1811
|
-
|
|
1825
|
+
scope.domElement.releasePointerCapture( event.pointerId );
|
|
1812
1826
|
|
|
1813
|
-
|
|
1827
|
+
scope.domElement.removeEventListener( 'pointermove', onPointerMove );
|
|
1828
|
+
scope.domElement.removeEventListener( 'pointerup', onPointerUp );
|
|
1814
1829
|
|
|
1815
|
-
|
|
1830
|
+
}
|
|
1816
1831
|
|
|
1817
|
-
|
|
1832
|
+
scope.dispatchEvent( _endEvent );
|
|
1818
1833
|
|
|
1819
|
-
|
|
1834
|
+
state = STATE.NONE;
|
|
1820
1835
|
|
|
1821
1836
|
}
|
|
1822
1837
|
|
|
@@ -2168,7 +2183,7 @@
|
|
|
2168
2183
|
scope.domElement.addEventListener( 'contextmenu', onContextMenu );
|
|
2169
2184
|
|
|
2170
2185
|
scope.domElement.addEventListener( 'pointerdown', onPointerDown );
|
|
2171
|
-
scope.domElement.addEventListener( 'pointercancel',
|
|
2186
|
+
scope.domElement.addEventListener( 'pointercancel', onPointerUp );
|
|
2172
2187
|
scope.domElement.addEventListener( 'wheel', onMouseWheel, { passive: false } );
|
|
2173
2188
|
|
|
2174
2189
|
// force an update at start
|
|
@@ -2502,6 +2517,8 @@
|
|
|
2502
2517
|
|
|
2503
2518
|
constructor() {
|
|
2504
2519
|
|
|
2520
|
+
this.isPass = true;
|
|
2521
|
+
|
|
2505
2522
|
// if set to true, the pass is processed by the composer
|
|
2506
2523
|
this.enabled = true;
|
|
2507
2524
|
|
|
@@ -3788,13 +3805,22 @@
|
|
|
3788
3805
|
/**
|
|
3789
3806
|
* The Ease class provides a collection of easing functions for use with tween.js.
|
|
3790
3807
|
*/
|
|
3791
|
-
var Easing = {
|
|
3792
|
-
Linear: {
|
|
3808
|
+
var Easing = Object.freeze({
|
|
3809
|
+
Linear: Object.freeze({
|
|
3793
3810
|
None: function (amount) {
|
|
3794
3811
|
return amount;
|
|
3795
3812
|
},
|
|
3796
|
-
|
|
3797
|
-
|
|
3813
|
+
In: function (amount) {
|
|
3814
|
+
return this.None(amount);
|
|
3815
|
+
},
|
|
3816
|
+
Out: function (amount) {
|
|
3817
|
+
return this.None(amount);
|
|
3818
|
+
},
|
|
3819
|
+
InOut: function (amount) {
|
|
3820
|
+
return this.None(amount);
|
|
3821
|
+
},
|
|
3822
|
+
}),
|
|
3823
|
+
Quadratic: Object.freeze({
|
|
3798
3824
|
In: function (amount) {
|
|
3799
3825
|
return amount * amount;
|
|
3800
3826
|
},
|
|
@@ -3807,8 +3833,8 @@
|
|
|
3807
3833
|
}
|
|
3808
3834
|
return -0.5 * (--amount * (amount - 2) - 1);
|
|
3809
3835
|
},
|
|
3810
|
-
},
|
|
3811
|
-
Cubic: {
|
|
3836
|
+
}),
|
|
3837
|
+
Cubic: Object.freeze({
|
|
3812
3838
|
In: function (amount) {
|
|
3813
3839
|
return amount * amount * amount;
|
|
3814
3840
|
},
|
|
@@ -3821,8 +3847,8 @@
|
|
|
3821
3847
|
}
|
|
3822
3848
|
return 0.5 * ((amount -= 2) * amount * amount + 2);
|
|
3823
3849
|
},
|
|
3824
|
-
},
|
|
3825
|
-
Quartic: {
|
|
3850
|
+
}),
|
|
3851
|
+
Quartic: Object.freeze({
|
|
3826
3852
|
In: function (amount) {
|
|
3827
3853
|
return amount * amount * amount * amount;
|
|
3828
3854
|
},
|
|
@@ -3835,8 +3861,8 @@
|
|
|
3835
3861
|
}
|
|
3836
3862
|
return -0.5 * ((amount -= 2) * amount * amount * amount - 2);
|
|
3837
3863
|
},
|
|
3838
|
-
},
|
|
3839
|
-
Quintic: {
|
|
3864
|
+
}),
|
|
3865
|
+
Quintic: Object.freeze({
|
|
3840
3866
|
In: function (amount) {
|
|
3841
3867
|
return amount * amount * amount * amount * amount;
|
|
3842
3868
|
},
|
|
@@ -3849,19 +3875,19 @@
|
|
|
3849
3875
|
}
|
|
3850
3876
|
return 0.5 * ((amount -= 2) * amount * amount * amount * amount + 2);
|
|
3851
3877
|
},
|
|
3852
|
-
},
|
|
3853
|
-
Sinusoidal: {
|
|
3878
|
+
}),
|
|
3879
|
+
Sinusoidal: Object.freeze({
|
|
3854
3880
|
In: function (amount) {
|
|
3855
|
-
return 1 - Math.
|
|
3881
|
+
return 1 - Math.sin(((1.0 - amount) * Math.PI) / 2);
|
|
3856
3882
|
},
|
|
3857
3883
|
Out: function (amount) {
|
|
3858
3884
|
return Math.sin((amount * Math.PI) / 2);
|
|
3859
3885
|
},
|
|
3860
3886
|
InOut: function (amount) {
|
|
3861
|
-
return 0.5 * (1 - Math.
|
|
3887
|
+
return 0.5 * (1 - Math.sin(Math.PI * (0.5 - amount)));
|
|
3862
3888
|
},
|
|
3863
|
-
},
|
|
3864
|
-
Exponential: {
|
|
3889
|
+
}),
|
|
3890
|
+
Exponential: Object.freeze({
|
|
3865
3891
|
In: function (amount) {
|
|
3866
3892
|
return amount === 0 ? 0 : Math.pow(1024, amount - 1);
|
|
3867
3893
|
},
|
|
@@ -3880,8 +3906,8 @@
|
|
|
3880
3906
|
}
|
|
3881
3907
|
return 0.5 * (-Math.pow(2, -10 * (amount - 1)) + 2);
|
|
3882
3908
|
},
|
|
3883
|
-
},
|
|
3884
|
-
Circular: {
|
|
3909
|
+
}),
|
|
3910
|
+
Circular: Object.freeze({
|
|
3885
3911
|
In: function (amount) {
|
|
3886
3912
|
return 1 - Math.sqrt(1 - amount * amount);
|
|
3887
3913
|
},
|
|
@@ -3894,8 +3920,8 @@
|
|
|
3894
3920
|
}
|
|
3895
3921
|
return 0.5 * (Math.sqrt(1 - (amount -= 2) * amount) + 1);
|
|
3896
3922
|
},
|
|
3897
|
-
},
|
|
3898
|
-
Elastic: {
|
|
3923
|
+
}),
|
|
3924
|
+
Elastic: Object.freeze({
|
|
3899
3925
|
In: function (amount) {
|
|
3900
3926
|
if (amount === 0) {
|
|
3901
3927
|
return 0;
|
|
@@ -3927,15 +3953,15 @@
|
|
|
3927
3953
|
}
|
|
3928
3954
|
return 0.5 * Math.pow(2, -10 * (amount - 1)) * Math.sin((amount - 1.1) * 5 * Math.PI) + 1;
|
|
3929
3955
|
},
|
|
3930
|
-
},
|
|
3931
|
-
Back: {
|
|
3956
|
+
}),
|
|
3957
|
+
Back: Object.freeze({
|
|
3932
3958
|
In: function (amount) {
|
|
3933
3959
|
var s = 1.70158;
|
|
3934
|
-
return amount * amount * ((s + 1) * amount - s);
|
|
3960
|
+
return amount === 1 ? 1 : amount * amount * ((s + 1) * amount - s);
|
|
3935
3961
|
},
|
|
3936
3962
|
Out: function (amount) {
|
|
3937
3963
|
var s = 1.70158;
|
|
3938
|
-
return --amount * amount * ((s + 1) * amount + s) + 1;
|
|
3964
|
+
return amount === 0 ? 0 : --amount * amount * ((s + 1) * amount + s) + 1;
|
|
3939
3965
|
},
|
|
3940
3966
|
InOut: function (amount) {
|
|
3941
3967
|
var s = 1.70158 * 1.525;
|
|
@@ -3944,8 +3970,8 @@
|
|
|
3944
3970
|
}
|
|
3945
3971
|
return 0.5 * ((amount -= 2) * amount * ((s + 1) * amount + s) + 2);
|
|
3946
3972
|
},
|
|
3947
|
-
},
|
|
3948
|
-
Bounce: {
|
|
3973
|
+
}),
|
|
3974
|
+
Bounce: Object.freeze({
|
|
3949
3975
|
In: function (amount) {
|
|
3950
3976
|
return 1 - Easing.Bounce.Out(1 - amount);
|
|
3951
3977
|
},
|
|
@@ -3969,16 +3995,35 @@
|
|
|
3969
3995
|
}
|
|
3970
3996
|
return Easing.Bounce.Out(amount * 2 - 1) * 0.5 + 0.5;
|
|
3971
3997
|
},
|
|
3998
|
+
}),
|
|
3999
|
+
generatePow: function (power) {
|
|
4000
|
+
if (power === void 0) { power = 4; }
|
|
4001
|
+
power = power < Number.EPSILON ? Number.EPSILON : power;
|
|
4002
|
+
power = power > 10000 ? 10000 : power;
|
|
4003
|
+
return {
|
|
4004
|
+
In: function (amount) {
|
|
4005
|
+
return Math.pow(amount, power);
|
|
4006
|
+
},
|
|
4007
|
+
Out: function (amount) {
|
|
4008
|
+
return 1 - Math.pow((1 - amount), power);
|
|
4009
|
+
},
|
|
4010
|
+
InOut: function (amount) {
|
|
4011
|
+
if (amount < 0.5) {
|
|
4012
|
+
return Math.pow((amount * 2), power) / 2;
|
|
4013
|
+
}
|
|
4014
|
+
return (1 - Math.pow((2 - amount * 2), power)) / 2 + 0.5;
|
|
4015
|
+
},
|
|
4016
|
+
};
|
|
3972
4017
|
},
|
|
3973
|
-
};
|
|
4018
|
+
});
|
|
3974
4019
|
|
|
3975
|
-
var now;
|
|
4020
|
+
var now$2;
|
|
3976
4021
|
// Include a performance.now polyfill.
|
|
3977
4022
|
// In node.js, use process.hrtime.
|
|
3978
4023
|
// eslint-disable-next-line
|
|
3979
4024
|
// @ts-ignore
|
|
3980
4025
|
if (typeof self === 'undefined' && typeof process !== 'undefined' && process.hrtime) {
|
|
3981
|
-
now = function () {
|
|
4026
|
+
now$2 = function () {
|
|
3982
4027
|
// eslint-disable-next-line
|
|
3983
4028
|
// @ts-ignore
|
|
3984
4029
|
var time = process.hrtime();
|
|
@@ -3990,19 +4035,19 @@
|
|
|
3990
4035
|
else if (typeof self !== 'undefined' && self.performance !== undefined && self.performance.now !== undefined) {
|
|
3991
4036
|
// This must be bound, because directly assigning this function
|
|
3992
4037
|
// leads to an invocation exception in Chrome.
|
|
3993
|
-
now = self.performance.now.bind(self.performance);
|
|
4038
|
+
now$2 = self.performance.now.bind(self.performance);
|
|
3994
4039
|
}
|
|
3995
4040
|
// Use Date.now if it is available.
|
|
3996
4041
|
else if (Date.now !== undefined) {
|
|
3997
|
-
now = Date.now;
|
|
4042
|
+
now$2 = Date.now;
|
|
3998
4043
|
}
|
|
3999
4044
|
// Otherwise, use 'new Date().getTime()'.
|
|
4000
4045
|
else {
|
|
4001
|
-
now = function () {
|
|
4046
|
+
now$2 = function () {
|
|
4002
4047
|
return new Date().getTime();
|
|
4003
4048
|
};
|
|
4004
4049
|
}
|
|
4005
|
-
var now$1 = now;
|
|
4050
|
+
var now$1$1 = now$2;
|
|
4006
4051
|
|
|
4007
4052
|
/**
|
|
4008
4053
|
* Controlling groups of tweens
|
|
@@ -4033,7 +4078,7 @@
|
|
|
4033
4078
|
delete this._tweensAddedDuringUpdate[tween.getId()];
|
|
4034
4079
|
};
|
|
4035
4080
|
Group.prototype.update = function (time, preserve) {
|
|
4036
|
-
if (time === void 0) { time = now$1(); }
|
|
4081
|
+
if (time === void 0) { time = now$1$1(); }
|
|
4037
4082
|
if (preserve === void 0) { preserve = false; }
|
|
4038
4083
|
var tweenIds = Object.keys(this._tweens);
|
|
4039
4084
|
if (tweenIds.length === 0) {
|
|
@@ -4183,8 +4228,10 @@
|
|
|
4183
4228
|
this._startTime = 0;
|
|
4184
4229
|
this._easingFunction = Easing.Linear.None;
|
|
4185
4230
|
this._interpolationFunction = Interpolation.Linear;
|
|
4231
|
+
// eslint-disable-next-line
|
|
4186
4232
|
this._chainedTweens = [];
|
|
4187
4233
|
this._onStartCallbackFired = false;
|
|
4234
|
+
this._onEveryStartCallbackFired = false;
|
|
4188
4235
|
this._id = Sequence.nextId();
|
|
4189
4236
|
this._isChainStopped = false;
|
|
4190
4237
|
this._goToEnd = false;
|
|
@@ -4210,10 +4257,13 @@
|
|
|
4210
4257
|
return this;
|
|
4211
4258
|
};
|
|
4212
4259
|
Tween.prototype.duration = function (d) {
|
|
4260
|
+
if (d === void 0) { d = 1000; }
|
|
4213
4261
|
this._duration = d;
|
|
4214
4262
|
return this;
|
|
4215
4263
|
};
|
|
4216
|
-
Tween.prototype.start = function (time) {
|
|
4264
|
+
Tween.prototype.start = function (time, overrideStartingValues) {
|
|
4265
|
+
if (time === void 0) { time = now$1$1(); }
|
|
4266
|
+
if (overrideStartingValues === void 0) { overrideStartingValues = false; }
|
|
4217
4267
|
if (this._isPlaying) {
|
|
4218
4268
|
return this;
|
|
4219
4269
|
}
|
|
@@ -4232,13 +4282,17 @@
|
|
|
4232
4282
|
this._isPlaying = true;
|
|
4233
4283
|
this._isPaused = false;
|
|
4234
4284
|
this._onStartCallbackFired = false;
|
|
4285
|
+
this._onEveryStartCallbackFired = false;
|
|
4235
4286
|
this._isChainStopped = false;
|
|
4236
|
-
this._startTime = time
|
|
4287
|
+
this._startTime = time;
|
|
4237
4288
|
this._startTime += this._delayTime;
|
|
4238
|
-
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat);
|
|
4289
|
+
this._setupProperties(this._object, this._valuesStart, this._valuesEnd, this._valuesStartRepeat, overrideStartingValues);
|
|
4239
4290
|
return this;
|
|
4240
4291
|
};
|
|
4241
|
-
Tween.prototype.
|
|
4292
|
+
Tween.prototype.startFromCurrentValues = function (time) {
|
|
4293
|
+
return this.start(time, true);
|
|
4294
|
+
};
|
|
4295
|
+
Tween.prototype._setupProperties = function (_object, _valuesStart, _valuesEnd, _valuesStartRepeat, overrideStartingValues) {
|
|
4242
4296
|
for (var property in _valuesEnd) {
|
|
4243
4297
|
var startValue = _object[property];
|
|
4244
4298
|
var startValueIsArray = Array.isArray(startValue);
|
|
@@ -4258,7 +4312,9 @@
|
|
|
4258
4312
|
// handle an array of relative values
|
|
4259
4313
|
endValues = endValues.map(this._handleRelativeValue.bind(this, startValue));
|
|
4260
4314
|
// Create a local copy of the Array with the start value at the front
|
|
4261
|
-
|
|
4315
|
+
if (_valuesStart[property] === undefined) {
|
|
4316
|
+
_valuesEnd[property] = [startValue].concat(endValues);
|
|
4317
|
+
}
|
|
4262
4318
|
}
|
|
4263
4319
|
// handle the deepness of the values
|
|
4264
4320
|
if ((propType === 'object' || startValueIsArray) && startValue && !isInterpolationList) {
|
|
@@ -4272,11 +4328,11 @@
|
|
|
4272
4328
|
_valuesStartRepeat[property] = startValueIsArray ? [] : {}; // TODO? repeat nested values? And yoyo? And array values?
|
|
4273
4329
|
// eslint-disable-next-line
|
|
4274
4330
|
// @ts-ignore FIXME?
|
|
4275
|
-
this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property]);
|
|
4331
|
+
this._setupProperties(startValue, _valuesStart[property], _valuesEnd[property], _valuesStartRepeat[property], overrideStartingValues);
|
|
4276
4332
|
}
|
|
4277
4333
|
else {
|
|
4278
|
-
// Save the starting value, but only once.
|
|
4279
|
-
if (typeof _valuesStart[property] === 'undefined') {
|
|
4334
|
+
// Save the starting value, but only once unless override is requested.
|
|
4335
|
+
if (typeof _valuesStart[property] === 'undefined' || overrideStartingValues) {
|
|
4280
4336
|
_valuesStart[property] = startValue;
|
|
4281
4337
|
}
|
|
4282
4338
|
if (!startValueIsArray) {
|
|
@@ -4318,7 +4374,7 @@
|
|
|
4318
4374
|
return this;
|
|
4319
4375
|
};
|
|
4320
4376
|
Tween.prototype.pause = function (time) {
|
|
4321
|
-
if (time === void 0) { time = now$1(); }
|
|
4377
|
+
if (time === void 0) { time = now$1$1(); }
|
|
4322
4378
|
if (this._isPaused || !this._isPlaying) {
|
|
4323
4379
|
return this;
|
|
4324
4380
|
}
|
|
@@ -4329,7 +4385,7 @@
|
|
|
4329
4385
|
return this;
|
|
4330
4386
|
};
|
|
4331
4387
|
Tween.prototype.resume = function (time) {
|
|
4332
|
-
if (time === void 0) { time = now$1(); }
|
|
4388
|
+
if (time === void 0) { time = now$1$1(); }
|
|
4333
4389
|
if (!this._isPaused || !this._isPlaying) {
|
|
4334
4390
|
return this;
|
|
4335
4391
|
}
|
|
@@ -4347,14 +4403,17 @@
|
|
|
4347
4403
|
return this;
|
|
4348
4404
|
};
|
|
4349
4405
|
Tween.prototype.group = function (group) {
|
|
4406
|
+
if (group === void 0) { group = mainGroup; }
|
|
4350
4407
|
this._group = group;
|
|
4351
4408
|
return this;
|
|
4352
4409
|
};
|
|
4353
4410
|
Tween.prototype.delay = function (amount) {
|
|
4411
|
+
if (amount === void 0) { amount = 0; }
|
|
4354
4412
|
this._delayTime = amount;
|
|
4355
4413
|
return this;
|
|
4356
4414
|
};
|
|
4357
4415
|
Tween.prototype.repeat = function (times) {
|
|
4416
|
+
if (times === void 0) { times = 0; }
|
|
4358
4417
|
this._initialRepeat = times;
|
|
4359
4418
|
this._repeat = times;
|
|
4360
4419
|
return this;
|
|
@@ -4364,17 +4423,21 @@
|
|
|
4364
4423
|
return this;
|
|
4365
4424
|
};
|
|
4366
4425
|
Tween.prototype.yoyo = function (yoyo) {
|
|
4426
|
+
if (yoyo === void 0) { yoyo = false; }
|
|
4367
4427
|
this._yoyo = yoyo;
|
|
4368
4428
|
return this;
|
|
4369
4429
|
};
|
|
4370
4430
|
Tween.prototype.easing = function (easingFunction) {
|
|
4431
|
+
if (easingFunction === void 0) { easingFunction = Easing.Linear.None; }
|
|
4371
4432
|
this._easingFunction = easingFunction;
|
|
4372
4433
|
return this;
|
|
4373
4434
|
};
|
|
4374
4435
|
Tween.prototype.interpolation = function (interpolationFunction) {
|
|
4436
|
+
if (interpolationFunction === void 0) { interpolationFunction = Interpolation.Linear; }
|
|
4375
4437
|
this._interpolationFunction = interpolationFunction;
|
|
4376
4438
|
return this;
|
|
4377
4439
|
};
|
|
4440
|
+
// eslint-disable-next-line
|
|
4378
4441
|
Tween.prototype.chain = function () {
|
|
4379
4442
|
var tweens = [];
|
|
4380
4443
|
for (var _i = 0; _i < arguments.length; _i++) {
|
|
@@ -4387,6 +4450,10 @@
|
|
|
4387
4450
|
this._onStartCallback = callback;
|
|
4388
4451
|
return this;
|
|
4389
4452
|
};
|
|
4453
|
+
Tween.prototype.onEveryStart = function (callback) {
|
|
4454
|
+
this._onEveryStartCallback = callback;
|
|
4455
|
+
return this;
|
|
4456
|
+
};
|
|
4390
4457
|
Tween.prototype.onUpdate = function (callback) {
|
|
4391
4458
|
this._onUpdateCallback = callback;
|
|
4392
4459
|
return this;
|
|
@@ -4409,7 +4476,7 @@
|
|
|
4409
4476
|
* it is still playing, just paused).
|
|
4410
4477
|
*/
|
|
4411
4478
|
Tween.prototype.update = function (time, autoStart) {
|
|
4412
|
-
if (time === void 0) { time = now$1(); }
|
|
4479
|
+
if (time === void 0) { time = now$1$1(); }
|
|
4413
4480
|
if (autoStart === void 0) { autoStart = true; }
|
|
4414
4481
|
if (this._isPaused)
|
|
4415
4482
|
return true;
|
|
@@ -4420,7 +4487,7 @@
|
|
|
4420
4487
|
if (time > endTime)
|
|
4421
4488
|
return false;
|
|
4422
4489
|
if (autoStart)
|
|
4423
|
-
this.start(time);
|
|
4490
|
+
this.start(time, true);
|
|
4424
4491
|
}
|
|
4425
4492
|
this._goToEnd = false;
|
|
4426
4493
|
if (time < this._startTime) {
|
|
@@ -4432,6 +4499,12 @@
|
|
|
4432
4499
|
}
|
|
4433
4500
|
this._onStartCallbackFired = true;
|
|
4434
4501
|
}
|
|
4502
|
+
if (this._onEveryStartCallbackFired === false) {
|
|
4503
|
+
if (this._onEveryStartCallback) {
|
|
4504
|
+
this._onEveryStartCallback(this._object);
|
|
4505
|
+
}
|
|
4506
|
+
this._onEveryStartCallbackFired = true;
|
|
4507
|
+
}
|
|
4435
4508
|
elapsed = (time - this._startTime) / this._duration;
|
|
4436
4509
|
elapsed = this._duration === 0 || elapsed > 1 ? 1 : elapsed;
|
|
4437
4510
|
var value = this._easingFunction(elapsed);
|
|
@@ -4470,6 +4543,7 @@
|
|
|
4470
4543
|
if (this._onRepeatCallback) {
|
|
4471
4544
|
this._onRepeatCallback(this._object);
|
|
4472
4545
|
}
|
|
4546
|
+
this._onEveryStartCallbackFired = false;
|
|
4473
4547
|
return true;
|
|
4474
4548
|
}
|
|
4475
4549
|
else {
|
|
@@ -4479,7 +4553,7 @@
|
|
|
4479
4553
|
for (var i = 0, numChainedTweens = this._chainedTweens.length; i < numChainedTweens; i++) {
|
|
4480
4554
|
// Make the chained tweens start exactly at the time they should,
|
|
4481
4555
|
// even if the `update()` method was called way past the duration of the tween
|
|
4482
|
-
this._chainedTweens[i].start(this._startTime + this._duration);
|
|
4556
|
+
this._chainedTweens[i].start(this._startTime + this._duration, false);
|
|
4483
4557
|
}
|
|
4484
4558
|
this._isPlaying = false;
|
|
4485
4559
|
return false;
|
|
@@ -4543,7 +4617,7 @@
|
|
|
4543
4617
|
return Tween;
|
|
4544
4618
|
}());
|
|
4545
4619
|
|
|
4546
|
-
var VERSION = '
|
|
4620
|
+
var VERSION = '19.0.0';
|
|
4547
4621
|
|
|
4548
4622
|
/**
|
|
4549
4623
|
* Tween.js - Licensed under the MIT license
|
|
@@ -4574,7 +4648,7 @@
|
|
|
4574
4648
|
Easing: Easing,
|
|
4575
4649
|
Group: Group,
|
|
4576
4650
|
Interpolation: Interpolation,
|
|
4577
|
-
now: now$1,
|
|
4651
|
+
now: now$1$1,
|
|
4578
4652
|
Sequence: Sequence,
|
|
4579
4653
|
nextId: nextId,
|
|
4580
4654
|
Tween: Tween,
|
|
@@ -4596,75 +4670,494 @@
|
|
|
4596
4670
|
};
|
|
4597
4671
|
}); // constant
|
|
4598
4672
|
|
|
4673
|
+
/** Detect free variable `global` from Node.js. */
|
|
4674
|
+
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;
|
|
4675
|
+
|
|
4676
|
+
var freeGlobal$1 = freeGlobal;
|
|
4677
|
+
|
|
4678
|
+
/** Detect free variable `self`. */
|
|
4679
|
+
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;
|
|
4680
|
+
|
|
4681
|
+
/** Used as a reference to the global object. */
|
|
4682
|
+
var root = freeGlobal$1 || freeSelf || Function('return this')();
|
|
4683
|
+
|
|
4684
|
+
var root$1 = root;
|
|
4685
|
+
|
|
4686
|
+
/** Built-in value references. */
|
|
4687
|
+
var Symbol$1 = root$1.Symbol;
|
|
4688
|
+
|
|
4689
|
+
var Symbol$2 = Symbol$1;
|
|
4690
|
+
|
|
4691
|
+
/** Used for built-in method references. */
|
|
4692
|
+
var objectProto$1 = Object.prototype;
|
|
4693
|
+
|
|
4694
|
+
/** Used to check objects for own properties. */
|
|
4695
|
+
var hasOwnProperty = objectProto$1.hasOwnProperty;
|
|
4696
|
+
|
|
4599
4697
|
/**
|
|
4600
|
-
*
|
|
4601
|
-
*
|
|
4602
|
-
*
|
|
4603
|
-
* leading edge, instead of the trailing. The function also has a property 'clear'
|
|
4604
|
-
* that is a function which will clear the timer to prevent previously scheduled executions.
|
|
4605
|
-
*
|
|
4606
|
-
* @source underscore.js
|
|
4607
|
-
* @see http://unscriptable.com/2009/03/20/debouncing-javascript-methods/
|
|
4608
|
-
* @param {Function} function to wrap
|
|
4609
|
-
* @param {Number} timeout in ms (`100`)
|
|
4610
|
-
* @param {Boolean} whether to execute at the beginning (`false`)
|
|
4611
|
-
* @api public
|
|
4698
|
+
* Used to resolve the
|
|
4699
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
4700
|
+
* of values.
|
|
4612
4701
|
*/
|
|
4702
|
+
var nativeObjectToString$1 = objectProto$1.toString;
|
|
4613
4703
|
|
|
4614
|
-
|
|
4615
|
-
|
|
4616
|
-
if (null == wait) wait = 100;
|
|
4704
|
+
/** Built-in value references. */
|
|
4705
|
+
var symToStringTag$1 = Symbol$2 ? Symbol$2.toStringTag : undefined;
|
|
4617
4706
|
|
|
4618
|
-
|
|
4619
|
-
|
|
4707
|
+
/**
|
|
4708
|
+
* A specialized version of `baseGetTag` which ignores `Symbol.toStringTag` values.
|
|
4709
|
+
*
|
|
4710
|
+
* @private
|
|
4711
|
+
* @param {*} value The value to query.
|
|
4712
|
+
* @returns {string} Returns the raw `toStringTag`.
|
|
4713
|
+
*/
|
|
4714
|
+
function getRawTag(value) {
|
|
4715
|
+
var isOwn = hasOwnProperty.call(value, symToStringTag$1),
|
|
4716
|
+
tag = value[symToStringTag$1];
|
|
4620
4717
|
|
|
4621
|
-
|
|
4622
|
-
|
|
4718
|
+
try {
|
|
4719
|
+
value[symToStringTag$1] = undefined;
|
|
4720
|
+
var unmasked = true;
|
|
4721
|
+
} catch (e) {}
|
|
4722
|
+
|
|
4723
|
+
var result = nativeObjectToString$1.call(value);
|
|
4724
|
+
if (unmasked) {
|
|
4725
|
+
if (isOwn) {
|
|
4726
|
+
value[symToStringTag$1] = tag;
|
|
4623
4727
|
} else {
|
|
4624
|
-
|
|
4625
|
-
if (!immediate) {
|
|
4626
|
-
result = func.apply(context, args);
|
|
4627
|
-
context = args = null;
|
|
4628
|
-
}
|
|
4728
|
+
delete value[symToStringTag$1];
|
|
4629
4729
|
}
|
|
4630
4730
|
}
|
|
4631
|
-
|
|
4632
|
-
|
|
4633
|
-
|
|
4634
|
-
|
|
4635
|
-
|
|
4636
|
-
|
|
4637
|
-
|
|
4638
|
-
|
|
4639
|
-
|
|
4640
|
-
|
|
4731
|
+
return result;
|
|
4732
|
+
}
|
|
4733
|
+
|
|
4734
|
+
/** Used for built-in method references. */
|
|
4735
|
+
var objectProto = Object.prototype;
|
|
4736
|
+
|
|
4737
|
+
/**
|
|
4738
|
+
* Used to resolve the
|
|
4739
|
+
* [`toStringTag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
|
|
4740
|
+
* of values.
|
|
4741
|
+
*/
|
|
4742
|
+
var nativeObjectToString = objectProto.toString;
|
|
4743
|
+
|
|
4744
|
+
/**
|
|
4745
|
+
* Converts `value` to a string using `Object.prototype.toString`.
|
|
4746
|
+
*
|
|
4747
|
+
* @private
|
|
4748
|
+
* @param {*} value The value to convert.
|
|
4749
|
+
* @returns {string} Returns the converted string.
|
|
4750
|
+
*/
|
|
4751
|
+
function objectToString(value) {
|
|
4752
|
+
return nativeObjectToString.call(value);
|
|
4753
|
+
}
|
|
4754
|
+
|
|
4755
|
+
/** `Object#toString` result references. */
|
|
4756
|
+
var nullTag = '[object Null]',
|
|
4757
|
+
undefinedTag = '[object Undefined]';
|
|
4758
|
+
|
|
4759
|
+
/** Built-in value references. */
|
|
4760
|
+
var symToStringTag = Symbol$2 ? Symbol$2.toStringTag : undefined;
|
|
4761
|
+
|
|
4762
|
+
/**
|
|
4763
|
+
* The base implementation of `getTag` without fallbacks for buggy environments.
|
|
4764
|
+
*
|
|
4765
|
+
* @private
|
|
4766
|
+
* @param {*} value The value to query.
|
|
4767
|
+
* @returns {string} Returns the `toStringTag`.
|
|
4768
|
+
*/
|
|
4769
|
+
function baseGetTag(value) {
|
|
4770
|
+
if (value == null) {
|
|
4771
|
+
return value === undefined ? undefinedTag : nullTag;
|
|
4772
|
+
}
|
|
4773
|
+
return (symToStringTag && symToStringTag in Object(value))
|
|
4774
|
+
? getRawTag(value)
|
|
4775
|
+
: objectToString(value);
|
|
4776
|
+
}
|
|
4777
|
+
|
|
4778
|
+
/**
|
|
4779
|
+
* Checks if `value` is object-like. A value is object-like if it's not `null`
|
|
4780
|
+
* and has a `typeof` result of "object".
|
|
4781
|
+
*
|
|
4782
|
+
* @static
|
|
4783
|
+
* @memberOf _
|
|
4784
|
+
* @since 4.0.0
|
|
4785
|
+
* @category Lang
|
|
4786
|
+
* @param {*} value The value to check.
|
|
4787
|
+
* @returns {boolean} Returns `true` if `value` is object-like, else `false`.
|
|
4788
|
+
* @example
|
|
4789
|
+
*
|
|
4790
|
+
* _.isObjectLike({});
|
|
4791
|
+
* // => true
|
|
4792
|
+
*
|
|
4793
|
+
* _.isObjectLike([1, 2, 3]);
|
|
4794
|
+
* // => true
|
|
4795
|
+
*
|
|
4796
|
+
* _.isObjectLike(_.noop);
|
|
4797
|
+
* // => false
|
|
4798
|
+
*
|
|
4799
|
+
* _.isObjectLike(null);
|
|
4800
|
+
* // => false
|
|
4801
|
+
*/
|
|
4802
|
+
function isObjectLike(value) {
|
|
4803
|
+
return value != null && typeof value == 'object';
|
|
4804
|
+
}
|
|
4805
|
+
|
|
4806
|
+
/** `Object#toString` result references. */
|
|
4807
|
+
var symbolTag = '[object Symbol]';
|
|
4808
|
+
|
|
4809
|
+
/**
|
|
4810
|
+
* Checks if `value` is classified as a `Symbol` primitive or object.
|
|
4811
|
+
*
|
|
4812
|
+
* @static
|
|
4813
|
+
* @memberOf _
|
|
4814
|
+
* @since 4.0.0
|
|
4815
|
+
* @category Lang
|
|
4816
|
+
* @param {*} value The value to check.
|
|
4817
|
+
* @returns {boolean} Returns `true` if `value` is a symbol, else `false`.
|
|
4818
|
+
* @example
|
|
4819
|
+
*
|
|
4820
|
+
* _.isSymbol(Symbol.iterator);
|
|
4821
|
+
* // => true
|
|
4822
|
+
*
|
|
4823
|
+
* _.isSymbol('abc');
|
|
4824
|
+
* // => false
|
|
4825
|
+
*/
|
|
4826
|
+
function isSymbol(value) {
|
|
4827
|
+
return typeof value == 'symbol' ||
|
|
4828
|
+
(isObjectLike(value) && baseGetTag(value) == symbolTag);
|
|
4829
|
+
}
|
|
4830
|
+
|
|
4831
|
+
/** Used to match a single whitespace character. */
|
|
4832
|
+
var reWhitespace = /\s/;
|
|
4833
|
+
|
|
4834
|
+
/**
|
|
4835
|
+
* Used by `_.trim` and `_.trimEnd` to get the index of the last non-whitespace
|
|
4836
|
+
* character of `string`.
|
|
4837
|
+
*
|
|
4838
|
+
* @private
|
|
4839
|
+
* @param {string} string The string to inspect.
|
|
4840
|
+
* @returns {number} Returns the index of the last non-whitespace character.
|
|
4841
|
+
*/
|
|
4842
|
+
function trimmedEndIndex(string) {
|
|
4843
|
+
var index = string.length;
|
|
4844
|
+
|
|
4845
|
+
while (index-- && reWhitespace.test(string.charAt(index))) {}
|
|
4846
|
+
return index;
|
|
4847
|
+
}
|
|
4848
|
+
|
|
4849
|
+
/** Used to match leading whitespace. */
|
|
4850
|
+
var reTrimStart = /^\s+/;
|
|
4851
|
+
|
|
4852
|
+
/**
|
|
4853
|
+
* The base implementation of `_.trim`.
|
|
4854
|
+
*
|
|
4855
|
+
* @private
|
|
4856
|
+
* @param {string} string The string to trim.
|
|
4857
|
+
* @returns {string} Returns the trimmed string.
|
|
4858
|
+
*/
|
|
4859
|
+
function baseTrim(string) {
|
|
4860
|
+
return string
|
|
4861
|
+
? string.slice(0, trimmedEndIndex(string) + 1).replace(reTrimStart, '')
|
|
4862
|
+
: string;
|
|
4863
|
+
}
|
|
4864
|
+
|
|
4865
|
+
/**
|
|
4866
|
+
* Checks if `value` is the
|
|
4867
|
+
* [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
|
|
4868
|
+
* of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
|
|
4869
|
+
*
|
|
4870
|
+
* @static
|
|
4871
|
+
* @memberOf _
|
|
4872
|
+
* @since 0.1.0
|
|
4873
|
+
* @category Lang
|
|
4874
|
+
* @param {*} value The value to check.
|
|
4875
|
+
* @returns {boolean} Returns `true` if `value` is an object, else `false`.
|
|
4876
|
+
* @example
|
|
4877
|
+
*
|
|
4878
|
+
* _.isObject({});
|
|
4879
|
+
* // => true
|
|
4880
|
+
*
|
|
4881
|
+
* _.isObject([1, 2, 3]);
|
|
4882
|
+
* // => true
|
|
4883
|
+
*
|
|
4884
|
+
* _.isObject(_.noop);
|
|
4885
|
+
* // => true
|
|
4886
|
+
*
|
|
4887
|
+
* _.isObject(null);
|
|
4888
|
+
* // => false
|
|
4889
|
+
*/
|
|
4890
|
+
function isObject(value) {
|
|
4891
|
+
var type = typeof value;
|
|
4892
|
+
return value != null && (type == 'object' || type == 'function');
|
|
4893
|
+
}
|
|
4894
|
+
|
|
4895
|
+
/** Used as references for various `Number` constants. */
|
|
4896
|
+
var NAN = 0 / 0;
|
|
4897
|
+
|
|
4898
|
+
/** Used to detect bad signed hexadecimal string values. */
|
|
4899
|
+
var reIsBadHex = /^[-+]0x[0-9a-f]+$/i;
|
|
4900
|
+
|
|
4901
|
+
/** Used to detect binary string values. */
|
|
4902
|
+
var reIsBinary = /^0b[01]+$/i;
|
|
4903
|
+
|
|
4904
|
+
/** Used to detect octal string values. */
|
|
4905
|
+
var reIsOctal = /^0o[0-7]+$/i;
|
|
4906
|
+
|
|
4907
|
+
/** Built-in method references without a dependency on `root`. */
|
|
4908
|
+
var freeParseInt = parseInt;
|
|
4909
|
+
|
|
4910
|
+
/**
|
|
4911
|
+
* Converts `value` to a number.
|
|
4912
|
+
*
|
|
4913
|
+
* @static
|
|
4914
|
+
* @memberOf _
|
|
4915
|
+
* @since 4.0.0
|
|
4916
|
+
* @category Lang
|
|
4917
|
+
* @param {*} value The value to process.
|
|
4918
|
+
* @returns {number} Returns the number.
|
|
4919
|
+
* @example
|
|
4920
|
+
*
|
|
4921
|
+
* _.toNumber(3.2);
|
|
4922
|
+
* // => 3.2
|
|
4923
|
+
*
|
|
4924
|
+
* _.toNumber(Number.MIN_VALUE);
|
|
4925
|
+
* // => 5e-324
|
|
4926
|
+
*
|
|
4927
|
+
* _.toNumber(Infinity);
|
|
4928
|
+
* // => Infinity
|
|
4929
|
+
*
|
|
4930
|
+
* _.toNumber('3.2');
|
|
4931
|
+
* // => 3.2
|
|
4932
|
+
*/
|
|
4933
|
+
function toNumber(value) {
|
|
4934
|
+
if (typeof value == 'number') {
|
|
4935
|
+
return value;
|
|
4936
|
+
}
|
|
4937
|
+
if (isSymbol(value)) {
|
|
4938
|
+
return NAN;
|
|
4939
|
+
}
|
|
4940
|
+
if (isObject(value)) {
|
|
4941
|
+
var other = typeof value.valueOf == 'function' ? value.valueOf() : value;
|
|
4942
|
+
value = isObject(other) ? (other + '') : other;
|
|
4943
|
+
}
|
|
4944
|
+
if (typeof value != 'string') {
|
|
4945
|
+
return value === 0 ? value : +value;
|
|
4946
|
+
}
|
|
4947
|
+
value = baseTrim(value);
|
|
4948
|
+
var isBinary = reIsBinary.test(value);
|
|
4949
|
+
return (isBinary || reIsOctal.test(value))
|
|
4950
|
+
? freeParseInt(value.slice(2), isBinary ? 2 : 8)
|
|
4951
|
+
: (reIsBadHex.test(value) ? NAN : +value);
|
|
4952
|
+
}
|
|
4953
|
+
|
|
4954
|
+
/**
|
|
4955
|
+
* Gets the timestamp of the number of milliseconds that have elapsed since
|
|
4956
|
+
* the Unix epoch (1 January 1970 00:00:00 UTC).
|
|
4957
|
+
*
|
|
4958
|
+
* @static
|
|
4959
|
+
* @memberOf _
|
|
4960
|
+
* @since 2.4.0
|
|
4961
|
+
* @category Date
|
|
4962
|
+
* @returns {number} Returns the timestamp.
|
|
4963
|
+
* @example
|
|
4964
|
+
*
|
|
4965
|
+
* _.defer(function(stamp) {
|
|
4966
|
+
* console.log(_.now() - stamp);
|
|
4967
|
+
* }, _.now());
|
|
4968
|
+
* // => Logs the number of milliseconds it took for the deferred invocation.
|
|
4969
|
+
*/
|
|
4970
|
+
var now = function() {
|
|
4971
|
+
return root$1.Date.now();
|
|
4972
|
+
};
|
|
4973
|
+
|
|
4974
|
+
var now$1 = now;
|
|
4975
|
+
|
|
4976
|
+
/** Error message constants. */
|
|
4977
|
+
var FUNC_ERROR_TEXT = 'Expected a function';
|
|
4978
|
+
|
|
4979
|
+
/* Built-in method references for those with the same name as other `lodash` methods. */
|
|
4980
|
+
var nativeMax = Math.max,
|
|
4981
|
+
nativeMin = Math.min;
|
|
4641
4982
|
|
|
4983
|
+
/**
|
|
4984
|
+
* Creates a debounced function that delays invoking `func` until after `wait`
|
|
4985
|
+
* milliseconds have elapsed since the last time the debounced function was
|
|
4986
|
+
* invoked. The debounced function comes with a `cancel` method to cancel
|
|
4987
|
+
* delayed `func` invocations and a `flush` method to immediately invoke them.
|
|
4988
|
+
* Provide `options` to indicate whether `func` should be invoked on the
|
|
4989
|
+
* leading and/or trailing edge of the `wait` timeout. The `func` is invoked
|
|
4990
|
+
* with the last arguments provided to the debounced function. Subsequent
|
|
4991
|
+
* calls to the debounced function return the result of the last `func`
|
|
4992
|
+
* invocation.
|
|
4993
|
+
*
|
|
4994
|
+
* **Note:** If `leading` and `trailing` options are `true`, `func` is
|
|
4995
|
+
* invoked on the trailing edge of the timeout only if the debounced function
|
|
4996
|
+
* is invoked more than once during the `wait` timeout.
|
|
4997
|
+
*
|
|
4998
|
+
* If `wait` is `0` and `leading` is `false`, `func` invocation is deferred
|
|
4999
|
+
* until to the next tick, similar to `setTimeout` with a timeout of `0`.
|
|
5000
|
+
*
|
|
5001
|
+
* See [David Corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
|
|
5002
|
+
* for details over the differences between `_.debounce` and `_.throttle`.
|
|
5003
|
+
*
|
|
5004
|
+
* @static
|
|
5005
|
+
* @memberOf _
|
|
5006
|
+
* @since 0.1.0
|
|
5007
|
+
* @category Function
|
|
5008
|
+
* @param {Function} func The function to debounce.
|
|
5009
|
+
* @param {number} [wait=0] The number of milliseconds to delay.
|
|
5010
|
+
* @param {Object} [options={}] The options object.
|
|
5011
|
+
* @param {boolean} [options.leading=false]
|
|
5012
|
+
* Specify invoking on the leading edge of the timeout.
|
|
5013
|
+
* @param {number} [options.maxWait]
|
|
5014
|
+
* The maximum time `func` is allowed to be delayed before it's invoked.
|
|
5015
|
+
* @param {boolean} [options.trailing=true]
|
|
5016
|
+
* Specify invoking on the trailing edge of the timeout.
|
|
5017
|
+
* @returns {Function} Returns the new debounced function.
|
|
5018
|
+
* @example
|
|
5019
|
+
*
|
|
5020
|
+
* // Avoid costly calculations while the window size is in flux.
|
|
5021
|
+
* jQuery(window).on('resize', _.debounce(calculateLayout, 150));
|
|
5022
|
+
*
|
|
5023
|
+
* // Invoke `sendMail` when clicked, debouncing subsequent calls.
|
|
5024
|
+
* jQuery(element).on('click', _.debounce(sendMail, 300, {
|
|
5025
|
+
* 'leading': true,
|
|
5026
|
+
* 'trailing': false
|
|
5027
|
+
* }));
|
|
5028
|
+
*
|
|
5029
|
+
* // Ensure `batchLog` is invoked once after 1 second of debounced calls.
|
|
5030
|
+
* var debounced = _.debounce(batchLog, 250, { 'maxWait': 1000 });
|
|
5031
|
+
* var source = new EventSource('/stream');
|
|
5032
|
+
* jQuery(source).on('message', debounced);
|
|
5033
|
+
*
|
|
5034
|
+
* // Cancel the trailing debounced invocation.
|
|
5035
|
+
* jQuery(window).on('popstate', debounced.cancel);
|
|
5036
|
+
*/
|
|
5037
|
+
function debounce(func, wait, options) {
|
|
5038
|
+
var lastArgs,
|
|
5039
|
+
lastThis,
|
|
5040
|
+
maxWait,
|
|
5041
|
+
result,
|
|
5042
|
+
timerId,
|
|
5043
|
+
lastCallTime,
|
|
5044
|
+
lastInvokeTime = 0,
|
|
5045
|
+
leading = false,
|
|
5046
|
+
maxing = false,
|
|
5047
|
+
trailing = true;
|
|
5048
|
+
|
|
5049
|
+
if (typeof func != 'function') {
|
|
5050
|
+
throw new TypeError(FUNC_ERROR_TEXT);
|
|
5051
|
+
}
|
|
5052
|
+
wait = toNumber(wait) || 0;
|
|
5053
|
+
if (isObject(options)) {
|
|
5054
|
+
leading = !!options.leading;
|
|
5055
|
+
maxing = 'maxWait' in options;
|
|
5056
|
+
maxWait = maxing ? nativeMax(toNumber(options.maxWait) || 0, wait) : maxWait;
|
|
5057
|
+
trailing = 'trailing' in options ? !!options.trailing : trailing;
|
|
5058
|
+
}
|
|
5059
|
+
|
|
5060
|
+
function invokeFunc(time) {
|
|
5061
|
+
var args = lastArgs,
|
|
5062
|
+
thisArg = lastThis;
|
|
5063
|
+
|
|
5064
|
+
lastArgs = lastThis = undefined;
|
|
5065
|
+
lastInvokeTime = time;
|
|
5066
|
+
result = func.apply(thisArg, args);
|
|
4642
5067
|
return result;
|
|
4643
|
-
}
|
|
5068
|
+
}
|
|
5069
|
+
|
|
5070
|
+
function leadingEdge(time) {
|
|
5071
|
+
// Reset any `maxWait` timer.
|
|
5072
|
+
lastInvokeTime = time;
|
|
5073
|
+
// Start the timer for the trailing edge.
|
|
5074
|
+
timerId = setTimeout(timerExpired, wait);
|
|
5075
|
+
// Invoke the leading edge.
|
|
5076
|
+
return leading ? invokeFunc(time) : result;
|
|
5077
|
+
}
|
|
5078
|
+
|
|
5079
|
+
function remainingWait(time) {
|
|
5080
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
5081
|
+
timeSinceLastInvoke = time - lastInvokeTime,
|
|
5082
|
+
timeWaiting = wait - timeSinceLastCall;
|
|
4644
5083
|
|
|
4645
|
-
|
|
4646
|
-
|
|
4647
|
-
|
|
4648
|
-
|
|
5084
|
+
return maxing
|
|
5085
|
+
? nativeMin(timeWaiting, maxWait - timeSinceLastInvoke)
|
|
5086
|
+
: timeWaiting;
|
|
5087
|
+
}
|
|
5088
|
+
|
|
5089
|
+
function shouldInvoke(time) {
|
|
5090
|
+
var timeSinceLastCall = time - lastCallTime,
|
|
5091
|
+
timeSinceLastInvoke = time - lastInvokeTime;
|
|
5092
|
+
|
|
5093
|
+
// Either this is the first call, activity has stopped and we're at the
|
|
5094
|
+
// trailing edge, the system time has gone backwards and we're treating
|
|
5095
|
+
// it as the trailing edge, or we've hit the `maxWait` limit.
|
|
5096
|
+
return (lastCallTime === undefined || (timeSinceLastCall >= wait) ||
|
|
5097
|
+
(timeSinceLastCall < 0) || (maxing && timeSinceLastInvoke >= maxWait));
|
|
5098
|
+
}
|
|
5099
|
+
|
|
5100
|
+
function timerExpired() {
|
|
5101
|
+
var time = now$1();
|
|
5102
|
+
if (shouldInvoke(time)) {
|
|
5103
|
+
return trailingEdge(time);
|
|
4649
5104
|
}
|
|
4650
|
-
|
|
4651
|
-
|
|
4652
|
-
|
|
4653
|
-
|
|
4654
|
-
|
|
4655
|
-
|
|
4656
|
-
|
|
4657
|
-
|
|
4658
|
-
|
|
5105
|
+
// Restart the timer.
|
|
5106
|
+
timerId = setTimeout(timerExpired, remainingWait(time));
|
|
5107
|
+
}
|
|
5108
|
+
|
|
5109
|
+
function trailingEdge(time) {
|
|
5110
|
+
timerId = undefined;
|
|
5111
|
+
|
|
5112
|
+
// Only invoke if we have `lastArgs` which means `func` has been
|
|
5113
|
+
// debounced at least once.
|
|
5114
|
+
if (trailing && lastArgs) {
|
|
5115
|
+
return invokeFunc(time);
|
|
4659
5116
|
}
|
|
4660
|
-
|
|
5117
|
+
lastArgs = lastThis = undefined;
|
|
5118
|
+
return result;
|
|
5119
|
+
}
|
|
5120
|
+
|
|
5121
|
+
function cancel() {
|
|
5122
|
+
if (timerId !== undefined) {
|
|
5123
|
+
clearTimeout(timerId);
|
|
5124
|
+
}
|
|
5125
|
+
lastInvokeTime = 0;
|
|
5126
|
+
lastArgs = lastCallTime = lastThis = timerId = undefined;
|
|
5127
|
+
}
|
|
5128
|
+
|
|
5129
|
+
function flush() {
|
|
5130
|
+
return timerId === undefined ? result : trailingEdge(now$1());
|
|
5131
|
+
}
|
|
4661
5132
|
|
|
5133
|
+
function debounced() {
|
|
5134
|
+
var time = now$1(),
|
|
5135
|
+
isInvoking = shouldInvoke(time);
|
|
5136
|
+
|
|
5137
|
+
lastArgs = arguments;
|
|
5138
|
+
lastThis = this;
|
|
5139
|
+
lastCallTime = time;
|
|
5140
|
+
|
|
5141
|
+
if (isInvoking) {
|
|
5142
|
+
if (timerId === undefined) {
|
|
5143
|
+
return leadingEdge(lastCallTime);
|
|
5144
|
+
}
|
|
5145
|
+
if (maxing) {
|
|
5146
|
+
// Handle invocations in a tight loop.
|
|
5147
|
+
clearTimeout(timerId);
|
|
5148
|
+
timerId = setTimeout(timerExpired, wait);
|
|
5149
|
+
return invokeFunc(lastCallTime);
|
|
5150
|
+
}
|
|
5151
|
+
}
|
|
5152
|
+
if (timerId === undefined) {
|
|
5153
|
+
timerId = setTimeout(timerExpired, wait);
|
|
5154
|
+
}
|
|
5155
|
+
return result;
|
|
5156
|
+
}
|
|
5157
|
+
debounced.cancel = cancel;
|
|
5158
|
+
debounced.flush = flush;
|
|
4662
5159
|
return debounced;
|
|
4663
5160
|
}
|
|
4664
|
-
// Adds compatibility for ES modules
|
|
4665
|
-
debounce.debounce = debounce;
|
|
4666
|
-
|
|
4667
|
-
var debounce_1 = debounce;
|
|
4668
5161
|
|
|
4669
5162
|
function _iterableToArrayLimit(arr, i) {
|
|
4670
5163
|
var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"];
|
|
@@ -4806,7 +5299,7 @@
|
|
|
4806
5299
|
initFn.call(comp, nodeElement, state, options);
|
|
4807
5300
|
state.initialised = true;
|
|
4808
5301
|
};
|
|
4809
|
-
var digest =
|
|
5302
|
+
var digest = debounce(function () {
|
|
4810
5303
|
if (!state.initialised) {
|
|
4811
5304
|
return;
|
|
4812
5305
|
}
|