3 Replies Latest reply on Jul 21, 2013 1:10 PM by resdesign

    JQuery width() height() always get stage size instead of div size?

    Jam Zhang Level 1

      I have an Edge project with nested Symbols. In a 3rd level symbol instance, I log it's real size like this.

       

      var stageWidth = $(window).width();

      var w = sym.getSymbolElement().width();

      console.log(w,stageWidth);

       

      When it's in the creationComplete event handler, it shows the right size.

      When it's in the mousemove event handler, it always shows that div size == stage size.

       

      I have tried hours not to find the solution.

      What is this problem?

        • 1. Re: JQuery width() height() always get stage size instead of div size?
          Departure Level 1

          Trying to use logic to locate the problem ( at least trying...)

           

          - if the code is placed in 3rd level, maybe the stageWidth is calculating something else than stage size?

          - if the code is placed in stage maybe the w is not targeting the right element?

          - Does it mean that during the mouseMove the creation has not completed yet? what could be the explanation for the contradictory results here?

          - maybe during mouseMove you are performing some sort of transform or modification on the element, and it makes the width equal to stage size? something to manipulate the w value after its creation?

          - maybe w is not reading the size you are actually interested to read ( like the value of w is equal to stage in reality and this is what shown in mouseMove but interestingly in creationComplete you get unequality. Assuming the  reverse scenario, suspecting the creationComplete results instead)

          - what happens if you replace mousemove to a click event?

           

          hope it helps, i guess this is how sherlock holmes would try to help you. not enough knowledge on creationComplete to find the flaw here...

          • 2. Re: JQuery width() height() always get stage size instead of div size?
            resdesign Adobe Community Professional & MVP

            I create a 135 px rectangle symbol and put a text on the stage to show the rectangle's width with:

             

            var stage = sym.$('Stage');

            var myCreatedSymbol = sym.createChildSymbol("rectSym", stage);

            myCreatedSymbol.getSymbolElement().css ("position", 'fixed');

            myCreatedSymbol.getSymbolElement().css ("left", 250);

            myCreatedSymbol.getSymbolElement().css ("top",  200);

            w = myCreatedSymbol.getSymbolElement().width();

            sym.$('Text').html('Symbol width is: ' + w );

             

             

            width.png

            • 3. Re: JQuery width() height() always get stage size instead of div size?
              resdesign Adobe Community Professional & MVP

              Here is 2 ways of getting the width and the result:

               

              var stage = sym.$('Stage');

              var myCreatedSymbol = sym.createChildSymbol("rectSym", stage);

              myCreatedSymbol.getSymbolElement().css ("position", 'fixed');

              myCreatedSymbol.getSymbolElement().css ("left", 250);

              myCreatedSymbol.getSymbolElement().css ("top",  200);

              w = myCreatedSymbol.getSymbolElement().width();

              x = myCreatedSymbol.getSymbolElement().css('width');

              sym.$('Text3').html('Symbol width is: ' + w  +' with width() and ' + x + 'if you use css.');

               

              width 2.png

              1 person found this helpful