GitLab repository storage has been migrated to hashed layout. Please contact Infrastructure team if you notice any issues with repositories or hooks.

Commit 4a28c6b2 authored by Philip Chimento's avatar Philip Chimento 🚮

Merge branch 'jaszhix/gjs-tweener-fix'

See !67
parents a0247133 da0a0f7a
Pipeline #8553 passed with stages
in 31 minutes and 52 seconds
......@@ -406,4 +406,26 @@ describe('Tweener', function () {
expect(overwrite).toHaveBeenCalledTimes(1);
expect(complete).toHaveBeenCalledTimes(1);
});
it('stays within min and max values', function () {
var objectA = {
x: 0,
y: 0
};
var objectB = {
x: 0,
y: 0
};
Tweener.addTween(objectA, { x: 300, y: 300, time: 1, max: 255, transition: "linear" });
Tweener.addTween(objectB, { x: -200, y: -200, time: 1, delay: 0.5, min: 0, transition: "linear" });
jasmine.clock().tick(1001);
expect(objectA.x).toEqual(255);
expect(objectA.y).toEqual(255);
expect(objectB.x).toEqual(0);
expect(objectB.y).toEqual(0);
});
});
......@@ -88,6 +88,8 @@ TweenList.prototype = {
tween.onErrorScope = this.onErrorScope;
}
tween.rounded = this.rounded;
tween.min = this.min;
tween.max = this.max;
tween.isPaused = this.isPaused;
tween.timePaused = this.timePaused;
tween.isCaller = this.isCaller;
......
......@@ -314,6 +314,11 @@ function _updateTweenByIndex(i) {
if (tweening.rounded)
nv = Math.round(nv);
if (tweening.min !== undefined && nv < tweening.min)
nv = tweening.min;
if (tweening.max !== undefined && nv > tweening.max)
nv = tweening.max;
if (property.isSpecialProperty) {
// It's a special property, tunnel via the special property method
_specialPropertyList[name].setValue(scope, nv, _specialPropertyList[name].parameters, tweening.properties[name].extra);
......@@ -368,7 +373,7 @@ function _onEnterFrame() {
return true;
}
const restrictedWords = {
var restrictedWords = {
time: true,
delay: true,
userFrames: true,
......@@ -381,6 +386,8 @@ const restrictedWords = {
onOverwrite: true,
onError: true,
rounded: true,
min: true,
max: true,
onStartParams: true,
onUpdateParams: true,
onCompleteParams: true,
......@@ -571,6 +578,8 @@ function _addTweenOrCaller(target, tweeningParameters, isCaller) {
tween.onOverwriteScope = obj.onOverwriteScope;
tween.onErrorScope = obj.onErrorScope;
tween.rounded = obj.rounded;
tween.min = obj.min;
tween.max = obj.max;
tween.skipUpdates = obj.skipUpdates;
tween.isCaller = isCaller;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment