How to use the snapsvg.matrix function in snapsvg

To help you get started, we’ve selected a few snapsvg examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github javallone / regexper-static / src / js / parser / javascript.js View on Github external
.then(result => {
        let box = result.getBBox();

        result.transform(Snap.matrix()
          .translate(10 - box.x, 10 - box.y));
        svg.attr({
          width: box.width + 20,
          height: box.height + 20
        });
      })
      // Stop and remove loading indicator after render is totally complete.
github microsoft / PowerBI-visuals-ClusterMap / lib / @uncharted / personas / src / personas.persona.js View on Github external
Persona.prototype.merge = function(target) {
    /* unregister all events */
    this.invalidate();
    /* unhighlight the target */
    target.unhiglightForMerge();
    /* animate the merge */
    var matrix = Snap.matrix();
    matrix.e = target.position.x;
    matrix.f = target.position.y;
    matrix.scale(0);
    this.animate({transform: matrix}, this.mAnimationDurationBase * 2, mina.easein, function() {
        /* since a persona handles its own container, remove it from the DOM */
        this.remove();
        /* if the parent of this persona is set and it has an objects array, remove this persona from it */
        var parent = this.parentNode;
        if (parent && parent.removeObject) {
            parent.removeObject(this);
        }
        /* remove this graphical persona from the data */
        this.mData.graphicalPersona = null;
        /* trigger the merged event */
        this.mEventCenter.publish(Events.merged, this, target);
    }.bind(this));
github javallone / regexper-static / spec / parser / javascript / charset_spec.js View on Github external
it('calculates the anchor based on the partContainer', function() {
      var node = new javascript.Parser('[a]').__consume__charset();

      node.partContainer = jasmine.createSpyObj('partContainer', ['getBBox']);
      node.partContainer.getBBox.and.returnValue({
        cy: 20
      });

      spyOn(node, 'transform').and.returnValue({
        localMatrix: Snap.matrix().translate(3, 8)
      });

      expect(node._anchor).toEqual({
        ay: 28
      });
    });
github javallone / regexper-static / spec / parser / javascript / repeat_spec.js View on Github external
it(`translates to [${t.translate.x}, ${t.translate.y}] when hasLoop is ${t.hasLoop} and hasSkip is ${t.hasSkip}`, function() {
        this.node.hasLoop = t.hasLoop;
        this.node.hasSkip = t.hasSkip;
        expect(this.node.contentPosition).toEqual(Snap.matrix()
          .translate(t.translate.x, t.translate.y));
      });
    });
github javallone / regexper-static / spec / parser / javascript / regexp_spec.js View on Github external
it('creates a container for the match nodes', function() {
      this.node._render();
      expect(this.node.container.group).toHaveBeenCalled();
      expect(this.group.addClass).toHaveBeenCalledWith('regexp-matches');
      expect(this.group.transform).toHaveBeenCalledWith(Snap.matrix()
        .translate(20, 0));
    });
github javallone / regexper-static / spec / parser / javascript / subexp_spec.js View on Github external
it('applies the local transform matrix to the anchor from the regexp', function() {
      var node = new javascript.Parser('(test)').__consume__subexp();

      node.regexp = {
        getBBox() {
          return {
            ax: 10,
            ax2: 15,
            ay: 20
          };
        }
      };

      spyOn(node, 'transform').and.returnValue({
        localMatrix: Snap.matrix().translate(3, 8)
      });

      expect(node._anchor).toEqual({
        ax: 13,
        ax2: 18,
        ay: 28
      });
    });
github javallone / regexper-static / spec / parser / javascript / node_spec.js View on Github external
.then(() => {
            expect(this.content.transform).toHaveBeenCalledWith(Snap.matrix()
              .translate(5, 25));
            done();
          });
      });
github javallone / regexper-static / spec / parser / javascript / match_fragment_spec.js View on Github external
beforeEach(function() {
      this.node = new javascript.Parser('a').__consume__match_fragment();

      this.node.content = {
        getBBox() {
          return {
            ax: 1,
            ax2: 2,
            ay: 3
          };
        }
      };
      spyOn(this.node, 'transform').and.returnValue({
        localMatrix: Snap.matrix().translate(10, 20)
      });
    });
github javallone / regexper-static / spec / parser / javascript / match_spec.js View on Github external
this.node.start = jasmine.createSpyObj('start', ['getBBox']);
      this.node.start.getBBox.and.returnValue({
        x: 1,
        x2: 2,
        cy: 3
      });

      this.node.end = jasmine.createSpyObj('start', ['getBBox']);
      this.node.end.getBBox.and.returnValue({
        x: 4,
        x2: 5,
        cy: 6
      });

      spyOn(this.node, 'transform').and.returnValue({
        localMatrix: Snap.matrix().translate(10, 20)
      });
    });
github javallone / regexper-static / spec / parser / javascript_spec.js View on Github external
.then(() => {
            expect(this.result.transform).toHaveBeenCalledWith(Snap.matrix()
              .translate(6, 8));
            done();
          });
      });

snapsvg

JavaScript Vector Library

Apache-2.0
Latest version published 7 years ago

Package Health Score

58 / 100
Full package analysis

Similar packages