How to implement toggle functionality on JQuery UI Selectable?

前端 未结 3 1625
[愿得一人]
[愿得一人] 2021-01-12 14:45

I\'m using JQuery UI - Selectable. I want to deselect the element if it has been pressed and it has already been selected (toggle)

Could you help me to add this func

3条回答
  •  太阳男子
    2021-01-12 15:41

    You have to inject two simple elements in the code to achieve what you want. This just inverts the metaKey boolean, whenever you need inverted/toggle functionality.

    options: {
        appendTo: 'body',
        autoRefresh: true,
        distance: 0,
        filter: '*',
        tolerance: 'touch',
        inverted: false /* <= FIRST*/
    },
    
    _mouseStart: function(event) {
        var self = this;
    
        this.opos = [event.pageX, event.pageY];
    
        if (this.options.disabled)
            return;
    
        var options = this.options;
    
        if (options.inverted) /* <= SECOND*/
            event.metaKey = !event.metaKey; /* <= SECOND*/
    

提交回复
热议问题