vue-twentytwenty icon indicating copy to clipboard operation
vue-twentytwenty copied to clipboard

imgOffset.left is Undefined and Causes Application Error

Open devanflaherty opened this issue 3 years ago • 0 comments

Problem

We currently use this plugin for some before/after scenarios and generally has been great.

There is one issue though where if a user attempts to move the slider before the second image is loaded in (generally the image on the right) then an error is thrown and causes my application to break.

Seems to be located here:

./node_modules/vue-twentytwenty/dist/vue-twentytwenty.common.js in apply at line 327:89


moveSlide(event) {
      if (this.sliding) {
        var x = (event.touches ? event.touches[0].pageX : event.pageX) - this.imgOffset.left;
        x = x < 0 ? 0 : x > this.w ? this.w : x;
        return this.slideOffset = x / this.w;
      }

Suggestion

I think a simple check against this.imgOffset first would resolve this error from occurring.

Thanks for your time.

devanflaherty avatar Jan 25 '22 21:01 devanflaherty