From 9a8705b7156e3330687ebc1a164dd1df3a3e5125 Mon Sep 17 00:00:00 2001 From: MattMo Date: Tue, 24 May 2022 08:01:28 -0700 Subject: [PATCH] Fixed a bug where the list refresh was being activated when the scroll top wasn't 0. --- ignite-template.js | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/ignite-template.js b/ignite-template.js index 2928ec1..9f52e83 100644 --- a/ignite-template.js +++ b/ignite-template.js @@ -231,7 +231,7 @@ class IgniteTemplate { if (live) { this.on("input", valueChanged); } - + this.on("change", valueChanged); this.on("keyup", valueChanged); } @@ -2405,28 +2405,33 @@ class list extends IgniteTemplate { onRefreshTouchMove(event) { var touch = event.touches[0]; - var diff = Math.max(touch.clientY - this.refreshTouchStartY, 0); - if (diff < 100) { - if (this.refreshPlaceholderElement instanceof IgniteTemplate) { - this.refreshPlaceholderElement.element.style.setProperty("min-height", `${diff}px`); - this.refreshPlaceholderElement.element.style.setProperty("height", `${diff}px`); - } else { - this.refreshPlaceholderElement.style.setProperty("min-height", `${diff}px`); - this.refreshPlaceholderElement.style.setProperty("height", `${diff}px`); - } + if (this.element.parentElement.scrollTop > 0) { + this.refreshTouchStartY = touch.clientY; } else { - if (this.refreshPlaceholderElement instanceof IgniteTemplate) { - this.refreshPlaceholderElement.element.style.setProperty("min-height", "0px"); - this.refreshPlaceholderElement.element.style.setProperty("height", "0px"); + var diff = Math.max(touch.clientY - this.refreshTouchStartY, 0); + + if (diff < 100) { + if (this.refreshPlaceholderElement instanceof IgniteTemplate) { + this.refreshPlaceholderElement.element.style.setProperty("min-height", `${diff}px`); + this.refreshPlaceholderElement.element.style.setProperty("height", `${diff}px`); + } else { + this.refreshPlaceholderElement.style.setProperty("min-height", `${diff}px`); + this.refreshPlaceholderElement.style.setProperty("height", `${diff}px`); + } } else { - this.refreshPlaceholderElement.style.setProperty("min-height", "0px"); - this.refreshPlaceholderElement.style.setProperty("height", "0px"); + if (this.refreshPlaceholderElement instanceof IgniteTemplate) { + this.refreshPlaceholderElement.element.style.setProperty("min-height", "0px"); + this.refreshPlaceholderElement.element.style.setProperty("height", "0px"); + } else { + this.refreshPlaceholderElement.style.setProperty("min-height", "0px"); + this.refreshPlaceholderElement.style.setProperty("height", "0px"); + } + + this.element.parentElement.removeEventListener("touchmove", this.refreshTouchMoveListener); + + this.refreshCallback(); } - - this.element.parentElement.removeEventListener("touchmove", this.refreshTouchMoveListener); - - this.refreshCallback(); } }