Skip to content

Commit d736b82

Browse files
committed
using snap instead of hard
1 parent a811c56 commit d736b82

File tree

8 files changed

+27
-30
lines changed

8 files changed

+27
-30
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,4 @@ bower_components
22
node_modules
33
demos/audio
44
dist/images
5+
/*.gif

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Causes the GIF to expand to cover its container, like if you had used `backgroun
3434
`n-times="3.0"` (speed mode only)
3535
Stops playback (by adding the attribute `stopped`) after a set number of times. Can be fractional e.g. `0.9` will play the first 90% of the GIF then stop. Removing the `stopped` attribute will restart the playback.
3636

37-
`hard` (sync & bpm modes only)
37+
`snap` (sync & bpm modes only)
3838
Instead of allowing longer GIFs to sync to multiple beats, force them to fit into only one.
3939

4040
`ping-pong`
@@ -75,12 +75,12 @@ Breaks the GIF across 1 or more _beats_ (depending on how long the GIF is), wher
7575
<x-gif src="something_dumb_from_buzzfeed.gif" bpm="120"></x-gif>
7676
```
7777

78-
### Hard-bpm
78+
### snap-bpm
7979

8080
Just like `bpm` but locks all GIFs to one _beat_, regardless of how long they were originally.
8181

8282
```html
83-
<x-gif src="something_dumb_from_buzzfeed.gif" hard-bpm="120"></x-gif>
83+
<x-gif src="something_dumb_from_buzzfeed.gif" snap-bpm="120"></x-gif>
8484
```
8585

8686
### Stopped

dist/x-gif.angular.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2113,7 +2113,7 @@ var $__default = (function() {
21132113
this.pingPong = opts.pingPong;
21142114
this.fill = opts.fill;
21152115
this.stopped = opts.stopped;
2116-
this.hard = opts.hard;
2116+
this.snap = opts.snap;
21172117
this.ready = new Promise((function(resolve, reject) {
21182118
var exploder = new Exploder(file);
21192119
exploder.load().then((function(gif) {
@@ -2173,7 +2173,7 @@ var $__default = (function() {
21732173
},
21742174
fromClock: function(beatNr, beatDuration, beatFraction) {
21752175
var speedup = 1.5,
2176-
lengthInBeats = this.hard ? 1 : Math.max(1, Math.round((1 / speedup) * 10 * this.gif.length / beatDuration)),
2176+
lengthInBeats = this.snap ? 1 : Math.max(1, Math.round((1 / speedup) * 10 * this.gif.length / beatDuration)),
21772177
subBeat = beatNr % lengthInBeats,
21782178
repeatCount = beatNr / lengthInBeats,
21792179
subFraction = (beatFraction / lengthInBeats) + subBeat / lengthInBeats;

dist/x-gif.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2116,7 +2116,7 @@ var $__default = (function() {
21162116
this.pingPong = opts.pingPong;
21172117
this.fill = opts.fill;
21182118
this.stopped = opts.stopped;
2119-
this.hard = opts.hard;
2119+
this.snap = opts.snap;
21202120
this.ready = new Promise((function(resolve, reject) {
21212121
var exploder = new Exploder(file);
21222122
exploder.load().then((function(gif) {
@@ -2176,7 +2176,7 @@ var $__default = (function() {
21762176
},
21772177
fromClock: function(beatNr, beatDuration, beatFraction) {
21782178
var speedup = 1.5,
2179-
lengthInBeats = this.hard ? 1 : Math.max(1, Math.round((1 / speedup) * 10 * this.gif.length / beatDuration)),
2179+
lengthInBeats = this.snap ? 1 : Math.max(1, Math.round((1 / speedup) * 10 * this.gif.length / beatDuration)),
21802180
subBeat = beatNr % lengthInBeats,
21812181
repeatCount = beatNr / lengthInBeats,
21822182
subFraction = (beatFraction / lengthInBeats) + subBeat / lengthInBeats;

dist/x-gif.raw.js

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2034,10 +2034,9 @@ var XGifController = function XGifController(xgif) {
20342034
if (this.playback)
20352035
this.playback.changeBpm(bpm);
20362036
},
2037-
hardChanged: function(hard) {
2038-
console.log("TURN DOWN");
2037+
snapChanged: function(snap) {
20392038
if (this.playback)
2040-
this.playback.hard = hard;
2039+
this.playback.snap = snap;
20412040
},
20422041
stoppedChanged: function(nowStop) {
20432042
if (this.playback) {
@@ -2094,7 +2093,7 @@ var $XGif = XGif;
20942093
stopped: this.hasAttribute('stopped'),
20952094
fill: this.hasAttribute('fill'),
20962095
nTimes: isNaN(maybeNtimes) ? null : maybeNtimes,
2097-
hard: this.hasAttribute('hard'),
2096+
snap: this.hasAttribute('snap'),
20982097
pingPong: this.hasAttribute('ping-pong')
20992098
};
21002099
},
@@ -2113,10 +2112,9 @@ var $XGif = XGif;
21132112
} else if (attribute == "ping-pong") {
21142113
this.determinePlaybackOptions();
21152114
this.controller.pingPongChanged(this.options.pingPong);
2116-
} else if (attribute == "hard") {
2117-
console.log("TURN DOWN");
2115+
} else if (attribute == "snap") {
21182116
this.determinePlaybackOptions();
2119-
this.controller.hardChanged(this.options.hard);
2117+
this.controller.snapChanged(this.options.snap);
21202118
}
21212119
},
21222120
clock: function(beatNr, beatDuration, beatFraction) {
@@ -2191,7 +2189,7 @@ var $__default = (function() {
21912189
this.pingPong = opts.pingPong;
21922190
this.fill = opts.fill;
21932191
this.stopped = opts.stopped;
2194-
this.hard = opts.hard;
2192+
this.snap = opts.snap;
21952193
this.ready = new Promise((function(resolve, reject) {
21962194
var exploder = new Exploder(file);
21972195
exploder.load().then((function(gif) {
@@ -2251,7 +2249,7 @@ var $__default = (function() {
22512249
},
22522250
fromClock: function(beatNr, beatDuration, beatFraction) {
22532251
var speedup = 1.5,
2254-
lengthInBeats = this.hard ? 1 : Math.max(1, Math.round((1 / speedup) * 10 * this.gif.length / beatDuration)),
2252+
lengthInBeats = this.snap ? 1 : Math.max(1, Math.round((1 / speedup) * 10 * this.gif.length / beatDuration)),
22552253
subBeat = beatNr % lengthInBeats,
22562254
repeatCount = beatNr / lengthInBeats,
22572255
subFraction = (beatFraction / lengthInBeats) + subBeat / lengthInBeats;

index.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -115,11 +115,11 @@ <h3>BPM</h3>
115115
</label>
116116
<x-gif ng-src="{{ trustedUrl() }}" bpm="{{ gif.bpm }}"></x-gif>
117117
<figcaption>
118-
<pre>&lt;x-gif src="{{ trustedUrl() }}" bpm="{{ gif.bpm }}" &gt;&lt;/x-gif&gt;</pre>
118+
<pre>&lt;x-gif src="{{ trustedUrl() }}" bpm="{{ gif.bpm }}"&gt;&lt;/x-gif&gt;</pre>
119119
</figcaption>
120-
<x-gif ng-src="{{ trustedUrl() }}" bpm="{{ gif.bpm }}" hard></x-gif>
120+
<x-gif ng-src="{{ trustedUrl() }}" bpm="{{ gif.bpm }}" snap></x-gif>
121121
<figcaption>
122-
<pre>&lt;x-gif src="{{ trustedUrl() }}" bpm="{{ gif.bpm }}" hard&gt;&lt;/x-gif&gt;</pre>
122+
<pre>&lt;x-gif src="{{ trustedUrl() }}" bpm="{{ gif.bpm }}" snap&gt;&lt;/x-gif&gt;</pre>
123123
</figcaption>
124124
</figure>
125125

@@ -139,9 +139,9 @@ <h3>Synced to Audio</h3>
139139
<figcaption>
140140
<pre>&lt;x-gif src="{{ trustedUrl() }}" synced&gt;&lt;/x-gif&gt;</pre>
141141
</figcaption>
142-
<x-gif class="x-gif-synced-demo" ng-src="{{ trustedUrl() }}" sync hard></x-gif>
142+
<x-gif class="x-gif-synced-demo" ng-src="{{ trustedUrl() }}" sync snap></x-gif>
143143
<figcaption>
144-
<pre>&lt;x-gif src="{{ trustedUrl() }}" synced hard&gt;&lt;/x-gif&gt;</pre>
144+
<pre>&lt;x-gif src="{{ trustedUrl() }}" synced snap&gt;&lt;/x-gif&gt;</pre>
145145
<p>
146146
Audio: Encom Part II by Daft Punk. CC0 1.0 Universal.
147147
<br/>

src/playback.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default class Playback {
2121
this.pingPong = opts.pingPong;
2222
this.fill = opts.fill;
2323
this.stopped = opts.stopped;
24-
this.hard = opts.hard;
24+
this.snap = opts.snap;
2525

2626
this.ready = new Promise((resolve, reject) => {
2727
var exploder = new Exploder(file)
@@ -91,7 +91,7 @@ export default class Playback {
9191
fromClock(beatNr, beatDuration, beatFraction) {
9292
// Always bias GIFs to speeding up rather than slowing down, it looks better.
9393
var speedup = 1.5,
94-
lengthInBeats = this.hard ? 1 : Math.max(1, Math.round((1 / speedup) * 10 * this.gif.length / beatDuration)),
94+
lengthInBeats = this.snap ? 1 : Math.max(1, Math.round((1 / speedup) * 10 * this.gif.length / beatDuration)),
9595
subBeat = beatNr % lengthInBeats,
9696
repeatCount = beatNr / lengthInBeats,
9797
subFraction = (beatFraction / lengthInBeats) + subBeat / lengthInBeats;

src/x-gif.raw.js

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,8 @@ class XGifController {
4141
if (this.playback) this.playback.changeBpm(bpm);
4242
}
4343

44-
hardChanged(hard) {
45-
console.log("TURN DOWN")
46-
if (this.playback) this.playback.hard = hard;
44+
snapChanged(snap) {
45+
if (this.playback) this.playback.snap = snap;
4746
}
4847

4948
stoppedChanged(nowStop) {
@@ -108,7 +107,7 @@ class XGif extends HTMLElement {
108107
stopped: this.hasAttribute('stopped'),
109108
fill: this.hasAttribute('fill'),
110109
nTimes: isNaN(maybeNtimes) ? null : maybeNtimes,
111-
hard: this.hasAttribute('hard'),
110+
snap: this.hasAttribute('snap'),
112111
pingPong: this.hasAttribute('ping-pong')
113112
}
114113
}
@@ -128,10 +127,9 @@ class XGif extends HTMLElement {
128127
} else if (attribute == "ping-pong") {
129128
this.determinePlaybackOptions();
130129
this.controller.pingPongChanged(this.options.pingPong);
131-
} else if (attribute == "hard") {
132-
console.log("TURN DOWN")
130+
} else if (attribute == "snap") {
133131
this.determinePlaybackOptions();
134-
this.controller.hardChanged(this.options.hard);
132+
this.controller.snapChanged(this.options.snap);
135133
}
136134
}
137135

0 commit comments

Comments
 (0)