Integrate a feature in Vue-Multipane component for inserting page breaks

Having some issues with the Vue-multipane component in my specific use case and struggling to find a solution.

I'm attempting to disable the multipane feature once the screen size is smaller than 768px and switch to displaying full-width rows instead of columns for better usability on mobile devices.

However, I've encountered two main problems:

  • Shrinked pane does not expand to 100% width when the screen size goes below 768px (refer to screenshots). After reducing the width of the pane with the handle, try resizing the window width below 786px to observe this issue.
  • The handle disappears when the screen size is between 768 - 770px (near the breakpoint). The page break does not trigger, but the handle is not visible. Currently investigating this problem for a possible fix.

(handle missing)

When reduced to 767px (should be maximized to 100%) - shrink the pane first and then reduce the window width:

The expected layout should look like this (correctly displayed on page load):

Please take a look at this JSFiddle or review the code snippet below.

It's recommended to visit JSFiddle for easier resizing and testing of the mentioned behavior.

Troubleshooting Steps Taken:

  • Added CSS styles flex-grow: 1 and width: 100%; within the media query of the left-pane without success.
  • Regarding the handle issue: Adjusted the breakpoint position, but the behavior persisted.

Note: Testing conducted using Firefox browser.

//console.log(Multipane, window)

const PageBreak = {
data() {
   return {
     screenWidth: document.documentElement.clientHeight,
    }
  },
computed: {
  largeScreen () {
    return this.screenWidth > 768; // Considering 10px for handle
    }
  },
  mounted: function () {   
    window.addEventListener('resize', this.handleResize)
  },
  beforeDestroy: function () {
    window.removeEventListener('resize', this.handleResize)
  },

  methods: {
    handleResize (event) {
      this.screenWidth = document.documentElement.clientWidth
    }
  }
}

new Vue({
el: '#app',
  mixins: [ PageBreak ]
})
.custom-resizer {
  width: 100%;
  height: 400px;
}

.custom-resizer > .pane {
  text-align: left;
  padding: 15px;
  overflow: hidden;
  background: #eee;
  border: 1px solid #ccc;
}

.custom-resizer > .multipane-resizer {
  margin: 0;
  left: 0;
  position: relative;
}
.custom-resizer > .multipane-resizer:before {
  display: block;
  content: "";
  width: 3px;
  height: 40px;
  position: absolute;
  top: 50%;
  left: 50%;
  margin-top: -20px;
  margin-left: -1.5px;
  border-left: 1px solid #ccc;
  border-right: 1px solid #ccc;
}
.custom-resizer > .multipane-resizer:hover:before {
  border-color: #999;
}

.left-pane {
  width: 50%;
}

@media (max-width: 768px) {
  /* Stack panes if smaller than 768px */
  .multipane.layout-v {
    /* flex-direction: column; */
    display: block;
  }

  .left-pane {
    /* flex-grow: 1; */
    /* How to maximize left-pane if it was shrinked previously? */
    width: 100%;
  }
}
<link href="https://cdnjs.cloudflare.com/ajax/libs/bulma/0.5.3/css/bulma.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.4.4/vue.js"></script>
<script src="https://unpkg.com/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6412110149091108100d14050a0124544a5d4a51">[email protected]</a>/dist/vue-multipane.min.js"></script>
<div id="app">
  <multipane class="custom-resizer" layout="vertical">
  <div class="pane left-pane">
    <div>
      <h6 class="title is-6">Pane 1</h6>
    </div>
  </div>
  <multipane-resizer v-if="largeScreen"></multipane-resizer>
  <div class="pane" :style="{ flexGrow: 1 }">
    <div>
      <h6 class="title is-6">Pane 2</h6>
    </div>
  </div>
  <!--<multipane-resizer></multipane-resizer>
  <div class="pane" :style="{ flexGrow: 1 }">
    <div>
      <h6 class="title is-6">Pane 3</h6>
    </div>
  </div>-->
</multipane>
</div>

Answer №1

I have successfully resolved the issues at hand. (Although the method used to fix the handle issue with the page break position may seem unconventional, it is effective.)

Allow me to elaborate on my approach:

  • To address the screen size limitation, I assigned the full_width class to the left pane when the screen width is less than 768px, ensuring maximum coverage by setting the pane's width to 100% !important using Vue code:
    :class="{full_width: !largeScreen}"
  • Upon setting the page break position to 768px, it became apparent that the handle was missing. By adjusting the position down by 17px (accounting for padding and border adjustments), I was able to rectify this issue. Within the computed property of largeScreen, I implemented a conditional statement as follows:
    return this.screenWidth > (768 - 17);
    (I verified this through console logging the screen size)

Please refer to this fiddle for further details.

If you have insights into why altering the position by 17px resolves the handle issue, kindly share your thoughts.

The current solution meets my needs and functions satisfactorily. Considering submitting an issue to the Vue-multipane repository for a feature enhancement request might be beneficial. Directly integrating this functionality into the Multipane component and enabling breakpoint customization via property assignment could streamline the process.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Troubleshooting: Layout display issue on Internet Explorer 8

The first image is from IE9 and above, while the second one is from IE8. In IE8, the right side goes down because it's displaying in mobile view (Check the top menu) Here is the header code I am using: <meta charset="utf-8"> <meta h ...

What is the best way to incorporate flags in a nodejs application when using npm run-script?

I have a NodeJS file that I execute using an "npm" command. I've been attempting to display all arguments (including flags). When the file is executed by directly calling the node executable, it functions correctly. However, when I use the npm command ...

Angular 7 - Customize Mat-select-value color depending on a specific condition

One issue I am facing is changing the color of a selected value in a mat select based on a condition. This change should be visually apparent to the user. Although accessing mat-select-value from the styles is possible, implementing a condition using ng-cl ...

Tips for finishing a row of images using CSS3

Here is the code snippet that I am currently working with: <div id="images" class="img"/> <img src="spiderman.png" alt=""/> <img src="superman.png" alt="" height="25%" width="25%"/> <img src="batman.png" alt="" /> </div> ...

Transitioning Between Div Elements Using Jquery

I am stuck with the following HTML code: <section> <div id="first"> ---content </div> <div id="second"> ---content </div> </section> When the page loads, the second div and its contents are not visible (I'm uns ...

The AngularJS model does not reflect changes after I make edits in the editor

Currently, I am utilizing Jhtmlarea and have created a custom directive as follows: test.directive('jhtml', function () { return { restrict: 'A', replace: false, link: function (s ...

Identifying when a paste event occurs within a contenteditable field

How do you detect and prevent a paste event in a content editable div so that you can intercept and sanitize the paste to only include text? Another concern is not losing focus after completing the paste + sanitize process. ...

Reactjs, encountering a hitch in utilizing material UI: Incompatible hook call detected

As a newcomer to React, I decided to incorporate Material UI components into my project. After installing the components locally using npm install and importing them into my project, I encountered an error when trying to run start: Error: Invalid hook call ...

What is the best way to make a container 100% tall and display a navigation bar?

Struggling to properly render my React page This is what I have: ReactDOM.render( <React.StrictMode> <Provider store={store}> <Router /> </Provider> </React.StrictMode>, document.getEl ...

Having trouble integrating MaterialUI Datepicker, Dayjs, useFormik, and Yup

Currently, I am facing a recurring issue with the Material UI Date picker in conjunction with day js. The problem arises when I select a date on the calendar for the first time, it updates correctly in the text field but fails to work thereafter. Additiona ...

Ways to unveil a concealed div element using JavaScript

If javascript is disabled, I want to hide a div. If javascript is enabled, however, I don't want to rely on using the <noscript> tag due to issues in Chrome and Opera. Instead, my approach is as follows: <div id="box" style="display:none"> ...

When using vue.js, I am able to successfully copy data by clicking on a text box, but unfortunately

I am facing an issue where the copied value from one text box to another is not passing validation upon clicking a checkbox. I need help resolving this issue, and I also have another concern about validating specific text boxes for numbers using regex with ...

How can I get the bootstrap grid to span across multiple rows?

I'm trying to create a collage of images using Bootstrap 5, but I can't figure out how to make elements span multiple rows. Here's the layout I want to achieve: https://i.sstatic.net/JjnF0.png (guess I don't have a good reputation yet ...

Express framework converted the data type BIGINT to String in DB2

When using the express version "4.16.3", we encountered a vulnerability to Prototype Pollution, so we upgraded to "4.18.1". However, some APIs are now showing errors related to data types - they were integer and are now string. For example: "MEMORY_examp ...

Centered on the screen are the input field and corresponding label

I am in the process of creating a signup form, and I have encountered an issue. How can I make the input wider without using a fixed width like width: 420px? Additionally, I would like to center both the input field and the label. I envision something simi ...

Transfer PHP's uniqid() function to real-time using JavaScript with jQuery

Seeking a compact JavaScript(jQuery) code snippet to achieve this: date("r",hexdec(substr(uniqid(),0,8))); Your assistance is highly appreciated. Thank you. ...

Refresh a webpage content dynamically without the need to reload the entire page

How can I implement YouTube's page navigation system that does not require the entire page to reload when switching pages? Do I need to incorporate Javascript or utilize an API for this functionality? ...

Having trouble sourcing packages from npm or bower for download

After working with npm and bower using my mobile internet connection without any problems, I switched to my university proxy and made changes to the proxy configuration (npm config set proxy). Upon returning to my mobile internet and setting the proxy valu ...

Transmitting HTML markup code

Let's discuss an example with a form that may not be secure or correct: <BODY> <FORM ACTION="" METHOD="post" NAME="test" ID="test"> <INPUT TYPE="text" NAME="testt" VALUE="1"> <INPUT TYPE="reset" VALUE="testtt" onClick="test.s ...

ReactJS - Experiencing an abundance of re-renders in Protected Route

I have recently started working with React and encountered an issue with my Protected routes. They are functioning perfectly on my local machine but throwing errors on the server. You can see the error https://i.sstatic.net/l6dZW.png Below is my code: Pr ...