@cheprasov/web-animation
Advanced tools
Comparing version 0.1.5 to 0.1.6
{ | ||
"name": "@cheprasov/web-animation", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"author": "Alexander Cheprasov", | ||
@@ -5,0 +5,0 @@ "description": "A Class for driving animated content on the web is based on requestAnimationFrame for performance.", |
@@ -40,2 +40,4 @@ //@flow | ||
_isInLoop: boolean = false; | ||
constructor(options: OptionsType = {}) { | ||
@@ -81,3 +83,6 @@ const opts = { ...defaultOptions, ...options }; | ||
this._rAF(this._onTick); | ||
if (!this._isInLoop) { | ||
this._rAF(this._onTick); | ||
this._isInLoop = true; | ||
} | ||
} | ||
@@ -101,2 +106,3 @@ | ||
if (this._isStopped) { | ||
this._isInLoop = false; | ||
return; | ||
@@ -115,2 +121,3 @@ } | ||
} | ||
this._isInLoop = false; | ||
return; | ||
@@ -117,0 +124,0 @@ } |
@@ -191,5 +191,14 @@ // @flow | ||
it('should call tick function for animation', () => { | ||
it('should call tick function for animation and mark as in loop', () => { | ||
expect(animation._rAF).toHaveBeenCalledWith(animation._onTick); | ||
expect(animation._isInLoop).toBeTruthy(); | ||
}); | ||
it('should not call tick animation if it is in loop', () => { | ||
animation = new WebAnimation(); | ||
animation._rAF = jest.fn(); | ||
animation._isInLoop = true; | ||
animation.run(); | ||
expect(animation._rAF).not.toHaveBeenCalled(); | ||
}); | ||
}); | ||
@@ -277,2 +286,3 @@ | ||
animation._isStopped = false; | ||
animation._isInLoop = true; | ||
progress = { | ||
@@ -295,2 +305,3 @@ elapsedTime: 42, | ||
expect(animation._rAF).not.toHaveBeenCalled(); | ||
expect(animation._isInLoop).toBeFalsy(); | ||
}); | ||
@@ -312,2 +323,3 @@ | ||
expect(animation._isStopped).toBeTruthy(); | ||
expect(animation._isInLoop).toBeFalsy(); | ||
}); | ||
@@ -318,2 +330,3 @@ | ||
expect(animation._rAF).not.toHaveBeenCalled(); | ||
expect(animation._isInLoop).toBeFalsy(); | ||
}); | ||
@@ -326,2 +339,3 @@ | ||
expect(animation._isStopped).toBeFalsy(); | ||
expect(animation._isInLoop).toBeTruthy(); | ||
}); | ||
@@ -333,2 +347,3 @@ | ||
expect(animation._rAF).toHaveBeenCalled(); | ||
expect(animation._isInLoop).toBeTruthy(); | ||
}); | ||
@@ -335,0 +350,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27883
465