//So, my rambling begins
I need to know how long it takes before something happens in the animation pipeline.
This listens to screen size dimensions changing.
//Code but do note that you do need to start it in onReady() and add an element named and hide it.
import wixWindow from ‘wix-window’ ;
let windowHeight = 0 ;
let windowWidth = 0 ;
let windowHeightOld = 0 ;
let windowWidthOld = 0 ;
let delay = 50 ;
let active = true ;
let ticker = wixAnimations . timeline ({
“repeat” : 0 ,
“repeatDelay” : 0 ,
“yoyo” : false
});
function preCalculate ( callback ) {
wixWindow . getBoundingRect ()
. then (( windowSizeInfo ) => {
windowHeight = windowSizeInfo . window . height ;
windowWidth = windowSizeInfo . window . width ;
callback ();
});
}
function onTick ( ){
if ( active === true ){
preCalculate (()=>{
if (( windowWidthOld != windowWidth )||( windowHeightOld != windowHeight )){
//Do something
}
windowWidthOld = windowWidth ;
windowHeightOld = windowHeight ;
});
ticker . add ( $w ( ‘#dummy’ ), { x : “+=1” , easing : ‘easeLinear’ , duration : delay }). play (). onComplete (()=>{
onTick ();
});
}
}
//To enlighten you
I ask because I run into a couple problems and such because my html5 iframe that did this no longer works because of silly changes the browser makers keep making.
Problem is how long it takes before something animates varies per operating system and therefore, timers are not that useful.
So, I want to use something like this but before I start coding away and it is not allowed, I need to know.
Thus me asking.