Changeset 506
- Timestamp:
- 01/15/06 08:02:34 (3 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mochikit/branches/scriptaculous/MochiKit/Effects.js
r505 r506 614 614 MochiKit.DOM.setStyle(this.element, 615 615 MochiKit.Base.update(this.oldStyle, { 616 backgroundColor: this.options.endColor616 backgroundColor: this.options.endColor 617 617 })); 618 618 } … … 670 670 671 671 Effect.Fade = function (element, options) { 672 /*** 673 674 Fade a given element: change its opacity and hide it in the end. 675 676 @param options: 'to' and 'from' to change opacity. 677 678 ***/ 672 679 var oldOpacity = MochiKit.DOM.getInlineOpacity(element); 673 680 options = MochiKit.Base.update({ … … 675 682 to: 0.0, 676 683 afterFinishInternal: function (effect) { 677 if ( effect.options.to != 0) {684 if (!effect.options.to) { 678 685 return; 679 686 } … … 686 693 687 694 Effect.Appear = function (element, options) { 695 /*** 696 697 Make an element appear. 698 699 @param options: 'to' and 'from' to change opacity. 700 701 ***/ 688 702 options = MochiKit.Base.update({ 689 from: (MochiKit.DOM.getStyle(element, 'display') == 'none' ? 0.0 : MochiKit.DOM.getOpacity(element) || 0.0), 703 from: (MochiKit.DOM.getStyle(element, 'display') == 'none' ? 0.0 : 704 MochiKit.DOM.getOpacity(element) || 0.0), 690 705 to: 1.0, 691 706 beforeSetup: function (effect) { … … 698 713 699 714 Effect.Puff = function (element, options) { 715 /*** 716 717 'Puff' an element: grow it to double size, fading it and make it hidden. 718 719 @param options: 'duration' in seconds for the effect, default to 1.0. 720 721 ***/ 700 722 element = MochiKit.DOM.getElement(element); 701 723 var oldStyle = { … … 706 728 duration: 1.0, 707 729 beforeSetupInternal: function (effect) { 708 MochiKit.DOM.setStyle(effect.effects[0].element, {position: 'absolute'}); 730 MochiKit.DOM.setStyle(effect.effects[0].element, 731 {position: 'absolute'}); 709 732 }, 710 733 afterFinishInternal: function (effect) { … … 714 737 }, options || {}); 715 738 return new Effect.Parallel( 716 [new Effect.Scale(element, 200,739 [new Effect.Scale(element, 200, 717 740 {sync: true, scaleFromCenter: true, 718 741 scaleContent: true, restoreAfterFinish: true}), 719 new Effect.Opacity(element, {sync: true, to: 0.0 })],720 options742 new Effect.Opacity(element, {sync: true, to: 0.0 })], 743 options 721 744 ); 722 745 }; 723 746 724 747 Effect.BlindUp = function (element, options) { 748 /*** 749 750 Blind an element up: change its vertical size to 0. 751 752 ***/ 725 753 element = MochiKit.DOM.getElement(element); 726 754 MochiKit.DOM.makeClipping(element); … … 739 767 740 768 Effect.BlindDown = function (element, options) { 769 /*** 770 771 Blind an element down: restore its vertical size. 772 773 ***/ 741 774 element = MochiKit.DOM.getElement(element); 742 775 var oldHeight = MochiKit.DOM.getStyle(element, 'height'); … … 763 796 764 797 Effect.SwitchOff = function (element) { 798 /*** 799 800 Apply a switch-off-like effect. 801 802 ***/ 765 803 element = MochiKit.DOM.getElement(element); 766 804 var oldOpacity = MochiKit.DOM.getInlineOpacity(element); … … 793 831 794 832 Effect.DropOut = function (element, options) { 833 /*** 834 835 Make an element fall and disappear. 836 837 ***/ 795 838 element = MochiKit.DOM.getElement(element); 796 839 var oldStyle = { … … 818 861 819 862 Effect.Shake = function (element) { 863 /*** 864 865 Move an element from left to right several times. 866 867 ***/ 820 868 element = MochiKit.DOM.getElement(element); 821 869 var oldStyle = { … … 823 871 left: MochiKit.DOM.getStyle(element, 'left') }; 824 872 return new Effect.Move(element, 825 {x: 20, y: 0, duration: 0.05, afterFinishInternal: function (effect) {873 {x: 20, y: 0, duration: 0.05, afterFinishInternal: function (effect) { 826 874 new Effect.Move(effect.element, 827 {x: -40, y: 0, duration: 0.1, afterFinishInternal: function (effect) {875 {x: -40, y: 0, duration: 0.1, afterFinishInternal: function (effect) { 828 876 new Effect.Move(effect.element, 829 {x: 40, y: 0, duration: 0.1, afterFinishInternal: function (effect) {877 {x: 40, y: 0, duration: 0.1, afterFinishInternal: function (effect) { 830 878 new Effect.Move(effect.element, 831 {x: -40, y: 0, duration: 0.1, afterFinishInternal: function (effect) {879 {x: -40, y: 0, duration: 0.1, afterFinishInternal: function (effect) { 832 880 new Effect.Move(effect.element, 833 {x: 40, y: 0, duration: 0.1, afterFinishInternal: function (effect) {881 {x: 40, y: 0, duration: 0.1, afterFinishInternal: function (effect) { 834 882 new Effect.Move(effect.element, 835 {x: -20, y: 0, duration: 0.05, afterFinishInternal: function (effect) {883 {x: -20, y: 0, duration: 0.05, afterFinishInternal: function (effect) { 836 884 MochiKit.DOM.undoPositioned(effect.element); 837 885 MochiKit.DOM.setStyle(effect.element, oldStyle); … … 840 888 841 889 Effect.SlideDown = function (element, options) { 890 /*** 891 892 Slide an element down. 893 It needs to have the content of the element wrapped in a container 894 element with fixed height. 895 896 ***/ 842 897 element = MochiKit.DOM.getElement(element); 843 898 MochiKit.DOM.cleanWhitespace(element); 844 // SlideDown need to have the content of the element wrapped in845 // a container element with fixed height!846 899 var oldInnerBottom = MochiKit.DOM.getStyle(element.firstChild, 'bottom'); 847 900 var elementDimensions = MochiKit.DOM.elementDimensions(element); … … 871 924 MochiKit.DOM.undoPositioned(effect.element.firstChild); 872 925 MochiKit.DOM.undoPositioned(effect.element); 873 MochiKit.DOM.setStyle(effect.element.firstChild, {bottom: oldInnerBottom}); 926 MochiKit.DOM.setStyle(effect.element.firstChild, 927 {bottom: oldInnerBottom}); 874 928 } 875 929 }, options || {}); … … 879 933 880 934 Effect.SlideUp = function (element, options) { 935 /*** 936 937 Slide an element up. 938 It needs to have the content of the element wrapped in a container 939 element with fixed height. 940 941 ***/ 881 942 element = MochiKit.DOM.getElement(element); 882 943 MochiKit.DOM.cleanWhitespace(element); … … 912 973 }; 913 974 914 // Bug in opera makes the TD containing this element expand for a instance after finish 915 Effect.Squish = function (element) { 916 return new Effect.Scale(element, MochiKit.Base.isOpera() ? 1 : 0, 917 {restoreAfterFinish: true, 918 beforeSetup: function (effect) { 975 // Bug in opera makes the TD containing this element expand for a instance 976 // after finish 977 Effect.Squish = function (element, options) { 978 /*** 979 980 Reduce an element and make it disappear. 981 982 ***/ 983 options = MochiKit.Base.update({ 984 restoreAfterFinish: true, 985 beforeSetup: function (effect) { 919 986 MochiKit.DOM.makeClipping(effect.element); 920 },921 afterFinishInternal: function (effect) {987 }, 988 afterFinishInternal: function (effect) { 922 989 MochiKit.DOM.hideElement(effect.element); 923 990 MochiKit.DOM.undoClipping(effect.element); 924 } 925 }); 991 } 992 }, options || {}); 993 994 return new Effect.Scale(element, MochiKit.Base.isOpera() ? 1 : 0, options); 926 995 }; 927 996 928 997 Effect.Grow = function (element, options) { 998 /*** 999 1000 Grow an element to its original size. Make it zero-sized before 1001 if necessary. 1002 1003 ***/ 929 1004 element = MochiKit.DOM.getElement(element); 930 1005 options = MochiKit.Base.update({ … … 997 1072 new Effect.Parallel( 998 1073 [new Effect.Opacity(effect.element, { 999 sync: true, to: 1.0, from: 0.0, transition: options.opacityTransition 1074 sync: true, to: 1.0, from: 0.0, 1075 transition: options.opacityTransition 1000 1076 }), 1001 1077 new Effect.Move(effect.element, { 1002 x: moveX, y: moveY, sync: true, transition: options.moveTransition 1078 x: moveX, y: moveY, sync: true, 1079 transition: options.moveTransition 1003 1080 }), 1004 1081 new Effect.Scale(effect.element, 100, { … … 1017 1094 1018 1095 Effect.Shrink = function (element, options) { 1096 /*** 1097 1098 Shrink an element and make it disappear. 1099 1100 ***/ 1019 1101 element = MochiKit.DOM.getElement(element); 1020 1102 options = MochiKit.Base.update({ … … 1056 1138 } 1057 1139 1058 var optionsParallel = MochiKit.Base.update( 1059 { 1140 var optionsParallel = MochiKit.Base.update({ 1060 1141 beforeStartInternal: function (effect) { 1061 1142 MochiKit.DOM.makePositioned(effect.effects[0].element); … … 1087 1168 1088 1169 Effect.Pulsate = function (element, options) { 1170 /*** 1171 1172 Pulse an element between appear/fade. 1173 1174 ***/ 1089 1175 element = MochiKit.DOM.getElement(element); 1090 1176 options = MochiKit.Base.update({ … … 1093 1179 afterFinishInternal: function (effect) { 1094 1180 MochiKit.DOM.setStyle(effect.element, {opacity: oldOpacity}); 1095 }, 1096 transition: reverser 1181 } 1097 1182 }, options || {}); 1098 1183 var oldOpacity = MochiKit.DOM.getInlineOpacity(element); 1099 1184 var transition = options.transition || Effect.Transitions.sinoidal; 1100 var reverser = function (pos) {1185 var reverser = MochiKit.Base.bind(function (pos) { 1101 1186 return transition(1 - Effect.Transitions.pulse(pos)); 1102 } ;1187 }, transition); 1103 1188 MochiKit.Base.bind(reverser, transition); 1104 return new Effect.Opacity(element, options); 1189 return new Effect.Opacity(element, MochiKit.Base.update({ 1190 transition: reverser}, options)); 1105 1191 }; 1106 1192 1107 1193 Effect.Fold = function (element, options) { 1194 /*** 1195 1196 Fold an element, first vertically, then horizontally. 1197 1198 ***/ 1108 1199 element = MochiKit.DOM.getElement(element); 1109 1200 var oldStyle = {
