splitpanes icon indicating copy to clipboard operation
splitpanes copied to clipboard

Allow sizes in pixels

Open cimpok opened this issue 5 years ago • 20 comments

Could you please add absolute sizes to panes? So we would be able to specify certain pane's initial widths not in percents of the parent but in absolute values, like px. And also disable resizing for certain panes would be welcome. Thanks.

cimpok avatar Feb 25 '20 20:02 cimpok

@antoniandre any thoughts on this?

nmearl avatar May 05 '20 16:05 nmearl

Hi guys I am adding this in my to do list. It involves a big refactoring though.

antoniandre avatar Oct 19 '20 11:10 antoniandre

nice to have it

carlosyan1807 avatar Dec 21 '20 06:12 carlosyan1807

I'm also looking for this feature! Thx @antoniandre in advance!

aendre avatar Jan 13 '21 16:01 aendre

any progress on this?? Coz im also waiting for this feature

rajithaeyee avatar Feb 17 '21 08:02 rajithaeyee

I'm also looking forward for this feature!

Hextar avatar Mar 02 '21 19:03 Hextar

I'm also looking forward for this feature! too!

zzxxiinn avatar May 12 '21 07:05 zzxxiinn

Would be a game changer

alectrocute avatar Jul 22 '21 15:07 alectrocute

+1

jloganolson avatar Jul 27 '21 14:07 jloganolson

any thoughts on this?

jinrui-kooboo avatar Aug 26 '21 05:08 jinrui-kooboo

+1

WhatzzUp avatar Nov 12 '21 22:11 WhatzzUp

+1

zhangbaojia avatar Dec 06 '21 06:12 zhangbaojia

+1

karukenert avatar Feb 26 '22 15:02 karukenert

I guess it will never be live :(

cihadturhan avatar Apr 13 '22 10:04 cihadturhan

+10086

fulus06 avatar Jul 20 '22 09:07 fulus06

+1

Ldkwewde01 avatar Sep 10 '22 03:09 Ldkwewde01

try this ...

<div ref="SplitPanesRef" class="flex flex-col grow-1">
  <splitpanes :horizontal="false">
    <pane class="xcol" 
      :min-size="20" 
      :size="100 - propEditorWidthPercent" 
      :max-size="100 - propEditorWidthPercent">
      <div class="flex flex-col  grow-1 bg-gray-100"></div>
    </pane>
    <pane class="flex flex-col p-10 bg-white" 
      :min-size="propEditorWidthPercent" 
      :size="propEditorWidthPercent" 
      :max-size="80">
      <span class="h-40 rounded bg-gray-50"></span>
    </pane>
  </splitpanes>
</div>

// Vue3 Code
...
setup(props, context){
    const SplitPanesRef = ref(null as any);
    const SplitPanesRefResizeObserver = ref(null as ResizeObserver|null); // add Observer 
    const propEditorWidthPercent = ref(0);
    onMounted(()=>{
      console.log(route.params,'params');
      SplitPanesRefResizeObserver.value = new ResizeObserver(() => {
        propEditorWidthPercent.value = Math.min(Math.round( 360 / SplitPanesRef.value.clientWidth * 100), 50);
      })
      SplitPanesRefResizeObserver.value.observe(SplitPanesRef.value); // remove Observer
    });
    onBeforeUnmount(()=>{
      SplitPanesRefResizeObserver.value && SplitPanesRefResizeObserver.value.disconnect()
    })
    return {
    SplitPanesRef,
      propEditorWidthPercent,
    }
}

enmotion avatar Oct 25 '22 08:10 enmotion

First of all, thank you very much for this project, it has been very helpful to me today. However, I noticed this historical issue while using it and it seems to have been around for quite some time. I was wondering if the author still plans to add this feature?

mengdebiao avatar Mar 30 '23 08:03 mengdebiao

First of all, thank you very much for this project, it has been very helpful to me today. However, I noticed this historical issue while using it and it seems to have been around for quite some time. I was wondering if the author still plans to add this feature?

try this ...

<template>
  <Splitpanes ref="splitpanesRef" class="chat-container" :dbl-click-splitter="false">
    <Pane class="left" :size="leftPaneSize" max-size="50"></Pane>
    <Pane class="right" :size="100 - leftPaneSize"></Pane>
  </Splitpanes>
</template>

<script setup lang="ts">
import { ref, onMounted } from 'vue'
import { useResizeObserver } from '@vueuse/core'
import { Splitpanes, Pane } from 'splitpanes'
import 'splitpanes/dist/splitpanes.css'

const DEFAULT_WIDTH = 270
const leftPaneSize = ref(30)
const splitpanesRef = ref()

const setLeftPaneSize = () => {
  const width = splitpanesRef.value.$el.clientWidth
  leftPaneSize.value = (DEFAULT_WIDTH / width) * 100
}
onMounted(() => {
  setLeftPaneSize()

  useResizeObserver(splitpanesRef, (entries) => {
    const entry = entries[0]
    const { width } = entry.contentRect
    leftPaneSize.value = (DEFAULT_WIDTH / width) * 100
  })
})
</script>

mengdebiao avatar Mar 31 '23 07:03 mengdebiao