Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError: Cannot set property 'detach' of undefined #4

Closed
Itee opened this issue Mar 6, 2018 · 0 comments
Closed

TypeError: Cannot set property 'detach' of undefined #4

Itee opened this issue Mar 6, 2018 · 0 comments

Comments

@Itee
Copy link
Contributor

Itee commented Mar 6, 2018

Hi,

i got some trouble using this package.

I use this code snippet:

import Vue from '../../../../node_modules/vue/dist/vue.esm'
import resize from 'vue-resize-directive'

export default Vue.component( 'MyResizableComponent', {
    template: `
        <div v-resize="onResize"></div>
    `,
    directives: {
        resize
    },
    methods:  {

        onResize ( event ) {

            const domElement = this.$el
            console.log(`client(w/h): ${domElement.clientWidth}/${domElement.clientHeight}`)
            console.log(`offset(w/h): ${domElement.offsetWidth}/${domElement.offsetHeight}`)
            console.log(`event: ${event}`)

        }

    }

} )

and i got this errors:

[Vue warn]: Error in directive resize inserted hook: "TypeError: Cannot set property 'detach' of undefined"

and

Cannot set property 'detach' of undefined at ResizeSensor

Apparently the this argument is not correctly bound here:

/**
           * Class for dimension change detection.
           *
           * @param {Element|Element[]|Elements|jQuery} element
           * @param {Function} callback
           *
           * @constructor
           */
          var ResizeSensor = function ResizeSensor(element, callback) {
              
              //...

              this.detach = function (ev) {
                  ResizeSensor.detach(element, ev);
              };
          };
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant