nathancahill / split

Unopinionated utilities for resizeable split views
https://split.js.org/
MIT License
6.15k stars 450 forks source link

Need to prohibit the control of drag and drop #144

Closed DreamLi1314 closed 6 years ago

DreamLi1314 commented 6 years ago

In some cases I need to manually control the left pane and the right pane to a fixed size, so I need to disable the user from dragging the resize function. We don't seem to have this feature right now. I saw some code, but it didn't seem to work:

function drag (e) {
   var offset;

   if (!this.dragging) { return }
.....
DreamLi1314 commented 6 years ago

I modify the source code like as:

this.dragging = false;
if (!this.dragging) { return }

This can achieve my goal, but I can't set this.dragging outside.

nathancahill commented 6 years ago

If you want to disable the split, you can call split.destroy() and the sizes will be fixed and not draggable. You can re-initiate it to reenable dragging.

DreamLi1314 commented 6 years ago

There are also some problems with this:

now, I handle it by setSizes, like as:

let config = {
         sizes: this.sizes,
         ...
         onDrag: (event: any) => {
            if(!this.dragEnable) {
               this.setSizes(this.sizes);
            }

            this.onDrag.emit(event);
         },
        ...
      };

      this.splitInstance = Split(children, config);
nathancahill commented 6 years ago

What is the exact error you get when you call split.destroy?