Aricwithana / LCARS-SDK

A development kit and environment umbrella designed specifically for creating a functional implementation of the LCARS methodology
Other
206 stars 68 forks source link

viewportZoom: Cannot read property 'css' of undefined #10

Closed sfranzyshen closed 5 years ago

sfranzyshen commented 5 years ago

I'm trying to implement viewportZoom. I'm using the example give on the wiki ... but i get the error ... Uncaught TypeError: Cannot read property 'css' of undefined at Object.viewportZoom here is the code where it's being setup ... in my module.js file

{type:'wrapper', id:'wpr_viewport', version:'row', flex:'h', 
    arrive:function(){LCARS.helper.viewportZoom(this.dom, {width:1440, height:1080}); 
        window.addEventListener("resize", function(){LCARS.helper.viewportZoom(this.dom, {width:1440, height:1080});});},

    children:[

and the line(s) in the sdk ...

        viewportZoom:function(object, oArgs){
.......
            object.css('zoom', zoomLevel);

the error(s) only occur during the resize eventListener call ... it works fine when called from the arrive call ... seems this.dom behaves differently depending on who calls it ... a promise or event ...

sfranzyshen commented 5 years ago

full code example ... https://github.com/sfranzyshen/LCARS-SDK-ARCHIVE/blob/gh-pages/19182.4/interfaces/color-generator/module.js

Aricwithana commented 5 years ago

Ah, looks like a 'this' issue since the call is within a parent function. It has to be set via variable instead.

I've updated the wiki to account for it.


        arrive:function(){
            var dom = this.dom;
            LCARS.helper.viewportZoom(dom, {width:1440, height:1080});
            window.addEventListener("resize", function(){
                LCARS.helper.viewportZoom(dom, {width:1440, height:1080}); 
            });
        }

sfranzyshen commented 5 years ago

Once again Brilliant! that did it ;)