Skip to content

Commit

Permalink
Refactor #6826 - For Splitter
Browse files Browse the repository at this point in the history
  • Loading branch information
mertsincan committed Nov 21, 2024
1 parent db61c5e commit 418d81a
Showing 1 changed file with 3 additions and 24 deletions.
27 changes: 3 additions & 24 deletions packages/primevue/src/splitter/Splitter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</template>

<script>
import { getHeight, getOuterHeight, getOuterWidth, getWidth } from '@primeuix/utils/dom';
import { getHeight, getOuterHeight, getOuterWidth, getWidth, isRTL } from '@primeuix/utils/dom';
import { isArray } from '@primeuix/utils/object';
import { getVNodeProp } from '@primevue/core/utils';
import BaseSplitter from './BaseSplitter.vue';
Expand All @@ -47,40 +47,19 @@ export default {
panelSizes: null,
prevPanelIndex: null,
timer: null,
mutationObserver: null,
data() {
return {
prevSize: null,
isRTL: false
prevSize: null
};
},
mounted() {
this.initializePanels();
this.updateDirection();
this.observeDirectionChanges();
},
beforeUnmount() {
this.clear();
this.unbindMouseListeners();
if (this.mutationObserver) {
this.mutationObserver.disconnect();
}
},
methods: {
updateDirection() {
this.isRTL = !!this.$el.closest('[dir="rtl"]');
},
observeDirectionChanges() {
const targetNode = document.documentElement;
const config = { attributes: true, attributeFilter: ['dir'] };
this.mutationObserver = new MutationObserver(() => {
this.updateDirection();
});
this.mutationObserver.observe(targetNode, config);
},
isSplitterPanel(child) {
return child.type.name === 'SplitterPanel';
},
Expand Down Expand Up @@ -147,7 +126,7 @@ export default {
}
} else {
if (this.horizontal) {
if (this.isRTL) {
if (isRTL(this.$el)) {
newPos = ((this.startPos - event.pageX) * 100) / this.size;
} else {
newPos = ((event.pageX - this.startPos) * 100) / this.size;
Expand Down

0 comments on commit 418d81a

Please sign in to comment.