morphAssist.js 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. (function (angular){
  2. "use strict";
  3. angular.module('morph.assist', [])
  4. .factory('Assist', [function () {
  5. var defaultStyles = {
  6. wrapper: {
  7. 'position': 'fixed',
  8. 'z-index': '900',
  9. 'opacity': '0',
  10. 'margin': '0',
  11. 'pointer-events': 'none',
  12. '-webkit-transition': 'opacity 0.3s 0.5s, width 0.4s 0.1s, height 0.4s 0.1s, top 0.4s 0.1s, left 0.4s 0.1s, margin 0.4s 0.1s',
  13. 'transition': 'opacity 0.3s 0.5s, width 0.4s 0.1s, height 0.4s 0.1s, top 0.4s 0.1s, left 0.4s 0.1s, margin 0.4s 0.1s'
  14. },
  15. content: {
  16. 'transition': 'opacity 0.3s 0.3s ease',
  17. '-webkit-transition': 'opacity 0.3s 0.3s ease',
  18. 'height': '0',
  19. 'opacity': '0',
  20. },
  21. morphable: {
  22. 'z-index': '1000',
  23. 'outline': 'none',
  24. },
  25. fade: {
  26. 'display': 'none',
  27. 'opacity': '0',
  28. 'position': 'fixed',
  29. 'top': '0',
  30. 'left': '0',
  31. 'z-index': '800',
  32. 'width': '100%',
  33. 'height': '100%',
  34. 'background': 'rgba(0,0,0,0.5)',
  35. '-webkit-transition': 'opacity 0.5s',
  36. 'transition': 'opacity 0.5s'
  37. }
  38. };
  39. return {
  40. setBoundingRect: function (element, positioning, callback) {
  41. element.css({
  42. 'top': positioning.top + 'px',
  43. 'left': positioning.left + 'px',
  44. 'width': positioning.width + 'px',
  45. 'height': positioning.height + 'px'
  46. });
  47. if ( typeof callback === 'function' )
  48. callback(element);
  49. },
  50. applyDefaultStyles: function (element, elementName) {
  51. if ( defaultStyles[elementName] ) element.css(defaultStyles[elementName]);
  52. }
  53. };
  54. }]);
  55. })(angular);