EffectManager.js 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. /**
  2. * Created by admin on 2018-06-14.
  3. */
  4. import { TimelineLite, Sine, TweenMax,Power0 } from './TweenMax.min'
  5. var em = {};
  6. em.bumpToY = function (obj, time, addScale, returnFunc) {
  7. var originScale = obj.scale.y;
  8. TweenMax.to(obj.scale, time, {ease:Power0.easeNone, y:originScale + addScale, onComplete:(function () {
  9. TweenMax.to(obj.scale, time, {ease:Power0.easeNone, y:originScale, onComplete:(function () {
  10. if(returnFunc) returnFunc();
  11. }).bind(this)});
  12. }).bind(this)});
  13. };
  14. em.bumpFromToX = function (obj, time, minScale, maxScale, endScale, returnFunc) {
  15. TweenMax.fromTo(obj.scale, time, {x:minScale}, {x:maxScale, onComplete:(function () {
  16. TweenMax.to(obj.scale, time/2, {x:endScale, onComplete:(function () {
  17. if(returnFunc) returnFunc();
  18. }).bind(this)});
  19. }).bind(this)});
  20. }
  21. em.floatByY = function (obj, time, dist, repeatTime, returnFunc) {
  22. var originY = obj.y;
  23. (function upTween() {
  24. TweenMax.to(obj, time*0.25, {ease:Power0.easeNone, y:originY - dist, onComplete:downTween.bind(this)});
  25. })();
  26. function downTween() {
  27. TweenMax.to(obj, time*0.5, {ease:Power0.easeNone, y:originY + dist, onComplete:originTween.bind(this)});
  28. }
  29. function originTween() {
  30. TweenMax.to(obj, time*0.25, {ease:Power0.easeNone, y:originY, onComplete:(function () {
  31. if(repeatTime >= 1) {
  32. repeatTime--;
  33. em.floatByY(obj, time, dist, repeatTime, returnFunc);
  34. }
  35. else if(returnFunc) returnFunc();
  36. }).bind(this)});
  37. }
  38. }
  39. export default em;