unpoly-rails 0.57.0 → 0.60.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of unpoly-rails might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +393 -1
- data/Gemfile.lock +5 -2
- data/README.md +1 -1
- data/README_RAILS.md +1 -1
- data/Rakefile +10 -1
- data/design/es6.js +32 -0
- data/design/ie11.txt +9 -0
- data/design/measure_jquery/element_list.js +41 -0
- data/design/measure_jquery/up.on_vs_addEventListener.js +56 -0
- data/design/todo_jquery.txt +13 -0
- data/dist/unpoly-bootstrap3.js +8 -8
- data/dist/unpoly-bootstrap3.min.js +1 -1
- data/dist/unpoly.css +22 -20
- data/dist/unpoly.js +6990 -5336
- data/dist/unpoly.min.css +1 -1
- data/dist/unpoly.min.js +4 -4
- data/lib/assets/javascripts/unpoly-bootstrap3/viewport-ext.coffee +5 -0
- data/lib/assets/javascripts/unpoly.coffee +8 -6
- data/lib/assets/javascripts/unpoly/browser.coffee.erb +23 -118
- data/lib/assets/javascripts/unpoly/classes/body_shifter.coffee +36 -0
- data/lib/assets/javascripts/unpoly/classes/cache.coffee +4 -4
- data/lib/assets/javascripts/unpoly/classes/compile_pass.coffee +45 -39
- data/lib/assets/javascripts/unpoly/classes/config.coffee +9 -0
- data/lib/assets/javascripts/unpoly/classes/css_transition.coffee +18 -27
- data/lib/assets/javascripts/unpoly/classes/divertible_chain.coffee +39 -0
- data/lib/assets/javascripts/unpoly/classes/event_listener.coffee +116 -0
- data/lib/assets/javascripts/unpoly/classes/extract_cascade.coffee +8 -8
- data/lib/assets/javascripts/unpoly/classes/extract_plan.coffee +19 -19
- data/lib/assets/javascripts/unpoly/classes/field_observer.coffee +54 -31
- data/lib/assets/javascripts/unpoly/classes/{focus_tracker.coffee → focus_follower.coffee} +2 -2
- data/lib/assets/javascripts/unpoly/classes/follow_variant.coffee +25 -25
- data/lib/assets/javascripts/unpoly/classes/html_parser.coffee +4 -11
- data/lib/assets/javascripts/unpoly/classes/motion_controller.coffee +157 -0
- data/lib/assets/javascripts/unpoly/classes/params.coffee.erb +525 -0
- data/lib/assets/javascripts/unpoly/classes/record.coffee +8 -2
- data/lib/assets/javascripts/unpoly/classes/rect.js +21 -0
- data/lib/assets/javascripts/unpoly/classes/request.coffee +41 -35
- data/lib/assets/javascripts/unpoly/classes/response.coffee +7 -3
- data/lib/assets/javascripts/unpoly/classes/reveal_motion.coffee +102 -0
- data/lib/assets/javascripts/unpoly/classes/scroll_motion.coffee +67 -0
- data/lib/assets/javascripts/unpoly/classes/selector.coffee +60 -0
- data/lib/assets/javascripts/unpoly/classes/tether.coffee +105 -0
- data/lib/assets/javascripts/unpoly/classes/url_set.coffee +12 -7
- data/lib/assets/javascripts/unpoly/element.coffee.erb +1126 -0
- data/lib/assets/javascripts/unpoly/event.coffee.erb +437 -0
- data/lib/assets/javascripts/unpoly/feedback.coffee +73 -94
- data/lib/assets/javascripts/unpoly/form.coffee.erb +188 -181
- data/lib/assets/javascripts/unpoly/{dom.coffee.erb → fragment.coffee.erb} +250 -283
- data/lib/assets/javascripts/unpoly/framework.coffee +67 -0
- data/lib/assets/javascripts/unpoly/history.coffee +29 -28
- data/lib/assets/javascripts/unpoly/legacy.coffee +60 -0
- data/lib/assets/javascripts/unpoly/link.coffee.erb +127 -119
- data/lib/assets/javascripts/unpoly/log.coffee +99 -19
- data/lib/assets/javascripts/unpoly/modal.coffee.erb +95 -118
- data/lib/assets/javascripts/unpoly/motion.coffee.erb +158 -138
- data/lib/assets/javascripts/unpoly/namespace.coffee.erb +0 -5
- data/lib/assets/javascripts/unpoly/popup.coffee.erb +119 -102
- data/lib/assets/javascripts/unpoly/protocol.coffee +11 -15
- data/lib/assets/javascripts/unpoly/proxy.coffee +62 -65
- data/lib/assets/javascripts/unpoly/radio.coffee +3 -5
- data/lib/assets/javascripts/unpoly/rails.coffee +8 -9
- data/lib/assets/javascripts/unpoly/syntax.coffee.erb +173 -125
- data/lib/assets/javascripts/unpoly/toast.coffee +25 -24
- data/lib/assets/javascripts/unpoly/tooltip.coffee +89 -79
- data/lib/assets/javascripts/unpoly/util.coffee.erb +579 -1074
- data/lib/assets/javascripts/unpoly/{layout.coffee.erb → viewport.coffee.erb} +334 -264
- data/lib/assets/stylesheets/unpoly/dom.sass +1 -1
- data/lib/assets/stylesheets/unpoly/layout.sass +2 -0
- data/lib/assets/stylesheets/unpoly/popup.sass +0 -1
- data/lib/assets/stylesheets/unpoly/tooltip.sass +17 -12
- data/lib/unpoly/rails/version.rb +1 -1
- data/package.json +1 -2
- data/spec_app/Gemfile +2 -1
- data/spec_app/Gemfile.lock +38 -27
- data/spec_app/app/assets/javascripts/integration_test.coffee +1 -0
- data/spec_app/app/assets/javascripts/jasmine_specs.coffee +1 -2
- data/spec_app/app/assets/stylesheets/integration_test.sass +14 -1
- data/spec_app/app/controllers/scroll_test_controller.rb +5 -0
- data/spec_app/app/views/css_test/modal.erb +6 -6
- data/spec_app/app/views/css_test/popup.erb +44 -18
- data/spec_app/app/views/css_test/tooltip.erb +23 -4
- data/spec_app/app/views/error_test/trigger.erb +1 -1
- data/spec_app/app/views/form_test/basics/new.erb +1 -3
- data/spec_app/app/views/pages/start.erb +9 -2
- data/spec_app/app/views/reveal_test/long1.erb +1 -1
- data/spec_app/app/views/reveal_test/long2.erb +1 -1
- data/spec_app/app/views/reveal_test/within_document_viewport.erb +24 -0
- data/spec_app/app/views/reveal_test/within_overflowing_div_viewport.erb +28 -0
- data/spec_app/app/views/scroll_test/long1.erb +30 -0
- data/spec_app/config/routes.rb +1 -0
- data/spec_app/spec/javascripts/helpers/agent_detector.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/async_sequence.js.coffee +1 -0
- data/spec_app/spec/javascripts/helpers/browser_switches.js.coffee +17 -5
- data/spec_app/spec/javascripts/helpers/enable_logging.js.coffee +1 -1
- data/spec_app/spec/javascripts/helpers/fixture.js.coffee +25 -0
- data/spec_app/spec/javascripts/helpers/jquery_no_conflict.js +1 -0
- data/spec_app/spec/javascripts/helpers/last_request.js.coffee +1 -0
- data/spec_app/spec/javascripts/helpers/mock_ajax.js.coffee +1 -1
- data/spec_app/spec/javascripts/helpers/parse_form_data.js.coffee +2 -2
- data/spec_app/spec/javascripts/helpers/protect_jasmine_runner.coffee +4 -1
- data/spec_app/spec/javascripts/helpers/remove_body_margin.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/reset_history.js.coffee +2 -1
- data/spec_app/spec/javascripts/helpers/reset_knife.js.coffee +2 -2
- data/spec_app/spec/javascripts/helpers/reset_up.js.coffee +18 -11
- data/spec_app/spec/javascripts/helpers/restore_body_scroll.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/show_lib_versions.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/spec_util.coffee +47 -0
- data/spec_app/spec/javascripts/helpers/to_be_around.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_array.coffee +5 -0
- data/spec_app/spec/javascripts/helpers/to_be_attached.coffee +6 -2
- data/spec_app/spec/javascripts/helpers/to_be_blank.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_detached.coffee +6 -2
- data/spec_app/spec/javascripts/helpers/to_be_element.js.coffee +8 -0
- data/spec_app/spec/javascripts/helpers/to_be_error.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_given.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_hidden.js.coffee +8 -0
- data/spec_app/spec/javascripts/helpers/to_be_missing.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_present.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_scrolled_to.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_be_visible.js.coffee +9 -0
- data/spec_app/spec/javascripts/helpers/to_contain.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_end_with.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_equal_jquery.js.coffee +1 -2
- data/spec_app/spec/javascripts/helpers/to_equal_node_list.coffee +7 -0
- data/spec_app/spec/javascripts/helpers/to_equal_via_is_equal.js.coffee +7 -0
- data/spec_app/spec/javascripts/helpers/to_have_class.js.coffee +10 -0
- data/spec_app/spec/javascripts/helpers/to_have_descendant.js.coffee +10 -0
- data/spec_app/spec/javascripts/helpers/to_have_length.js.coffee +8 -0
- data/spec_app/spec/javascripts/helpers/to_have_opacity.coffee +7 -3
- data/spec_app/spec/javascripts/helpers/to_have_own_property.js.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_have_request_method.js.coffee +1 -0
- data/spec_app/spec/javascripts/helpers/to_have_text.js.coffee +9 -0
- data/spec_app/spec/javascripts/helpers/to_have_unhandled_rejections.coffee +0 -21
- data/spec_app/spec/javascripts/helpers/to_match_list.coffee +14 -0
- data/spec_app/spec/javascripts/helpers/to_match_selector.coffee +3 -0
- data/spec_app/spec/javascripts/helpers/to_match_text.js.coffee +4 -1
- data/spec_app/spec/javascripts/helpers/to_match_url.coffee +1 -0
- data/spec_app/spec/javascripts/helpers/trigger.js.coffee +91 -7
- data/spec_app/spec/javascripts/helpers/wait_until_dom_ready.js.coffee +3 -0
- data/spec_app/spec/javascripts/up/browser_spec.js.coffee +23 -90
- data/spec_app/spec/javascripts/up/classes/cache_spec.js.coffee +3 -0
- data/spec_app/spec/javascripts/up/classes/config_spec.coffee +24 -0
- data/spec_app/spec/javascripts/up/classes/divertible_chain_spec.coffee +45 -0
- data/spec_app/spec/javascripts/up/classes/focus_tracker_spec.coffee +5 -2
- data/spec_app/spec/javascripts/up/classes/params_spec.coffee +557 -0
- data/spec_app/spec/javascripts/up/classes/request_spec.coffee +7 -4
- data/spec_app/spec/javascripts/up/classes/scroll_motion_spec.js.coffee +51 -0
- data/spec_app/spec/javascripts/up/classes/store/memory_spec.js.coffee +3 -0
- data/spec_app/spec/javascripts/up/classes/store/session_spec.js.coffee +3 -2
- data/spec_app/spec/javascripts/up/element_spec.coffee +897 -0
- data/spec_app/spec/javascripts/up/event_spec.js.coffee +496 -0
- data/spec_app/spec/javascripts/up/feedback_spec.js.coffee +69 -48
- data/spec_app/spec/javascripts/up/form_spec.js.coffee +252 -194
- data/spec_app/spec/javascripts/up/{dom_spec.js.coffee → fragment_spec.js.coffee} +381 -388
- data/spec_app/spec/javascripts/up/history_spec.js.coffee +21 -19
- data/spec_app/spec/javascripts/up/jquery_spec.js.coffee +4 -0
- data/spec_app/spec/javascripts/up/legacy_spec.js.coffee +27 -0
- data/spec_app/spec/javascripts/up/link_spec.js.coffee +163 -160
- data/spec_app/spec/javascripts/up/log_spec.js.coffee +85 -12
- data/spec_app/spec/javascripts/up/modal_spec.js.coffee +141 -123
- data/spec_app/spec/javascripts/up/motion_spec.js.coffee +117 -113
- data/spec_app/spec/javascripts/up/popup_spec.js.coffee +60 -77
- data/spec_app/spec/javascripts/up/protocol_spec.js.coffee +1 -0
- data/spec_app/spec/javascripts/up/proxy_spec.js.coffee +85 -78
- data/spec_app/spec/javascripts/up/radio_spec.js.coffee +29 -22
- data/spec_app/spec/javascripts/up/rails_spec.js.coffee +14 -13
- data/spec_app/spec/javascripts/up/spec_spec.js.coffee +9 -0
- data/spec_app/spec/javascripts/up/syntax_spec.js.coffee +96 -66
- data/spec_app/spec/javascripts/up/toast_spec.js.coffee +37 -0
- data/spec_app/spec/javascripts/up/tooltip_spec.js.coffee +31 -47
- data/spec_app/spec/javascripts/up/util_spec.js.coffee +725 -562
- data/spec_app/spec/javascripts/up/{layout_spec.js.coffee → viewport_spec.js.coffee} +175 -149
- metadata +57 -19
- data/lib/assets/javascripts/unpoly-bootstrap3/layout-ext.coffee +0 -5
- data/lib/assets/javascripts/unpoly/bus.coffee.erb +0 -518
- data/lib/assets/javascripts/unpoly/classes/extract_step.coffee +0 -4
- data/lib/assets/javascripts/unpoly/classes/motion_tracker.coffee +0 -125
- data/lib/assets/javascripts/unpoly/params.coffee.erb +0 -522
- data/spec_app/spec/javascripts/helpers/append_fixture.js.coffee +0 -8
- data/spec_app/spec/javascripts/up/bus_spec.js.coffee +0 -210
- data/spec_app/spec/javascripts/up/namespace_spec.js.coffee +0 -9
- data/spec_app/spec/javascripts/up/params_spec.coffee +0 -768
- data/spec_app/vendor/asset-libs/jasmine-fixture-1.3.4/jasmine-fixture.js +0 -433
- data/spec_app/vendor/asset-libs/jasmine-jquery-2.1.1/.bower.json +0 -26
- data/spec_app/vendor/asset-libs/jasmine-jquery-2.1.1/jasmine-jquery.js +0 -838
@@ -1,3 +1,7 @@
|
|
1
|
+
u = up.util
|
2
|
+
e = up.element
|
3
|
+
$ = jQuery
|
4
|
+
|
1
5
|
describe 'up.motion', ->
|
2
6
|
|
3
7
|
u = up.util
|
@@ -7,32 +11,32 @@ describe 'up.motion', ->
|
|
7
11
|
describe 'up.animate', ->
|
8
12
|
|
9
13
|
it 'animates the given element', (done) ->
|
10
|
-
$element =
|
14
|
+
$element = $fixture('.element').text('content')
|
11
15
|
up.animate($element, 'fade-in', duration: 200, easing: 'linear')
|
12
16
|
|
13
|
-
u.
|
17
|
+
u.timer 1, ->
|
14
18
|
expect($element).toHaveOpacity(0.0, 0.15)
|
15
|
-
u.
|
19
|
+
u.timer 100, ->
|
16
20
|
expect($element).toHaveOpacity(0.5, 0.3)
|
17
|
-
u.
|
21
|
+
u.timer 260, ->
|
18
22
|
expect($element).toHaveOpacity(1.0, 0.15)
|
19
23
|
done()
|
20
24
|
|
21
25
|
it 'returns a promise that is fulfilled when the animation has completed', (done) ->
|
22
|
-
$element =
|
26
|
+
$element = $fixture('.element').text('content')
|
23
27
|
resolveSpy = jasmine.createSpy('resolve')
|
24
28
|
|
25
29
|
promise = up.animate($element, 'fade-in', duration: 100, easing: 'linear')
|
26
30
|
promise.then(resolveSpy)
|
27
31
|
|
28
|
-
u.
|
32
|
+
u.timer 50, ->
|
29
33
|
expect(resolveSpy).not.toHaveBeenCalled()
|
30
|
-
u.
|
34
|
+
u.timer 50 + (timingTolerance = 120), ->
|
31
35
|
expect(resolveSpy).toHaveBeenCalled()
|
32
36
|
done()
|
33
37
|
|
34
38
|
it 'cancels an existing animation on the element by instantly jumping to the last frame', asyncSpec (next) ->
|
35
|
-
$element =
|
39
|
+
$element = $fixture('.element').text('content')
|
36
40
|
up.animate($element, { 'font-size': '40px' }, duration: 10000, easing: 'linear')
|
37
41
|
|
38
42
|
next =>
|
@@ -42,7 +46,7 @@ describe 'up.motion', ->
|
|
42
46
|
expect($element.css('font-size')).toEqual('40px')
|
43
47
|
|
44
48
|
it 'pauses an existing CSS transitions and restores it once the Unpoly animation is done', asyncSpec (next) ->
|
45
|
-
$element =
|
49
|
+
$element = $fixture('.element').text('content').css
|
46
50
|
backgroundColor: 'yellow'
|
47
51
|
fontSize: '10px'
|
48
52
|
height: '20px'
|
@@ -87,32 +91,32 @@ describe 'up.motion', ->
|
|
87
91
|
describe 'when up.animate() is called from inside an animation function', ->
|
88
92
|
|
89
93
|
it 'animates', (done) ->
|
90
|
-
$element =
|
94
|
+
$element = $fixture('.element').text('content')
|
91
95
|
|
92
96
|
animation = ($element, options) ->
|
93
|
-
|
97
|
+
e.setStyle($element, opacity: 0)
|
94
98
|
up.animate($element, { opacity: 1 }, options)
|
95
99
|
|
96
100
|
up.animate($element, animation, duration: 300, easing: 'linear')
|
97
101
|
|
98
|
-
u.
|
102
|
+
u.timer 5, ->
|
99
103
|
expect($element).toHaveOpacity(0.0, 0.25)
|
100
|
-
u.
|
104
|
+
u.timer 150, ->
|
101
105
|
expect($element).toHaveOpacity(0.5, 0.25)
|
102
|
-
u.
|
106
|
+
u.timer 300, ->
|
103
107
|
expect($element).toHaveOpacity(1.0, 0.25)
|
104
108
|
done()
|
105
109
|
|
106
110
|
it "finishes animations only once", (done) ->
|
107
|
-
$element =
|
111
|
+
$element = $fixture('.element').text('content')
|
108
112
|
|
109
113
|
animation = ($element, options) ->
|
110
|
-
|
114
|
+
e.setStyle($element, opacity: 0)
|
111
115
|
up.animate($element, { opacity: 1 }, options)
|
112
116
|
|
113
117
|
up.animate($element, animation, duration: 200, easing: 'linear')
|
114
118
|
|
115
|
-
u.
|
119
|
+
u.task =>
|
116
120
|
expect(up.motion.finishCount()).toEqual(1)
|
117
121
|
done()
|
118
122
|
|
@@ -123,12 +127,12 @@ describe 'up.motion', ->
|
|
123
127
|
up.motion.config.enabled = false
|
124
128
|
|
125
129
|
it "doesn't animate and directly sets the last frame instead", (done) ->
|
126
|
-
$element =
|
130
|
+
$element = $fixture('.element').text('content')
|
127
131
|
callback = jasmine.createSpy('animation done callback')
|
128
132
|
animateDone = up.animate($element, { 'font-size': '40px' }, duration: 10000, easing: 'linear')
|
129
133
|
animateDone.then(callback)
|
130
134
|
|
131
|
-
u.
|
135
|
+
u.timer 5, =>
|
132
136
|
expect($element.css('font-size')).toEqual('40px')
|
133
137
|
expect(callback).toHaveBeenCalled()
|
134
138
|
done()
|
@@ -138,7 +142,7 @@ describe 'up.motion', ->
|
|
138
142
|
describe "when called with a `#{noneAnimation}` animation", ->
|
139
143
|
|
140
144
|
it "doesn't animate and resolves instantly", asyncSpec (next) ->
|
141
|
-
$element =
|
145
|
+
$element = $fixture('.element').text('content')
|
142
146
|
callback = jasmine.createSpy('animation done callback')
|
143
147
|
animateDone = up.animate($element, noneAnimation, duration: 10000, easing: 'linear')
|
144
148
|
animateDone.then(callback)
|
@@ -150,7 +154,7 @@ describe 'up.motion', ->
|
|
150
154
|
describe 'when called with an element or selector', ->
|
151
155
|
|
152
156
|
it 'cancels an existing animation on the given element by instantly jumping to the last frame', asyncSpec (next) ->
|
153
|
-
$element =
|
157
|
+
$element = $fixture('.element').text('content')
|
154
158
|
up.animate($element, { 'font-size': '40px', 'opacity': '0.5' }, duration: 30000)
|
155
159
|
|
156
160
|
next =>
|
@@ -158,10 +162,10 @@ describe 'up.motion', ->
|
|
158
162
|
|
159
163
|
next =>
|
160
164
|
expect($element.css('font-size')).toEqual('40px')
|
161
|
-
expect(
|
165
|
+
expect($element).toHaveOpacity(0.5, 0.01) # Safari sometimes has rounding errors
|
162
166
|
|
163
167
|
it 'cancels animations on children of the given element', asyncSpec (next) ->
|
164
|
-
$parent =
|
168
|
+
$parent = $fixture('.element')
|
165
169
|
$child = $parent.affix('.child')
|
166
170
|
up.animate($child, { 'font-size': '40px' }, duration: 10000)
|
167
171
|
|
@@ -172,8 +176,8 @@ describe 'up.motion', ->
|
|
172
176
|
expect($child.css('font-size')).toEqual('40px')
|
173
177
|
|
174
178
|
it 'does not cancel animations on other elements', asyncSpec (next) ->
|
175
|
-
$element1 =
|
176
|
-
$element2 =
|
179
|
+
$element1 = $fixture('.element1').text('content1')
|
180
|
+
$element2 = $fixture('.element2').text('content2')
|
177
181
|
up.animate($element1, 'fade-in', duration: 10000)
|
178
182
|
up.animate($element2, 'fade-in', duration: 10000)
|
179
183
|
|
@@ -185,7 +189,7 @@ describe 'up.motion', ->
|
|
185
189
|
expect(Number($element2.css('opacity'))).toBeAround(0, 0.1)
|
186
190
|
|
187
191
|
it 'restores CSS transitions from before the Unpoly animation', asyncSpec (next) ->
|
188
|
-
$element =
|
192
|
+
$element = $fixture('.element').text('content')
|
189
193
|
$element.css('transition': 'font-size 3s ease')
|
190
194
|
oldTransitionProperty = $element.css('transition-property')
|
191
195
|
expect(oldTransitionProperty).toBeDefined()
|
@@ -196,15 +200,15 @@ describe 'up.motion', ->
|
|
196
200
|
up.motion.finish($element)
|
197
201
|
|
198
202
|
next =>
|
199
|
-
expect(
|
203
|
+
expect($element).toHaveOpacity(1)
|
200
204
|
currentTransitionProperty = $element.css('transition-property')
|
201
205
|
expect(currentTransitionProperty).toEqual(oldTransitionProperty)
|
202
206
|
expect(currentTransitionProperty).toContain('font-size')
|
203
207
|
expect(currentTransitionProperty).not.toContain('opacity')
|
204
208
|
|
205
209
|
it 'cancels an existing transition on the old element by instantly jumping to the last frame', asyncSpec (next) ->
|
206
|
-
$v1 =
|
207
|
-
$v2 =
|
210
|
+
$v1 = $fixture('.element').text('v1')
|
211
|
+
$v2 = $fixture('.element').text('v2')
|
208
212
|
|
209
213
|
up.morph($v1, $v2, 'cross-fade', duration: 200)
|
210
214
|
|
@@ -219,8 +223,8 @@ describe 'up.motion', ->
|
|
219
223
|
expect($v2).toHaveOpacity(1.0, 0.2)
|
220
224
|
|
221
225
|
it 'cancels an existing transition on the new element by instantly jumping to the last frame', asyncSpec (next) ->
|
222
|
-
$v1 =
|
223
|
-
$v2 =
|
226
|
+
$v1 = $fixture('.element').text('v1')
|
227
|
+
$v2 = $fixture('.element').text('v2')
|
224
228
|
|
225
229
|
up.morph($v1, $v2, 'cross-fade', duration: 200)
|
226
230
|
|
@@ -236,7 +240,7 @@ describe 'up.motion', ->
|
|
236
240
|
|
237
241
|
|
238
242
|
it 'cancels transitions on children of the given element', asyncSpec (next) ->
|
239
|
-
$parent =
|
243
|
+
$parent = $fixture('.parent')
|
240
244
|
$old = $parent.affix('.old').text('old content')
|
241
245
|
$new = $parent.affix('.new').text('new content')
|
242
246
|
|
@@ -254,8 +258,8 @@ describe 'up.motion', ->
|
|
254
258
|
|
255
259
|
|
256
260
|
it 'does not leave .up-bounds elements in the DOM', asyncSpec (next) ->
|
257
|
-
$old =
|
258
|
-
$new =
|
261
|
+
$old = $fixture('.old').text('old content')
|
262
|
+
$new = $fixture('.new').text('new content')
|
259
263
|
|
260
264
|
up.morph($old, $new, 'cross-fade', duration: 2000)
|
261
265
|
|
@@ -268,7 +272,7 @@ describe 'up.motion', ->
|
|
268
272
|
|
269
273
|
|
270
274
|
it 'emits an up:motion:finish event on the given animating element, so custom animation functions can react to the finish request', asyncSpec (next) ->
|
271
|
-
$element =
|
275
|
+
$element = $fixture('.element').text('element text')
|
272
276
|
listener = jasmine.createSpy('finish event listener')
|
273
277
|
$element.on('up:motion:finish', listener)
|
274
278
|
|
@@ -294,69 +298,69 @@ describe 'up.motion', ->
|
|
294
298
|
describe 'when called without arguments', ->
|
295
299
|
|
296
300
|
it 'cancels all animations on the screen', asyncSpec (next) ->
|
297
|
-
$element1 =
|
298
|
-
$element2 =
|
301
|
+
$element1 = $fixture('.element1').text('content1')
|
302
|
+
$element2 = $fixture('.element2').text('content2')
|
299
303
|
|
300
304
|
up.animate($element1, 'fade-in', duration: 3000)
|
301
305
|
up.animate($element2, 'fade-in', duration: 3000)
|
302
306
|
|
303
307
|
next =>
|
304
|
-
expect(
|
305
|
-
expect(
|
308
|
+
expect($element1).toHaveOpacity(0.0, 0.1)
|
309
|
+
expect($element2).toHaveOpacity(0.0, 0.1)
|
306
310
|
|
307
311
|
up.motion.finish()
|
308
312
|
|
309
313
|
next =>
|
310
314
|
$element1 = $('.element1')
|
311
315
|
$element2 = $('.element2')
|
312
|
-
expect(
|
313
|
-
expect(
|
316
|
+
expect($element1).toHaveOpacity(1.0)
|
317
|
+
expect($element2).toHaveOpacity(1.0)
|
314
318
|
|
315
319
|
describe 'up.morph', ->
|
316
320
|
|
317
321
|
it 'transitions between two element by absolutely positioning one element above the other', asyncSpec (next) ->
|
318
|
-
$old =
|
319
|
-
$new =
|
322
|
+
$old = $fixture('.old').text('old content').css(width: '200px', width: '200px')
|
323
|
+
$new = $fixture('.new').text('new content').css(width: '200px', width: '200px').detach()
|
320
324
|
|
321
|
-
oldDims =
|
325
|
+
oldDims = $old[0].getBoundingClientRect()
|
322
326
|
|
323
327
|
up.morph($old, $new, 'cross-fade', duration: 200, easing: 'linear')
|
324
328
|
|
325
329
|
next =>
|
326
|
-
expect(
|
327
|
-
expect(
|
330
|
+
expect($old[0].getBoundingClientRect()).toEqual(oldDims)
|
331
|
+
expect($new[0].getBoundingClientRect()).toEqual(oldDims)
|
328
332
|
|
329
|
-
expect(
|
330
|
-
expect(
|
333
|
+
expect($old).toHaveOpacity(1.0, 0.25)
|
334
|
+
expect($new).toHaveOpacity(0.0, 0.25)
|
331
335
|
|
332
336
|
next.after 100, =>
|
333
|
-
expect(
|
334
|
-
expect(
|
337
|
+
expect($old).toHaveOpacity(0.5, 0.25)
|
338
|
+
expect($new).toHaveOpacity(0.5, 0.25)
|
335
339
|
|
336
340
|
next.after (100 + (tolerance = 110)), =>
|
337
|
-
expect(
|
341
|
+
expect($new).toHaveOpacity(1.0, 0.25)
|
338
342
|
expect($old).toBeDetached()
|
339
343
|
|
340
344
|
it 'does not change the position of sibling elements (as long as the old and new elements are of equal size)', asyncSpec (next) ->
|
341
|
-
$container =
|
345
|
+
$container = $fixture('.container')
|
342
346
|
|
343
347
|
$before = $container.affix('.before').css(margin: '20px')
|
344
348
|
$old = $container.affix('.old').text('old content').css(width: '200px', width: '200px', margin: '20px')
|
345
349
|
$new = $container.affix('.new').text('new content').css(width: '200px', width: '200px', margin: '20px').detach()
|
346
350
|
$after = $container.affix('.before').css(margin: '20px')
|
347
351
|
|
348
|
-
beforeDims =
|
349
|
-
afterDims =
|
352
|
+
beforeDims = $before[0].getBoundingClientRect()
|
353
|
+
afterDims = $after[0].getBoundingClientRect()
|
350
354
|
|
351
355
|
up.morph($old, $new, 'cross-fade', duration: 30, easing: 'linear')
|
352
356
|
|
353
357
|
next =>
|
354
|
-
expect(
|
355
|
-
expect(
|
358
|
+
expect($before[0].getBoundingClientRect()).toEqual(beforeDims)
|
359
|
+
expect($after[0].getBoundingClientRect()).toEqual(afterDims)
|
356
360
|
|
357
361
|
next.after 50, =>
|
358
|
-
expect(
|
359
|
-
expect(
|
362
|
+
expect($before[0].getBoundingClientRect()).toEqual(beforeDims)
|
363
|
+
expect($after[0].getBoundingClientRect()).toEqual(afterDims)
|
360
364
|
|
361
365
|
it 'transitions between two elements that are already positioned absolutely', asyncSpec (next) ->
|
362
366
|
elementStyles =
|
@@ -365,25 +369,25 @@ describe 'up.motion', ->
|
|
365
369
|
top: '30px'
|
366
370
|
width: '200px'
|
367
371
|
width: '200px'
|
368
|
-
$old =
|
369
|
-
$new =
|
372
|
+
$old = $fixture('.old').text('old content').css(elementStyles)
|
373
|
+
$new = $fixture('.new').text('new content').css(elementStyles).detach()
|
370
374
|
|
371
|
-
oldDims =
|
375
|
+
oldDims = $old[0].getBoundingClientRect()
|
372
376
|
|
373
377
|
up.morph($old, $new, 'cross-fade', duration: 100, easing: 'linear')
|
374
378
|
|
375
379
|
next =>
|
376
|
-
expect(
|
377
|
-
expect(
|
380
|
+
expect($old[0].getBoundingClientRect()).toEqual(oldDims)
|
381
|
+
expect($new[0].getBoundingClientRect()).toEqual(oldDims)
|
378
382
|
|
379
383
|
next.after (100 + (timingTolerance = 120)), =>
|
380
384
|
expect($old).toBeDetached()
|
381
|
-
expect(
|
385
|
+
expect($new[0].getBoundingClientRect()).toEqual(oldDims)
|
382
386
|
|
383
387
|
it 'cancels an existing transition on the new element by instantly jumping to the last frame', asyncSpec (next) ->
|
384
|
-
$v1 =
|
385
|
-
$v2 =
|
386
|
-
$v3 =
|
388
|
+
$v1 = $fixture('.element').text('v1')
|
389
|
+
$v2 = $fixture('.element').text('v2')
|
390
|
+
$v3 = $fixture('.element').text('v3')
|
387
391
|
|
388
392
|
up.morph($v1, $v2, 'cross-fade', duration: 200)
|
389
393
|
|
@@ -399,8 +403,8 @@ describe 'up.motion', ->
|
|
399
403
|
expect($v3).toHaveOpacity(0.0, 0.2)
|
400
404
|
|
401
405
|
it 'detaches the old element in the DOM', (done) ->
|
402
|
-
$v1 =
|
403
|
-
$v2 =
|
406
|
+
$v1 = $fixture('.element').text('v1')
|
407
|
+
$v2 = $fixture('.element').text('v2')
|
404
408
|
|
405
409
|
morphDone = up.morph($v1, $v2, 'cross-fade', duration: 5)
|
406
410
|
|
@@ -410,53 +414,53 @@ describe 'up.motion', ->
|
|
410
414
|
done()
|
411
415
|
|
412
416
|
it 'does not leave .up-bounds elements in the DOM', (done) ->
|
413
|
-
$v1 =
|
414
|
-
$v2 =
|
417
|
+
$v1 = $fixture('.element').text('v1')
|
418
|
+
$v2 = $fixture('.element').text('v2')
|
415
419
|
|
416
420
|
morphDone = up.morph($v1, $v2, 'cross-fade', duration: 5)
|
417
421
|
|
418
422
|
morphDone.then ->
|
419
|
-
expect('.up-bounds').not.
|
423
|
+
expect('.up-bounds').not.toBeAttached()
|
420
424
|
done()
|
421
425
|
|
422
426
|
|
423
427
|
describe 'when up.animate() is called from inside a transition function', ->
|
424
428
|
|
425
429
|
it 'animates', asyncSpec (next) ->
|
426
|
-
$old =
|
427
|
-
$new =
|
430
|
+
$old = $fixture('.old').text('old content')
|
431
|
+
$new = $fixture('.new').text('new content').detach()
|
428
432
|
|
429
|
-
oldDims =
|
433
|
+
oldDims = $old[0].getBoundingClientRect()
|
430
434
|
|
431
|
-
transition = (
|
432
|
-
up.animate(
|
433
|
-
up.animate(
|
435
|
+
transition = (oldElement, newElement, options) ->
|
436
|
+
up.animate(oldElement, 'fade-out', options)
|
437
|
+
up.animate(newElement, 'fade-in', options)
|
434
438
|
|
435
439
|
up.morph($old, $new, transition, duration: 200, easing: 'linear')
|
436
440
|
|
437
441
|
next =>
|
438
|
-
expect(
|
439
|
-
expect(
|
442
|
+
expect($old[0].getBoundingClientRect()).toEqual(oldDims)
|
443
|
+
expect($new[0].getBoundingClientRect()).toEqual(oldDims)
|
440
444
|
|
441
|
-
expect(
|
442
|
-
expect(
|
445
|
+
expect($old).toHaveOpacity(1.0, 0.25)
|
446
|
+
expect($new).toHaveOpacity(0.0, 0.25)
|
443
447
|
|
444
448
|
next.after 100, =>
|
445
|
-
expect(
|
446
|
-
expect(
|
449
|
+
expect($old).toHaveOpacity(0.5, 0.25)
|
450
|
+
expect($new).toHaveOpacity(0.5, 0.25)
|
447
451
|
|
448
452
|
next.after (100 + (tolerance = 110)), =>
|
449
|
-
expect(
|
453
|
+
expect($new).toHaveOpacity(1.0, 0.1)
|
450
454
|
expect($old).toBeDetached()
|
451
455
|
expect($new).toBeAttached()
|
452
456
|
|
453
457
|
it 'finishes animations only once', asyncSpec (next) ->
|
454
|
-
$old =
|
455
|
-
$new =
|
458
|
+
$old = $fixture('.old').text('old content')
|
459
|
+
$new = $fixture('.new').text('new content').detach()
|
456
460
|
|
457
|
-
transition = (
|
458
|
-
up.animate(
|
459
|
-
up.animate(
|
461
|
+
transition = (oldElement, newElement, options) ->
|
462
|
+
up.animate(oldElement, 'fade-out', options)
|
463
|
+
up.animate(newElement, 'fade-in', options)
|
460
464
|
|
461
465
|
up.morph($old, $new, transition, duration: 200, easing: 'linear')
|
462
466
|
|
@@ -466,38 +470,38 @@ describe 'up.motion', ->
|
|
466
470
|
describe 'when up.morph() is called from inside a transition function', ->
|
467
471
|
|
468
472
|
it 'morphs', asyncSpec (next) ->
|
469
|
-
$old =
|
470
|
-
$new =
|
473
|
+
$old = $fixture('.old').text('old content')
|
474
|
+
$new = $fixture('.new').text('new content').detach()
|
471
475
|
|
472
|
-
oldDims =
|
476
|
+
oldDims = $old[0].getBoundingClientRect()
|
473
477
|
|
474
|
-
transition = (
|
475
|
-
up.morph(
|
478
|
+
transition = (oldElement, newElement, options) ->
|
479
|
+
up.morph(oldElement, newElement, 'cross-fade', options)
|
476
480
|
|
477
481
|
up.morph($old, $new, transition, duration: 400, easing: 'linear')
|
478
482
|
|
479
483
|
next =>
|
480
|
-
expect(
|
481
|
-
expect(
|
484
|
+
expect($old[0].getBoundingClientRect()).toEqual(oldDims)
|
485
|
+
expect($new[0].getBoundingClientRect()).toEqual(oldDims)
|
482
486
|
|
483
|
-
expect(
|
484
|
-
expect(
|
487
|
+
expect($old).toHaveOpacity(1.0, 0.25)
|
488
|
+
expect($new).toHaveOpacity(0.0, 0.25)
|
485
489
|
|
486
490
|
next.after 200, =>
|
487
|
-
expect(
|
488
|
-
expect(
|
491
|
+
expect($old).toHaveOpacity(0.5, 0.25)
|
492
|
+
expect($new).toHaveOpacity(0.5, 0.25)
|
489
493
|
|
490
494
|
next.after (200 + (tolerance = 110)), =>
|
491
|
-
expect(
|
495
|
+
expect($new).toHaveOpacity(1.0, 0.25)
|
492
496
|
expect($old).toBeDetached()
|
493
497
|
expect($new).toBeAttached()
|
494
498
|
|
495
499
|
it "finishes animations only once", asyncSpec (next) ->
|
496
|
-
$old =
|
497
|
-
$new =
|
500
|
+
$old = $fixture('.old').text('old content')
|
501
|
+
$new = $fixture('.new').text('new content').detach()
|
498
502
|
|
499
|
-
transition = (
|
500
|
-
up.morph(
|
503
|
+
transition = (oldElement, newElement, options) ->
|
504
|
+
up.morph(oldElement, newElement, 'cross-fade', options)
|
501
505
|
|
502
506
|
up.morph($old, $new, transition, duration: 50, easing: 'linear')
|
503
507
|
|
@@ -508,19 +512,19 @@ describe 'up.motion', ->
|
|
508
512
|
describe 'with { reveal: true } option', ->
|
509
513
|
|
510
514
|
it 'reveals the new element while making the old element within the same viewport appear as if it would keep its scroll position', asyncSpec (next) ->
|
511
|
-
$container =
|
515
|
+
$container = $fixture('.container[up-viewport]').css
|
512
516
|
'width': '200px'
|
513
517
|
'height': '200px'
|
514
518
|
'overflow-y': 'scroll'
|
515
519
|
'position': 'fixed'
|
516
520
|
'left': 0,
|
517
521
|
'top': 0
|
518
|
-
$old =
|
522
|
+
$old = $fixture('.old').appendTo($container).css(height: '600px')
|
519
523
|
$container.scrollTop(300)
|
520
524
|
|
521
525
|
expect($container.scrollTop()).toEqual(300)
|
522
526
|
|
523
|
-
$new =
|
527
|
+
$new = $fixture('.new').css(height: '600px').detach()
|
524
528
|
|
525
529
|
up.morph($old, $new, 'cross-fade', duration: 50, reveal: true)
|
526
530
|
|
@@ -544,8 +548,8 @@ describe 'up.motion', ->
|
|
544
548
|
up.motion.config.enabled = false
|
545
549
|
|
546
550
|
it "doesn't animate and detaches the old element instead", asyncSpec (next) ->
|
547
|
-
$old =
|
548
|
-
$new =
|
551
|
+
$old = $fixture('.old').text('old content')
|
552
|
+
$new = $fixture('.new').text('new content')
|
549
553
|
up.morph($old, $new, 'cross-fade', duration: 1000)
|
550
554
|
|
551
555
|
next =>
|
@@ -559,8 +563,8 @@ describe 'up.motion', ->
|
|
559
563
|
describe "when called with a `#{JSON.stringify(noneTransition)}` transition", ->
|
560
564
|
|
561
565
|
it "doesn't animate and detaches the old element instead", asyncSpec (next) ->
|
562
|
-
$old =
|
563
|
-
$new =
|
566
|
+
$old = $fixture('.old').text('old content')
|
567
|
+
$new = $fixture('.new').text('new content')
|
564
568
|
up.morph($old, $new, noneTransition, duration: 1000)
|
565
569
|
|
566
570
|
next =>
|