Skip to content

Commit c889ce0

Browse files
authored
Merge pull request #571 from PolymerElements/reset-attached
Reset threshold-triggered on attached
2 parents 1bdfcb2 + a17f50a commit c889ce0

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

app-scroll-effects/app-scroll-effects-behavior.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ export const AppScrollEffectsBehavior = [
227227
return Math.max(0, this._scrollTop);
228228
},
229229

230+
attached: function() {
231+
this._scrollStateChanged();
232+
},
233+
230234
detached: function() {
231235
this._tearDownEffects();
232236
},
@@ -368,6 +372,10 @@ export const AppScrollEffectsBehavior = [
368372
* Overrides the `_scrollHandler`.
369373
*/
370374
_scrollHandler: function() {
375+
this._scrollStateChanged();
376+
},
377+
378+
_scrollStateChanged: function() {
371379
if (!this.disabled) {
372380
var scrollTop = this._clampedScrollTop;
373381
this._updateScrollState(scrollTop);

app-scroll-effects/test/app-scroll-effects-behavior.html

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,35 @@
225225
]);
226226
});
227227
});
228+
229+
test('reset threshold-triggered on attached (#570)', function(done) {
230+
flush(function() {
231+
var parent = container.parentElement;
232+
assert.isUndefined(container.thresholdTriggered);
233+
assert.equal(container.threshold, 0);
234+
container.threshold = 100;
235+
236+
scrollTestHelper(container.scrollTarget, [
237+
{
238+
y: 100,
239+
callback: function() {
240+
assert.isTrue(container.thresholdTriggered);
241+
parent.removeChild(container);
242+
assert.isTrue(container.thresholdTriggered);
243+
}
244+
},
245+
{
246+
y: 0,
247+
callback: function() {
248+
assert.isTrue(container.thresholdTriggered);
249+
parent.appendChild(container);
250+
assert.isFalse(container.thresholdTriggered);
251+
done();
252+
}
253+
}
254+
]);
255+
});
256+
});
228257
});
229258
</script>
230259

0 commit comments

Comments
 (0)