jQuery Plugin: Get the “this” object inside other functions

I am trying to create a panorama slider as a jQuery plugin, and I have the following code:

 $.fn.panorama = function(settings) {

    var myPanorama = this;
    ..

    this.mousedown(function(e){

       //do stuff 
       $(this).css... //this all work
    }


    //Call mouseup on document in case user lets go of mouse outside draggable object
$(document).mouseup(function(){
    $(myPanorama).easeDragging(); //works but probably not the way to do it
    this.easeDragging(); //ideal but refers to wrong object
 });

    }

My question is how do I refer to the this object inside the $(document).mouseup call?

Since it thinks this is the document itself and not the object attached to the plugin.

For now I am just making a variable and it works but there must be a better way!

thanks!

6
задан 1stthomas 14 October 2018 в 13:22
поделиться