Skip to content

Commit

Permalink
[GG MR unconed#2] Fix play() working on new slide
Browse files Browse the repository at this point in the history
(Richard Beddington)
  • Loading branch information
unconed committed Dec 16, 2015
1 parent df4f3e4 commit 7de40a0
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 36 deletions.
23 changes: 20 additions & 3 deletions build/mathbox-bundle.js
Original file line number Diff line number Diff line change
Expand Up @@ -61858,14 +61858,16 @@ Play = (function(superClass) {

Play.prototype.init = function() {
Play.__super__.init.apply(this, arguments);
return this.skew = null;
this.skew = null;
return this.start = null;
};

Play.prototype.reset = function(go) {
if (go == null) {
go = true;
}
return this.skew = go ? 0 : null;
this.skew = go ? 0 : null;
return this.start = null;
};

Play.prototype.make = function() {
Expand All @@ -61892,7 +61894,22 @@ Play = (function(superClass) {
var delay, delta, from, now, offset, pace, ratio, realtime, ref, speed, time, to;
ref = _this.props, from = ref.from, to = ref.to, speed = ref.speed, pace = ref.pace, delay = ref.delay, realtime = ref.realtime;
time = parentClock.getTime();
_this.playhead = _this.skew != null ? (now = realtime ? time.time : time.clock, delta = realtime ? time.delta : time.step, ratio = speed / pace, _this.skew += delta * (ratio - 1), offset = Math.max(0, now + _this.skew - delay * ratio), _this.props.loop ? offset = offset % (to - from) : void 0, _this.playhead = Math.min(to, from + offset)) : 0;
if (_this.skew != null) {
now = realtime ? time.time : time.clock;
delta = realtime ? time.delta : time.step;
ratio = speed / pace;
if (_this.start == null) {
_this.start = now;
}
_this.skew += delta * (ratio - 1);
offset = Math.max(0, now - _this.start + _this.skew - delay * ratio);
if (_this.props.loop) {
offset = offset % (to - from);
}
_this.playhead = Math.min(to, from + offset);
} else {
_this.playhead = 0;
}
return _this.update();
};
})(this));
Expand Down
20 changes: 10 additions & 10 deletions build/mathbox-bundle.min.js

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions build/mathbox-core.js
Original file line number Diff line number Diff line change
Expand Up @@ -15173,14 +15173,16 @@ Play = (function(superClass) {

Play.prototype.init = function() {
Play.__super__.init.apply(this, arguments);
return this.skew = null;
this.skew = null;
return this.start = null;
};

Play.prototype.reset = function(go) {
if (go == null) {
go = true;
}
return this.skew = go ? 0 : null;
this.skew = go ? 0 : null;
return this.start = null;
};

Play.prototype.make = function() {
Expand All @@ -15207,7 +15209,22 @@ Play = (function(superClass) {
var delay, delta, from, now, offset, pace, ratio, realtime, ref, speed, time, to;
ref = _this.props, from = ref.from, to = ref.to, speed = ref.speed, pace = ref.pace, delay = ref.delay, realtime = ref.realtime;
time = parentClock.getTime();
_this.playhead = _this.skew != null ? (now = realtime ? time.time : time.clock, delta = realtime ? time.delta : time.step, ratio = speed / pace, _this.skew += delta * (ratio - 1), offset = Math.max(0, now + _this.skew - delay * ratio), _this.props.loop ? offset = offset % (to - from) : void 0, _this.playhead = Math.min(to, from + offset)) : 0;
if (_this.skew != null) {
now = realtime ? time.time : time.clock;
delta = realtime ? time.delta : time.step;
ratio = speed / pace;
if (_this.start == null) {
_this.start = now;
}
_this.skew += delta * (ratio - 1);
offset = Math.max(0, now - _this.start + _this.skew - delay * ratio);
if (_this.props.loop) {
offset = offset % (to - from);
}
_this.playhead = Math.min(to, from + offset);
} else {
_this.playhead = 0;
}
return _this.update();
};
})(this));
Expand Down
18 changes: 9 additions & 9 deletions build/mathbox-core.min.js

Large diffs are not rendered by default.

24 changes: 13 additions & 11 deletions src/primitives/types/present/play.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ class Play extends Track
init: () ->
super
@skew = null
@start = null

reset: (go = true) ->
@skew = if go then 0 else null
@start = null

make: () ->
super
Expand All @@ -29,20 +31,20 @@ class Play extends Track

time = parentClock.getTime()

@playhead =
if @skew?
now = if realtime then time.time else time.clock
delta = if realtime then time.delta else time.step
ratio = speed / pace
if @skew?
now = if realtime then time.time else time.clock
delta = if realtime then time.delta else time.step
ratio = speed / pace

@skew += delta * (ratio - 1)
@start = now if !@start?
@skew += delta * (ratio - 1)

offset = Math.max 0, now + @skew - delay * ratio
offset = offset % (to - from) if @props.loop
offset = Math.max 0, now - @start + @skew - delay * ratio
offset = offset % (to - from) if @props.loop

@playhead = Math.min to, from + offset
else
0
@playhead = Math.min to, from + offset
else
@playhead = 0

@update()

Expand Down

0 comments on commit 7de40a0

Please sign in to comment.