@ -61,11 +61,11 @@ export default function visitWindow(
function $ { handlerName } ( event ) {
function $ { handlerName } ( event ) {
$ { handlerBody }
$ { handlerBody }
} ;
} ;
window . addEventListener ( '${attribute.name}' , $ { handlerName } ) ;
window . addEventListener ( "${attribute.name}" , $ { handlerName } ) ;
` );
` );
block . builders . destroy . addBlock ( deindent `
block . builders . destroy . addBlock ( deindent `
window . removeEventListener ( '${attribute.name}' , $ { handlerName } ) ;
window . removeEventListener ( "${attribute.name}" , $ { handlerName } ) ;
` );
` );
}
}
@ -125,11 +125,11 @@ export default function visitWindow(
function $ { handlerName } ( event ) {
function $ { handlerName } ( event ) {
$ { handlerBody }
$ { handlerBody }
} ;
} ;
window . addEventListener ( '${event}' , $ { handlerName } ) ;
window . addEventListener ( "${event}" , $ { handlerName } ) ;
` );
` );
block . builders . destroy . addBlock ( deindent `
block . builders . destroy . addBlock ( deindent `
window . removeEventListener ( '${event}' , $ { handlerName } ) ;
window . removeEventListener ( "${event}" , $ { handlerName } ) ;
` );
` );
} ) ;
} ) ;
@ -141,10 +141,10 @@ export default function visitWindow(
function $ { observerCallback } ( ) {
function $ { observerCallback } ( ) {
if ( $ { lock } ) return ;
if ( $ { lock } ) return ;
var x = $ { bindings . scrollX
var x = $ { bindings . scrollX
? ` #component.get( '${ bindings . scrollX } ' )`
? ` #component.get( "${ bindings . scrollX } " )`
: ` window.scrollX ` } ;
: ` window.scrollX ` } ;
var y = $ { bindings . scrollY
var y = $ { bindings . scrollY
? ` #component.get( '${ bindings . scrollY } ' )`
? ` #component.get( "${ bindings . scrollY } " )`
: ` window.scrollY ` } ;
: ` window.scrollY ` } ;
window . scrollTo ( x , y ) ;
window . scrollTo ( x , y ) ;
} ;
} ;
@ -152,18 +152,17 @@ export default function visitWindow(
if ( bindings . scrollX )
if ( bindings . scrollX )
block . builders . init . addLine (
block . builders . init . addLine (
` #component.observe( '${ bindings . scrollX } ' , ${ observerCallback } );`
` #component.observe( "${ bindings . scrollX } " , ${ observerCallback } );`
) ;
) ;
if ( bindings . scrollY )
if ( bindings . scrollY )
block . builders . init . addLine (
block . builders . init . addLine (
` #component.observe( '${ bindings . scrollY } ' , ${ observerCallback } );`
` #component.observe( "${ bindings . scrollY } " , ${ observerCallback } );`
) ;
) ;
} else if ( bindings . scrollX || bindings . scrollY ) {
} else if ( bindings . scrollX || bindings . scrollY ) {
const isX = ! ! bindings . scrollX ;
const isX = ! ! bindings . scrollX ;
block . builders . init . addBlock ( deindent `
block . builders . init . addBlock ( deindent `
# component . observe ( ' $ { bindings . scrollX ||
# component . observe ( "${bindings.scrollX || bindings.scrollY}" , function ( $ { isX ? 'x' : 'y' } ) {
bindings . scrollY } ', function ( ${isX ? ' x ' : ' y ' } ) {
if ( $ { lock } ) return ;
if ( $ { lock } ) return ;
window . scrollTo ( $ { isX ? 'x, window.scrollY' : 'window.scrollX, y' } ) ;
window . scrollTo ( $ { isX ? 'x, window.scrollY' : 'window.scrollX, y' } ) ;
} ) ;
} ) ;
@ -177,8 +176,8 @@ export default function visitWindow(
function $ { handlerName } ( event ) {
function $ { handlerName } ( event ) {
# component . set ( { $ { bindings . online } : navigator . onLine } ) ;
# component . set ( { $ { bindings . online } : navigator . onLine } ) ;
} ;
} ;
window . addEventListener ( 'online' , $ { handlerName } ) ;
window . addEventListener ( "online" , $ { handlerName } ) ;
window . addEventListener ( 'offline' , $ { handlerName } ) ;
window . addEventListener ( "offline" , $ { handlerName } ) ;
` );
` );
// add initial value
// add initial value
@ -187,8 +186,8 @@ export default function visitWindow(
) ;
) ;
block . builders . destroy . addBlock ( deindent `
block . builders . destroy . addBlock ( deindent `
window . removeEventListener ( 'online' , $ { handlerName } ) ;
window . removeEventListener ( "online" , $ { handlerName } ) ;
window . removeEventListener ( 'offline' , $ { handlerName } ) ;
window . removeEventListener ( "offline" , $ { handlerName } ) ;
` );
` );
}
}
}
}