Skip to content
This repository has been archived by the owner on Jan 14, 2019. It is now read-only.

Commit

Permalink
fix(standard_1): fix spsonsors not resizing when the number of namepl…
Browse files Browse the repository at this point in the history
…ates changed
  • Loading branch information
Alex Van Camp committed Jun 29, 2018
1 parent a1ae127 commit af35803
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 11 deletions.
40 changes: 30 additions & 10 deletions graphics/elements/atoms/atom-gridmask-image/atom-gridmask-image.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,18 @@
const svgDoc = SVG(this);
const mask = svgDoc.mask();
const image = svgDoc.image(this.fallbackSrc);
this.$svg.svgDoc = svgDoc;
this.$svg.image = image;
this.$svg.imageMaskCells = [];

svgDoc.size(ELEMENT_WIDTH, ELEMENT_HEIGHT);
image.size(ELEMENT_WIDTH, ELEMENT_HEIGHT);
image.attr({preserveAspectRatio: this.preserveAspectRatio});

if (this.withBackground) {
const bgRect = svgDoc.rect();
this.$svg.bgRect = bgRect;

bgRect.size(ELEMENT_WIDTH, ELEMENT_HEIGHT);
bgRect.fill({color: 'black', opacity: 0.25});

this.$svg.bgRect = bgRect;

if (STROKE_SIZE > 0) {
bgRect.stroke({
color: 'white',
Expand All @@ -168,11 +166,6 @@
width: STROKE_SIZE * 2
});

// Mirror such that drawSVG anims start from the top right
// and move clockwise to un-draw, counter-clockwise to draw.
bgRect.transform({scaleX: -1, x: ELEMENT_WIDTH});

image.size(ELEMENT_WIDTH - (STROKE_SIZE * 2), ELEMENT_HEIGHT - (STROKE_SIZE * 2));
image.move(STROKE_SIZE, STROKE_SIZE);
}
}
Expand All @@ -192,6 +185,33 @@

image.front();
image.maskWith(mask);

this.resize();
}

resize() {
if (!this._initialized) {
return;
}

const STROKE_SIZE = this.strokeSize;
const ELEMENT_WIDTH = this.clientWidth;
const ELEMENT_HEIGHT = this.clientHeight;

this.$svg.svgDoc.size(ELEMENT_WIDTH, ELEMENT_HEIGHT);
this.$svg.image.size(ELEMENT_WIDTH, ELEMENT_HEIGHT);

if (this.withBackground) {
this.$svg.bgRect.size(ELEMENT_WIDTH, ELEMENT_HEIGHT);

if (STROKE_SIZE > 0) {
// Mirror such that drawSVG anims start from the top right
// and move clockwise to un-draw, counter-clockwise to draw.
this.$svg.bgRect.transform({scaleX: -1, x: ELEMENT_WIDTH});

this.$svg.image.size(ELEMENT_WIDTH - (STROKE_SIZE * 2), ELEMENT_HEIGHT - (STROKE_SIZE * 2));
}
}
}
}

Expand Down
4 changes: 4 additions & 0 deletions graphics/elements/molecules/gdq-sponsors/gdq-sponsors.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@
return tl;
}

resize() {
this.$.image.resize();
}

_showItem(sponsorAsset) {
const tl = new TimelineLite();

Expand Down
3 changes: 2 additions & 1 deletion graphics/standard_1.html
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
</div>
<gdq-timer></gdq-timer>
<div id="sponsorsAndTwitter">
<gdq-sponsors></gdq-sponsors>
<gdq-sponsors id="sponsors"></gdq-sponsors>
<gdq-tweet></gdq-tweet>
</div>
</div>
Expand Down Expand Up @@ -187,6 +187,7 @@

if (newVal.runners.length !== 3 && newVal.runners.length <= 4) {
this.numRunners = newVal.runners.length;
this.$.sponsors.resize();
}
});
}
Expand Down

0 comments on commit af35803

Please sign in to comment.