function AnimateLib.TemporaryOnHeartbeat(Y,s,Z,x)local function b(Z)if s>Z then s=s-Z Y(Z)else local Z=s s=0 Y(Z)end end local function J()return s>0 end return AnimateLib.ConditionalOnHeartbeat(b,J,Z,x)end return AnimateLib

function AnimateLib.TemporaryOnHeartbeat(fn, lengthOfTime, yield, callback)
	local function PerfectDT(dt)
		if lengthOfTime > dt then
			lengthOfTime = lengthOfTime - dt;
			fn(dt);
		else
			local t = lengthOfTime;
			lengthOfTime = 0;
			fn(t);
		end
	end
	local function Condition()
		return lengthOfTime > 0;
	end
	return AnimateLib.ConditionalOnHeartbeat(PerfectDT, Condition, yield, callback);
end

return AnimateLib;
