diff --git a/index.js b/index.js index 87c6a48..d598664 100644 --- a/index.js +++ b/index.js @@ -965,11 +965,13 @@ Code related to measuring the size of the carousel after mounting // Add resize listening mounted: function () { this.onResize(); - return window.addEventListener('resize', this.onResize); + // Resize observer listens for the element itself to change dimensions + this.resizeObserver = new ResizeObserver(this.onResize); + return this.resizeObserver.observe(this.$el); }, - // Cleanup listeners beforeDestroy: function () { - return window.removeEventListener('resize', this.onResize); + var ref; + return (ref = this.resizeObserver) != null ? ref.disconnect() : void 0; }, computed: { // The width of a page of slides, which may be less than the carouselWidth diff --git a/package.json b/package.json index 1dcea4d..a4a41e3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "vue-ssr-carousel", - "version": "2.1.0", + "version": "2.2.0", "description": "A performance focused Vue carousel designed for SSR/SSG environments.", "main": "index.js", "scripts": {