Community X.

Connect with other creators, share ideas, give feedback and get the latest product updates.

Jul 13

Run code depending breakpoints

Dear All,

Is there a way to run a code depending the breakpoints?

For example:


export function button1_click(event) {
 
    if breakpoint is greater than 1001 {
       do this code#1
    } else if breakpoint is between 751 and 1000 {
       do this code#2
    } else if breakpoint is smaller than 750 {
       do this code#3
    } 
 
}
 

Thank you for your help.

Best regards,

Domivax

Hi @domivax


This is a great suggestion and is something that we plan on implementing in the future.


Currently, it is possible to run code on a specific screen size ranges, by using the "wix-window" api.


You can get the current screen size and create a logic for when to run the code.


More info: https://www.wix.com/corvid/new-reference/wix-window/getboundingrect


Please let us know if you have questions.


For specific questions regarding writing the code we recommend that you contact our Corvid experts at https://www.wix.com/corvid/forum

Jul 14

Thank you @Sebi for your reply.


getBoundingRect works very well. Below my final code.


Best regards,

Domivax


 wixWindow.getBoundingRect()
     .then((windowSizeInfo) => {
     let windowWidth = windowSizeInfo.window.width;
     if (windowWidth <= 1000) {
         $w("#TextTest").text = "less or equal than 1000"
    } else if (windowWidth > 1000) {
         $w("#TextTest").text = "more than 1000"
    }
});

Editor X

Design your boldest creations.