diff --git a/bower.json b/bower.json index 6904358..c2985c1 100644 --- a/bower.json +++ b/bower.json @@ -1,7 +1,7 @@ { "name": "strolch-wc-paging", "description": "Strolch WebComponent Paging", - "version": "0.2.0", + "version": "0.2.1", "authors": [ "Robert von Burg" ], diff --git a/strolch-wc-paging-behavior.html b/strolch-wc-paging-behavior.html index b6ff698..dff6ba1 100644 --- a/strolch-wc-paging-behavior.html +++ b/strolch-wc-paging-behavior.html @@ -16,6 +16,10 @@ previousOffset: 0, lastOffset: 0 } + }, + scrollTarget: { + type: Object, + value: null } }, @@ -75,6 +79,18 @@ this.ajax.params.limit = this.dataObj.limit; this.ajax.params.offset = this.dataObj.offset; this.ajax.generateRequest(); + this.ajax.addEventListener('response', this); + }, + handleEvent: function (event) { + if (event.type !== "response") + return; + + this.ajax.removeEventListener('response', this); + if (this.scrollTarget != null) { + this.scrollTarget.scrollIntoView({behavior: "smooth", block: "start", inline: "start"}); + } else { + window.scrollTo({top: 0, left: 0, behavior: "smooth"}); + } } }; \ No newline at end of file