Improved the pull down refresh code and logic.
This commit is contained in:
		| @@ -2402,9 +2402,13 @@ class list extends IgniteTemplate { | |||||||
|     } |     } | ||||||
|  |  | ||||||
|     onRefreshTouchStart(event) { |     onRefreshTouchStart(event) { | ||||||
|         var touch = event.touches[0]; |         this.refreshTouchStartY = event.touches[0].clientY; | ||||||
|  |         this.refreshTouchStartTop = this.element.parentElement.scrollTop; | ||||||
|  |  | ||||||
|         this.refreshTouchStartY = touch.clientY; |         //Save the default overflow value if we don't have it yet. | ||||||
|  |         if (!this.refreshTouchOverflow) { | ||||||
|  |             this.refreshTouchOverflow = window.getComputedStyle(this.element.parentElement).getPropertyValue("overflow-y"); | ||||||
|  |         } | ||||||
|          |          | ||||||
|         this.element.parentElement.addEventListener("touchmove", this.refreshTouchMoveListener); |         this.element.parentElement.addEventListener("touchmove", this.refreshTouchMoveListener); | ||||||
|         this.element.parentElement.addEventListener("touchend", this.refreshTouchEndListener); |         this.element.parentElement.addEventListener("touchend", this.refreshTouchEndListener); | ||||||
| @@ -2413,18 +2417,15 @@ class list extends IgniteTemplate { | |||||||
|     onRefreshTouchMove(event) { |     onRefreshTouchMove(event) { | ||||||
|         var touch = event.touches[0]; |         var touch = event.touches[0]; | ||||||
|  |  | ||||||
|         if (this.element.parentElement.scrollTop > 0) { |         var diff = touch.clientY - (this.refreshTouchStartY + this.refreshTouchStartTop + 15); | ||||||
|             this.refreshTouchStartY = touch.clientY; |  | ||||||
|         } else { |  | ||||||
|             var diff = Math.max(touch.clientY - this.refreshTouchStartY, 0) / 2; |  | ||||||
|  |  | ||||||
|             if (diff < (40 * window.devicePixelRatio)) { |         if (diff < 125) { | ||||||
|             if (this.refreshPlaceholderElement instanceof IgniteTemplate) { |             if (this.refreshPlaceholderElement instanceof IgniteTemplate) { | ||||||
|                     this.refreshPlaceholderElement.element.style.setProperty("min-height", `${diff}px`); |                 this.refreshPlaceholderElement.element.style.setProperty("min-height", `${Math.max(diff, 0)}px`); | ||||||
|                     this.refreshPlaceholderElement.element.style.setProperty("height", `${diff}px`); |                 this.refreshPlaceholderElement.element.style.setProperty("height", `${Math.max(diff, 0)}px`); | ||||||
|             } else { |             } else { | ||||||
|                     this.refreshPlaceholderElement.style.setProperty("min-height", `${diff}px`); |                 this.refreshPlaceholderElement.style.setProperty("min-height", `${Math.max(diff, 0)}px`); | ||||||
|                     this.refreshPlaceholderElement.style.setProperty("height", `${diff}px`); |                 this.refreshPlaceholderElement.style.setProperty("height", `${Math.max(diff, 0)}px`); | ||||||
|             } |             } | ||||||
|         } else { |         } else { | ||||||
|             if (this.refreshPlaceholderElement instanceof IgniteTemplate) { |             if (this.refreshPlaceholderElement instanceof IgniteTemplate) { | ||||||
| @@ -2436,9 +2437,17 @@ class list extends IgniteTemplate { | |||||||
|             } |             } | ||||||
|  |  | ||||||
|             this.element.parentElement.removeEventListener("touchmove", this.refreshTouchMoveListener); |             this.element.parentElement.removeEventListener("touchmove", this.refreshTouchMoveListener); | ||||||
|  |             this.element.parentElement.removeEventListener("touchend", this.refreshTouchEndListener); | ||||||
|  |             this.element.parentElement.style.removeProperty("overflow-y"); | ||||||
|  |             this.element.parentElement.style.setProperty("overflow-y", this.refreshTouchOverflow, "important"); | ||||||
|  |  | ||||||
|             this.refreshCallback(); |             this.refreshCallback(); | ||||||
|  |  | ||||||
|  |             return; | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         if (diff > 0 && this.element.parentElement.style["overflow-y"] != "hidden") { | ||||||
|  |             this.element.parentElement.style.setProperty("overflow-y", "hidden", "important"); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -2453,6 +2462,8 @@ class list extends IgniteTemplate { | |||||||
|  |  | ||||||
|         this.element.parentElement.removeEventListener("touchmove", this.refreshTouchMoveListener); |         this.element.parentElement.removeEventListener("touchmove", this.refreshTouchMoveListener); | ||||||
|         this.element.parentElement.removeEventListener("touchend", this.refreshTouchEndListener); |         this.element.parentElement.removeEventListener("touchend", this.refreshTouchEndListener); | ||||||
|  |         this.element.parentElement.style.removeProperty("overflow-y"); | ||||||
|  |         this.element.parentElement.style.setProperty("overflow-y", this.refreshTouchOverflow, "important"); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|     onStyleChanged(name, newValue) { |     onStyleChanged(name, newValue) { | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user