I haven’t been able to use wixWindow.WindowSizeInfo, however I’m getting undefined.
import wixWindow from 'wix-window';
$w.onReady(function () {
let size = wixWindow.WindowSizeInfo.window;
console.log(size);
});
I haven’t been able to use wixWindow.WindowSizeInfo, however I’m getting undefined.
import wixWindow from 'wix-window';
$w.onReady(function () {
let size = wixWindow.WindowSizeInfo.window;
console.log(size);
});
Hi Carlos:
This isn’t how to get the windows size info
You need to do the following as shown in the example here: wix-window-frontend - Velo API Reference - Wix.com
import wixWindow from 'wix-window';
// ...
wixWindow.getBoundingRect()
.then( (windowSizeInfo) => {
let windowHeight = windowSizeInfo.window.height;
// 565
let windowWidth = windowSizeInfo.window.width;
// 1269
let documentHeight = windowSizeInfo.document.height;
// 780
let documentWidth = windowSizeInfo.document.width;
// 1269
let scrollX = windowSizeInfo.scroll.x;
// 0
let scrollY = windowSizeInfo.scroll.y;
// 120
} );
Basically you need to get the bounding rectangle and THEN access the windowSizeInfo from the Promise result in the .then() call.
Steve
I’m not good at coding and got stuck while creating a reading progress bar. Can you tell me how can I get the value of the current scroll position so I can assign it to the progress bar value.
// Set the target value as 50
$w('#progressBar').targetValue = 100;
// Set the progress as 20
$w('#progressBar').value = 20;
I want to put the value of current scroll position (scrollY) in place of 20(after calculating the percentage).
Please add your own new post rather than bumping up an old thread from 2018.