|
15 | 15 |
|
16 | 16 | - **dismiss**: the element moves with the user's pointer while swiping, and then
|
17 | 17 | slides away and disappears when the swipe is complete.
|
| 18 | +- **grow**: the element grows while swiping, then returns to its original size |
| 19 | + upon swipe completion. |
18 | 20 | - **rubberband**: the element "stretches" away from center as the user's pointer
|
19 | 21 | moves, but snaps back to neutral when released.
|
20 | 22 | - **none**: the element stays put, and nothing happens.
|
|
101 | 103 | return player;
|
102 | 104 | },
|
103 | 105 | trigger: false
|
| 106 | + }, |
| 107 | + grow: { |
| 108 | + _calcScale: function(dx) { |
| 109 | + return 1.0 + (Math.log(Math.abs(dx)) / 40.0); |
| 110 | + }, |
| 111 | + update: function(el, e) { |
| 112 | + _applyTransform(el, "scale(" + _effects.grow._calcScale(e.dx) + ")"); |
| 113 | + }, |
| 114 | + finish: function(el, e) { |
| 115 | + _applyTransform(el, undefined); |
| 116 | + var player = el.animate([ |
| 117 | + {transform: 'scale(' + _effects.grow._calcScale(e.dx) + ')'}, |
| 118 | + {transform: 'scale(1.0)'} |
| 119 | + ], {duration: 200}); |
| 120 | + }, |
| 121 | + trigger: true |
104 | 122 | }
|
105 | 123 | }
|
106 | 124 |
|
|
154 | 172 | if (Math.abs(e.dx) > this.distanceThreshold) {
|
155 | 173 | var player = this._effect().finish(this, e);
|
156 | 174 | if (this._effect().trigger) {
|
157 |
| - this.fire("swipe", {effect: this[this.swipeDirection], direction: this.swipeDirection, animation: player}); |
| 175 | + var detail = {effect: this[this.swipeDirection], direction: this.swipeDirection, animation: player}; |
| 176 | + this.fire("swipe", detail); |
| 177 | + this.fire("swipe" + detail.direction, detail); |
158 | 178 | }
|
159 | 179 | } else {
|
160 | 180 | this.reset();
|
|
209 | 229 | *
|
210 | 230 | * @event swipe
|
211 | 231 | */
|
| 232 | + |
| 233 | + /** |
| 234 | + * Same as `swipe`, but only triggered on left swipe. |
| 235 | + * @event swipeleft |
| 236 | + */ |
| 237 | + |
| 238 | + /** |
| 239 | + * Same as `swipe`, but only triggered on right swipe. |
| 240 | + * @event swiperight |
| 241 | + */ |
212 | 242 | });
|
213 | 243 | })();
|
214 | 244 | </script>
|
|
0 commit comments