Thank you for reporting this bug. We will make it our priority to review this report.
  1. #1
    Ext JS Premium Member meditecsports's Avatar
    Join Date
    Oct 2010
    Location
    Germany
    Posts
    47
    Vote Rating
    2
    meditecsports is on a distinguished road

      0  

    Default [4.0.5] BUG: Ext.draw.Sprite, setAttributes method, scale,

    [4.0.5] BUG: Ext.draw.Sprite, setAttributes method, scale,


    When calling the setAttributes() method of a sprite and setting the "scale" of it, there is a problem using the center of the scaling specification. Using the properties "cx,cy", as documented will not work. Instead the "centerX/centerY" properties of the underlaying rendering engine do work:

    Code:
    track.setAttributes({
        scale: {centerX: 0, centerY: 0,  // working, but undocumented
                    cx: 0, cy: 0,   // documented, but not working
                    x: 1.3,
                    y: 1.5
        }
    },true);

  2. #2
    Sencha User
    Join Date
    Feb 2008
    Location
    Somewhere on Earth
    Posts
    29
    Vote Rating
    1
    TNTBOB is on a distinguished road

      0  

    Default


    Thanks for the info.
    Been looking all afternoon for this

    Now I need to solve my issue when I click on the image to zoom and it throws the listener 3 times.

  3. #3
    Ext JS Premium Member
    Join Date
    Sep 2009
    Posts
    59
    Vote Rating
    3
    wsi is on a distinguished road

      0  

    Default


    This bug still happens in ExtJS version 4.2.0.179.

    In Ext.draw.Sprite, there is a setAttributes function that saves the scaling changes:
    Code:
                
    setAttributes: function(attrs, redraw) {
      /* other code */
    
            newScaling = attrs.scaling || attrs.scale;
            scaling = spriteAttrs.scaling;
            delete attrs.scale;
            delete attrs.scaling;
            if (newScaling) {
                if (('x' in newScaling && newScaling.x !== scaling.x) ||
                    ('y' in newScaling && newScaling.y !== scaling.y) ||
                    ('cx' in newScaling && newScaling.cx !== scaling.cx) ||
                    ('cy' in newScaling && newScaling.cy !== scaling.cy)) {
                    me.dirtyTransform = true;
                    scaling.x = newScaling.x;
                    scaling.y = newScaling.y;
                    scaling.cx = newScaling.cx;
                    scaling.cy = newScaling.cy;
                }
            }
    
      /* other code */
    }
    Note that only cx and cy are saved.

    Then when the sprites are redrawn, the following code in Ext.draw.Surface is called which only uses centerX and centerY:
    Code:
        scale: function(sprite) {
            var bbox,
                x = sprite.attr.scaling.x || 1,
                y = sprite.attr.scaling.y || 1,
                centerX = sprite.attr.scaling.centerX,
                centerY = sprite.attr.scaling.centerY;
    
    
            if (!Ext.isNumber(centerX) || !Ext.isNumber(centerY)) {
                bbox = this.getBBox(sprite, true);
                centerX = !Ext.isNumber(centerX) ? bbox.x + bbox.width / 2 : centerX;
                centerY = !Ext.isNumber(centerY) ? bbox.y + bbox.height / 2 : centerY;
            }
            sprite.transformations.push({
                type: "scale",
                x: x,
                y: y,
                centerX: centerX,
                centerY: centerY
            });
        },

Thread Participants: 2