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

Can we add a new function call collapse and expand panel on the left or on the right? #6

Open
Yim-Sekny opened this issue Jun 30, 2018 · 8 comments

Comments

@Yim-Sekny
Copy link

imagin that we wanna use panel for show full screen map, so we need to collapse panel on the left when click on fullscreen

@kevinelliott
Copy link

This would be great!

@notchris
Copy link

notchris commented Feb 23, 2020

@yimseknyCorarl @kevinelliott
You can achieve this by changing the percent value of the component within a method.
For example:

<template>
  <div id="app">
    <split-pane ref="example" :min-percent='20' :default-percent='50' split="vertical">
        <template slot="paneL">
            <div>Left</div>
        </template>
        <template slot="paneR">
            <div>
              <button @click="collapse" type="button">Toggle Collapse</button>
            </div>
        </template>
    </split-pane>
  </div>
</template>

<script>
export default {
  name: 'App',
  data () {
    return {
        isCollapsed: false
    }
  },
  methods: {
      collapse () {
          if (this.isCollapsed) {
              this.$refs.example.percent = 50;
              this.isCollapsed = false;
          } else {
              this.$refs.example.percent = 0;
              this.isCollapsed = true;
          }
      }
  }
}
</script>

@morph3us-net
Copy link

Is there any way I could achieve the same effect through clicking on
"splitter-pane-resizer vertical" or
"splitter-pane-resizer horizontal"
(the handle bars) directly?

It'd be awesome if I wouldn't need to add another button just for this. Thanks in advance!

@notchris
Copy link

@morph3us-net Without modifying the build itself you would have to add an event listener to the handles to invoke a vue function to modify the percent values. It would be less clean, but wouldn't require a new bundle. Though, it may be easier to pull the project and make an MR

@morph3us-net
Copy link

Thanks for the answer!
I had tried to add an event handler myself, but didnt get far. (If you are interested, I posted on stackoverflow)

Excuse me, but what is a MR?

@notchris
Copy link

@morph3us-net One way, is to add in your mounted() function, an event listener on the pane divider. I haven't tested this, but something like...

mounted () {
   document.querySelector('.splitter-pane-resizer.vertical').addEventListener('click', (event) => {
              this.$refs.example.percent = 50;
              this.isCollapsed = false;
   })
} 

@notchris
Copy link

And even better if you can remove the event listener when the component is destroyed 👯

@morph3us-net
Copy link

Unfortunately, this does not work at all. I tried to make it print out a console log, but nothing happens.
Thanks for the reply, though.

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

4 participants