Commit 3ea25cf6 authored by Tomas Pettersson's avatar Tomas Pettersson 🏸
Browse files

changing speed does not longer alter direction

parent 1c6abb80
......@@ -150,11 +150,6 @@ var L;
Player.prototype.clear = function () {
this.disable();
};
//TODO
// Player: Cannot click in progress bar when playing. Sometimes click are not registered. Try change from onChange to onFinish
// Player: Changing speed while backward play causes forward play
// Player: Both playbuttons are sometimes active at the same time
// Player: Drag handle should be enabled
Player.prototype.addLayout = function () {
var self = this;
self.playerDiv = L.DomUtil.create('div', 'player', self.container);
......@@ -212,24 +207,26 @@ var L;
stopPlay();
var date = moment(data.from * 1000).utc();
self.timeSelect.value = date.format("X");
self.timeDimension.setCurrentTime(date.valueOf());
if (play)
startPlay(steps);
},
onFinish: function (data) {
self.disable();
var date = moment(data.from * 1000).utc();
self.timeDimension.setCurrentTime(date.valueOf());
self.timeSelect.value = date.format("X");
self.timeDimension.setCurrentTime(date.valueOf());
}
});
self.slider = $(timeSliderDiv).data("ionRangeSlider");
self.timeSelect = L.DomUtil.create('select', 'uk-width-4-6 uk-text-bold player-time', timeSelectDiv);
self.timeSelect = L.DomUtil.create('select', 'uk-width-4-6 player-time', timeSelectDiv);
self.updateTimeSelect(self.slider.result.min, self.slider.result.max);
var transitionButton = L.DomUtil.create('button', 'uk-button uk-button-small uk-text-bold uk-width-2-6', timeSelectDiv);
var tachometerIcon = L.DomUtil.create('span', 'uk-icon-tachometer', transitionButton);
var transitionSpeed = 1;
var title = document.createTextNode(' x' + transitionSpeed);
transitionButton.appendChild(title);
transitionButton.title = 'Change play speed';
transitionButton.onclick = function () {
switch (transitionSpeed) {
case 1:
......@@ -242,7 +239,16 @@ var L;
transitionSpeed = 1;
break;
}
self.player.setTransitionTime(self.transitionTime / transitionSpeed);
if (self.player.isPlaying()) {
self.player.pause();
var steps = self.player.getSteps();
self.player.setTransitionTime(self.transitionTime / transitionSpeed);
self.player._steps = steps;
self.player.release();
}
else {
self.player.setTransitionTime(self.transitionTime / transitionSpeed);
}
title = self.replaceText(transitionButton, ' x' + transitionSpeed, title);
};
var timeButtonGroup = L.DomUtil.create('div', 'uk-button-group', controlsDiv);
......@@ -363,7 +369,7 @@ var L;
from: +date.format("X")
});
};
self.timeSelect.value = moment(self.slider.result.from * 1000).valueOf() + '';
self.timeSelect.value = moment(self.slider.result.from).valueOf() + '';
self.timeSelect.onchange = function () {
self.disable();
stopPlay();
......
This diff is collapsed.
/*! leaflet-player-control 2017-04-26 */
/*! leaflet-player-control 2017-05-03 */
var __extends=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])};return function(b,c){function d(){this.constructor=b}a(b,c),b.prototype=null===c?Object.create(c):(d.prototype=c.prototype,new d)}}(),L;!function(a){!function(b){var c=function(b){function c(a){var c=b.call(this,a)||this;return a.domain&&(c.domain=a.domain),c.lang="en",a.lang&&(c.lang=a.lang),a.langdata&&(c.langData=a.langdata),c.display="vertical",a.display&&(c.display=a.display),c.transitionTime=500,a.transitionTime&&(c.transitionTime=a.transitionTime),c.interval=900,a.interval&&(c.interval=a.interval),c.datetimeformat="YYYY-MM-DD HH:mm",c.datetimeformatZ="YYYY-MM-DDTHH:mm:ss[Z]",c}return __extends(c,b),c.prototype.onAdd=function(b){var c=this;return this.container=a.DomUtil.create("div","player-control"),c.langData?c.setup():reqwest({url:"lang/player."+c.lang+".json",method:"get",type:"json",success:function(a){c.langData=a,c.setup()}}),c.disable(),a.DomEvent.disableClickPropagation(this.container),this.container},c.prototype.onRemove=function(a){var b=this;b.player.off("waiting",b.onPlayerWaiting,this)},c.prototype.setup=function(){var b=this;b.addLayout(),b.timeDimension=new a.TimeDimension({times:[]}),b.timeDimension.on("timeload",function(a){b.enable()}),b.player=new a.TimeDimension.Player({transitionTime:b.transitionTime,buffer:15,minBufferReady:10,loop:!0},b.timeDimension),b.player.on("waiting",b.onPlayerWaiting,this)},c.prototype.onPlayerWaiting=function(a){var b=this;b.player.getSteps()>0&&(b.playForwardIcon.classList.remove("uk-icon-pause"),b.playForwardIcon.innerHTML='<span class="player-play-progress">'+Math.floor(a.available/a.buffer*100)+"%</span>"),b.player.getSteps()<0&&(b.playBackwardIcon.classList.remove("uk-icon-pause"),b.playBackwardIcon.innerHTML='<span class="player-play-progress">'+Math.floor(a.available/a.buffer*100)+"%</span>")},c.prototype.getTimeDimension=function(){return this.timeDimension},c.prototype.getCurrentTimeIndex=function(){return this.timeDimension.getCurrentTimeIndex()},c.prototype.setCurrentTimeIndex=function(a){return this.timeDimension.setCurrentTimeIndex(a)},c.prototype.refresh=function(b){var c=this;if(c.timeDimension){for(var d=[],e=[],f=0;f<c.timeDimension._syncedLayers.length;f++){var g=c.timeDimension._syncedLayers[f],h=g.getPlayerTimes();d=a.TimeDimension.Util.union_arrays(h,d),g.forcePlayerTimes()&&(e=a.TimeDimension.Util.union_arrays(h,e))}var i=a.TimeDimension.Util.explodeTimeRange(new Date(d[0]),new Date(d[d.length-1]),"PT15M");e.length>0&&(i=a.TimeDimension.Util.explodeTimeRange(new Date(e[0]),new Date(e[e.length-1]),"PT15M")),c.timeDimension.setAvailableTimes(i,"replace"),c.timeDimension.setCurrentTimeIndex(b&&c.timeIndex||0),this.timeDimension._syncedLayers.length>0?(c.update({date:+moment(c.timeDimension.getCurrentTime()).utc().format("X"),min:+moment(i[0]).utc().format("X"),max:+moment(i[i.length-1]).utc().format("X")}),c.enable()):(c.timeIndex=c.timeDimension.getCurrentTimeIndex(),c.update({date:+moment().utc().startOf("hour").format("X"),min:+moment().utc().startOf("day").subtract(6,"hours").format("X"),max:+moment().utc().startOf("day").add(2,"days").format("X")}),c.clear())}},c.prototype.clear=function(){this.disable()},c.prototype.addLayout=function(){var b=this;b.playerDiv=a.DomUtil.create("div","player",b.container);var c=a.DomUtil.create("div",""),d=a.DomUtil.create("div",""),e=a.DomUtil.create("div",""),f=a.DomUtil.create("div",""),g=!1;"vertical"==b.display?(g=!0,b.playerDiv.classList.add("uk-margin-top"),f.classList.add("uk-margin-top"),c.classList.add("uk-width-1-1"),d.classList.add("uk-width-1-1"),f.classList.add("uk-width-1-1"),b.playerDiv.appendChild(c),b.playerDiv.appendChild(e),b.playerDiv.appendChild(f)):(b.playerDiv.classList.add("player-horizontal-padding"),e.classList.add("player-horizontal"),e.classList.add("uk-width-1-3"),e.classList.add("player-horizontal-timeslider"),c.classList.add("player-horizontal"),c.classList.add("uk-width-1-3"),c.classList.add("player-horizontal-timeselect"),f.classList.add("player-horizontal"),f.classList.add("uk-width-1-3"),f.classList.add("player-horizontal-control"),b.playerDiv.appendChild(f),b.playerDiv.appendChild(c),b.playerDiv.appendChild(e));var d=a.DomUtil.create("div","",e);$(d).ionRangeSlider({type:"single",min:+moment().utc().startOf("day").subtract(6,"hours").format("X"),max:+moment().utc().startOf("day").add(2,"days").format("X"),from:+moment().utc().startOf("hour").format("X"),step:b.interval,grid:g,keyboard:!0,keyboard_step:1,hide_min_max:!0,hide_from_to:!0,force_edges:!0,prettify:function(a){return moment(a,"X").utc().format("YYYY-MM-DD, HH:mm")},onChange:function(a){var c=b.player.isPlaying(),d=b.player.getSteps();c&&s();var e=moment(1e3*a.from).utc();b.timeSelect.value=e.format("X"),c&&t(d)},onFinish:function(a){b.disable();var c=moment(1e3*a.from).utc();b.timeDimension.setCurrentTime(c.valueOf()),b.timeSelect.value=c.format("X")}}),b.slider=$(d).data("ionRangeSlider"),b.timeSelect=a.DomUtil.create("select","uk-width-4-6 uk-text-bold player-time",c),b.updateTimeSelect(b.slider.result.min,b.slider.result.max);var h=a.DomUtil.create("button","uk-button uk-button-small uk-text-bold uk-width-2-6",c),i=(a.DomUtil.create("span","uk-icon-tachometer",h),1),j=document.createTextNode(" x"+i);h.appendChild(j),h.onclick=function(){switch(i){case 1:i=4;break;case 4:i=8;break;case 8:i=1}b.player.setTransitionTime(b.transitionTime/i),j=b.replaceText(h," x"+i,j)};var k=a.DomUtil.create("div","uk-button-group",f),l=a.DomUtil.create("button","uk-button player-button",k),m=(a.DomUtil.create("span","uk-icon-step-backward",l),a.DomUtil.create("button","uk-button player-button",k));b.playBackwardIcon=a.DomUtil.create("span","uk-icon-play player-play-reverse",m);var n=a.DomUtil.create("button","uk-button player-button",k),o=(a.DomUtil.create("span","uk-icon-chevron-left",n),a.DomUtil.create("button","uk-button player-button",k)),p=(a.DomUtil.create("span","uk-icon-chevron-right",o),a.DomUtil.create("button","uk-button player-button",k));b.playForwardIcon=a.DomUtil.create("span","uk-icon-play",p);var q=a.DomUtil.create("button","uk-button player-button",k),r=(a.DomUtil.create("span","uk-icon-step-forward",q),function(a){var c=moment(b.timeDimension.getCurrentTime()).utc();b.timeSelect.value=c.format("X"),b.slider.update({from:+c.format("X")}),b.player.getSteps()>0?(b.playForwardIcon.innerHTML="",b.playForwardIcon.classList.add("uk-icon-pause")):(b.playBackwardIcon.innerHTML="",b.playBackwardIcon.classList.add("uk-icon-pause"))}),s=function(){b.player.isPlaying()&&(b.playBackwardIcon.innerHTML="",b.playForwardIcon.innerHTML="",b.playForwardIcon.classList.remove("uk-icon-pause"),b.playForwardIcon.classList.add("uk-icon-play"),b.playBackwardIcon.classList.remove("uk-icon-pause"),b.playBackwardIcon.classList.add("uk-icon-play"),b.player.stop(),b.timeDimension.off("timeload",r))},t=function(a){a>0?u():v()},u=function(){b.playForwardIcon.classList.remove("uk-icon-play"),b.playForwardIcon.classList.add("uk-icon-pause"),b.player.start(1),b.timeDimension.on("timeload",r)},v=function(){b.playBackwardIcon.classList.remove("uk-icon-play"),b.playBackwardIcon.classList.add("uk-icon-pause"),b.player.start(-1),b.timeDimension.on("timeload",r)};p.onclick=function(){b.player.isPlaying()?s():u()},m.onclick=function(){b.player.isPlaying()?s():v()},l.onclick=function(){b.disable(),s();var a=moment(1e3*b.slider.result.min).utc();b.timeSelect.value=a.format("X"),b.timeDimension.setCurrentTimeIndex(0),b.slider.update({from:+a.format("X")})},n.onclick=function(){b.disable(),s();var a=moment(1e3*b.slider.result.from).subtract(b.interval,"seconds").utc();a<moment(1e3*b.slider.result.min)&&(a=moment(1e3*b.slider.result.min)),b.timeSelect.value=a.format("X"),b.timeDimension.setCurrentTime(a.valueOf()),b.slider.update({from:+a.format("X")})},o.onclick=function(){b.disable(),s();var a=moment(1e3*b.slider.result.from).add(b.interval,"seconds").utc();a>moment(1e3*b.slider.result.max)&&(a=moment(1e3*b.slider.result.max).utc()),b.timeSelect.value=a.format("X"),b.timeDimension.setCurrentTime(a.valueOf()),b.slider.update({from:+a.format("X")})},q.onclick=function(){b.disable(),s();var a=moment(1e3*b.slider.result.max).utc();b.timeSelect.value=a.format("X"),b.timeDimension.setCurrentTimeIndex(b.timeDimension._availableTimes.length-1),b.slider.update({from:+a.format("X")})},b.timeSelect.value=moment(1e3*b.slider.result.from).valueOf()+"",b.timeSelect.onchange=function(){b.disable(),s();var a=moment(1e3*parseInt(b.timeSelect.value)).utc();b.timeDimension.setCurrentTime(a.valueOf()),b.slider.update({from:+a.format("X")})}},c.prototype.replaceText=function(a,b,c){var d=document.createTextNode(b);return a.replaceChild(d,c),d},c.prototype.disable=function(){this.playerDiv.classList.add("player-disable")},c.prototype.enable=function(){this.playerDiv.classList.contains("player-disable")&&this.playerDiv.classList.remove("player-disable")},c.prototype.updateTimeSelect=function(b,c){for(var d=this;d.timeSelect.firstChild;)d.timeSelect.removeChild(d.timeSelect.firstChild);for(var e=b;e<=c;){var f=moment(1e3*e).utc(),g=a.DomUtil.create("option","",d.timeSelect);g.textContent=f.format(d.datetimeformat),g.value=f.format("X")+"",e+=d.interval}},c.prototype.update=function(a){var b=this,c={},d=b.slider.result.min,e=b.slider.result.max;a.min&&(d=a.min),a.max&&(e=a.max),c.min=d,c.max=e,b.updateTimeSelect(d,e),b.timeSelect.value=b.slider.result.from+"",a.date&&(c.from=a.date,b.timeSelect.value=a.date+""),b.slider.update(c)},c.prototype.getDate=function(){return moment(1e3*this.slider.result.from).utc()},c}(a.Control);b.Player=c}(a.Control||(a.Control={}))}(L||(L={}));
var __extends=this&&this.__extends||function(){var a=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(a,b){a.__proto__=b}||function(a,b){for(var c in b)b.hasOwnProperty(c)&&(a[c]=b[c])};return function(b,c){function d(){this.constructor=b}a(b,c),b.prototype=null===c?Object.create(c):(d.prototype=c.prototype,new d)}}(),L;!function(a){!function(b){var c=function(b){function c(a){var c=b.call(this,a)||this;return a.domain&&(c.domain=a.domain),c.lang="en",a.lang&&(c.lang=a.lang),a.langdata&&(c.langData=a.langdata),c.display="vertical",a.display&&(c.display=a.display),c.transitionTime=500,a.transitionTime&&(c.transitionTime=a.transitionTime),c.interval=900,a.interval&&(c.interval=a.interval),c.datetimeformat="YYYY-MM-DD HH:mm",c.datetimeformatZ="YYYY-MM-DDTHH:mm:ss[Z]",c}return __extends(c,b),c.prototype.onAdd=function(b){var c=this;return this.container=a.DomUtil.create("div","player-control"),c.langData?c.setup():reqwest({url:"lang/player."+c.lang+".json",method:"get",type:"json",success:function(a){c.langData=a,c.setup()}}),c.disable(),a.DomEvent.disableClickPropagation(this.container),this.container},c.prototype.onRemove=function(a){var b=this;b.player.off("waiting",b.onPlayerWaiting,this)},c.prototype.setup=function(){var b=this;b.addLayout(),b.timeDimension=new a.TimeDimension({times:[]}),b.timeDimension.on("timeload",function(a){b.enable()}),b.player=new a.TimeDimension.Player({transitionTime:b.transitionTime,buffer:15,minBufferReady:10,loop:!0},b.timeDimension),b.player.on("waiting",b.onPlayerWaiting,this)},c.prototype.onPlayerWaiting=function(a){var b=this;b.player.getSteps()>0&&(b.playForwardIcon.classList.remove("uk-icon-pause"),b.playForwardIcon.innerHTML='<span class="player-play-progress">'+Math.floor(a.available/a.buffer*100)+"%</span>"),b.player.getSteps()<0&&(b.playBackwardIcon.classList.remove("uk-icon-pause"),b.playBackwardIcon.innerHTML='<span class="player-play-progress">'+Math.floor(a.available/a.buffer*100)+"%</span>")},c.prototype.getTimeDimension=function(){return this.timeDimension},c.prototype.getCurrentTimeIndex=function(){return this.timeDimension.getCurrentTimeIndex()},c.prototype.setCurrentTimeIndex=function(a){return this.timeDimension.setCurrentTimeIndex(a)},c.prototype.refresh=function(b){var c=this;if(c.timeDimension){for(var d=[],e=[],f=0;f<c.timeDimension._syncedLayers.length;f++){var g=c.timeDimension._syncedLayers[f],h=g.getPlayerTimes();d=a.TimeDimension.Util.union_arrays(h,d),g.forcePlayerTimes()&&(e=a.TimeDimension.Util.union_arrays(h,e))}var i=a.TimeDimension.Util.explodeTimeRange(new Date(d[0]),new Date(d[d.length-1]),"PT15M");e.length>0&&(i=a.TimeDimension.Util.explodeTimeRange(new Date(e[0]),new Date(e[e.length-1]),"PT15M")),c.timeDimension.setAvailableTimes(i,"replace"),c.timeDimension.setCurrentTimeIndex(b&&c.timeIndex||0),this.timeDimension._syncedLayers.length>0?(c.update({date:+moment(c.timeDimension.getCurrentTime()).utc().format("X"),min:+moment(i[0]).utc().format("X"),max:+moment(i[i.length-1]).utc().format("X")}),c.enable()):(c.timeIndex=c.timeDimension.getCurrentTimeIndex(),c.update({date:+moment().utc().startOf("hour").format("X"),min:+moment().utc().startOf("day").subtract(6,"hours").format("X"),max:+moment().utc().startOf("day").add(2,"days").format("X")}),c.clear())}},c.prototype.clear=function(){this.disable()},c.prototype.addLayout=function(){var b=this;b.playerDiv=a.DomUtil.create("div","player",b.container);var c=a.DomUtil.create("div",""),d=a.DomUtil.create("div",""),e=a.DomUtil.create("div",""),f=a.DomUtil.create("div",""),g=!1;"vertical"==b.display?(g=!0,b.playerDiv.classList.add("uk-margin-top"),f.classList.add("uk-margin-top"),c.classList.add("uk-width-1-1"),d.classList.add("uk-width-1-1"),f.classList.add("uk-width-1-1"),b.playerDiv.appendChild(c),b.playerDiv.appendChild(e),b.playerDiv.appendChild(f)):(b.playerDiv.classList.add("player-horizontal-padding"),e.classList.add("player-horizontal"),e.classList.add("uk-width-1-3"),e.classList.add("player-horizontal-timeslider"),c.classList.add("player-horizontal"),c.classList.add("uk-width-1-3"),c.classList.add("player-horizontal-timeselect"),f.classList.add("player-horizontal"),f.classList.add("uk-width-1-3"),f.classList.add("player-horizontal-control"),b.playerDiv.appendChild(f),b.playerDiv.appendChild(c),b.playerDiv.appendChild(e));var d=a.DomUtil.create("div","",e);$(d).ionRangeSlider({type:"single",min:+moment().utc().startOf("day").subtract(6,"hours").format("X"),max:+moment().utc().startOf("day").add(2,"days").format("X"),from:+moment().utc().startOf("hour").format("X"),step:b.interval,grid:g,keyboard:!0,keyboard_step:1,hide_min_max:!0,hide_from_to:!0,force_edges:!0,prettify:function(a){return moment(a,"X").utc().format("YYYY-MM-DD, HH:mm")},onChange:function(a){var c=b.player.isPlaying(),d=b.player.getSteps();c&&s();var e=moment(1e3*a.from).utc();b.timeSelect.value=e.format("X"),b.timeDimension.setCurrentTime(e.valueOf()),c&&t(d)},onFinish:function(a){b.disable();var c=moment(1e3*a.from).utc();b.timeSelect.value=c.format("X"),b.timeDimension.setCurrentTime(c.valueOf())}}),b.slider=$(d).data("ionRangeSlider"),b.timeSelect=a.DomUtil.create("select","uk-width-4-6 player-time",c),b.updateTimeSelect(b.slider.result.min,b.slider.result.max);var h=a.DomUtil.create("button","uk-button uk-button-small uk-text-bold uk-width-2-6",c),i=(a.DomUtil.create("span","uk-icon-tachometer",h),1),j=document.createTextNode(" x"+i);h.appendChild(j),h.title="Change play speed",h.onclick=function(){switch(i){case 1:i=4;break;case 4:i=8;break;case 8:i=1}if(b.player.isPlaying()){b.player.pause();var a=b.player.getSteps();b.player.setTransitionTime(b.transitionTime/i),b.player._steps=a,b.player.release()}else b.player.setTransitionTime(b.transitionTime/i);j=b.replaceText(h," x"+i,j)};var k=a.DomUtil.create("div","uk-button-group",f),l=a.DomUtil.create("button","uk-button player-button",k),m=(a.DomUtil.create("span","uk-icon-step-backward",l),a.DomUtil.create("button","uk-button player-button",k));b.playBackwardIcon=a.DomUtil.create("span","uk-icon-play player-play-reverse",m);var n=a.DomUtil.create("button","uk-button player-button",k),o=(a.DomUtil.create("span","uk-icon-chevron-left",n),a.DomUtil.create("button","uk-button player-button",k)),p=(a.DomUtil.create("span","uk-icon-chevron-right",o),a.DomUtil.create("button","uk-button player-button",k));b.playForwardIcon=a.DomUtil.create("span","uk-icon-play",p);var q=a.DomUtil.create("button","uk-button player-button",k),r=(a.DomUtil.create("span","uk-icon-step-forward",q),function(a){var c=moment(b.timeDimension.getCurrentTime()).utc();b.timeSelect.value=c.format("X"),b.slider.update({from:+c.format("X")}),b.player.getSteps()>0?(b.playForwardIcon.innerHTML="",b.playForwardIcon.classList.add("uk-icon-pause")):(b.playBackwardIcon.innerHTML="",b.playBackwardIcon.classList.add("uk-icon-pause"))}),s=function(){b.player.isPlaying()&&(b.playBackwardIcon.innerHTML="",b.playForwardIcon.innerHTML="",b.playForwardIcon.classList.remove("uk-icon-pause"),b.playForwardIcon.classList.add("uk-icon-play"),b.playBackwardIcon.classList.remove("uk-icon-pause"),b.playBackwardIcon.classList.add("uk-icon-play"),b.player.stop(),b.timeDimension.off("timeload",r))},t=function(a){a>0?u():v()},u=function(){b.playForwardIcon.classList.remove("uk-icon-play"),b.playForwardIcon.classList.add("uk-icon-pause"),b.player.start(1),b.timeDimension.on("timeload",r)},v=function(){b.playBackwardIcon.classList.remove("uk-icon-play"),b.playBackwardIcon.classList.add("uk-icon-pause"),b.player.start(-1),b.timeDimension.on("timeload",r)};p.onclick=function(){b.player.isPlaying()?s():u()},m.onclick=function(){b.player.isPlaying()?s():v()},l.onclick=function(){b.disable(),s();var a=moment(1e3*b.slider.result.min).utc();b.timeSelect.value=a.format("X"),b.timeDimension.setCurrentTimeIndex(0),b.slider.update({from:+a.format("X")})},n.onclick=function(){b.disable(),s();var a=moment(1e3*b.slider.result.from).subtract(b.interval,"seconds").utc();a<moment(1e3*b.slider.result.min)&&(a=moment(1e3*b.slider.result.min)),b.timeSelect.value=a.format("X"),b.timeDimension.setCurrentTime(a.valueOf()),b.slider.update({from:+a.format("X")})},o.onclick=function(){b.disable(),s();var a=moment(1e3*b.slider.result.from).add(b.interval,"seconds").utc();a>moment(1e3*b.slider.result.max)&&(a=moment(1e3*b.slider.result.max).utc()),b.timeSelect.value=a.format("X"),b.timeDimension.setCurrentTime(a.valueOf()),b.slider.update({from:+a.format("X")})},q.onclick=function(){b.disable(),s();var a=moment(1e3*b.slider.result.max).utc();b.timeSelect.value=a.format("X"),b.timeDimension.setCurrentTimeIndex(b.timeDimension._availableTimes.length-1),b.slider.update({from:+a.format("X")})},b.timeSelect.value=moment(b.slider.result.from).valueOf()+"",b.timeSelect.onchange=function(){b.disable(),s();var a=moment(1e3*parseInt(b.timeSelect.value)).utc();b.timeDimension.setCurrentTime(a.valueOf()),b.slider.update({from:+a.format("X")})}},c.prototype.replaceText=function(a,b,c){var d=document.createTextNode(b);return a.replaceChild(d,c),d},c.prototype.disable=function(){this.playerDiv.classList.add("player-disable")},c.prototype.enable=function(){this.playerDiv.classList.contains("player-disable")&&this.playerDiv.classList.remove("player-disable")},c.prototype.updateTimeSelect=function(b,c){for(var d=this;d.timeSelect.firstChild;)d.timeSelect.removeChild(d.timeSelect.firstChild);for(var e=b;e<=c;){var f=moment(1e3*e).utc(),g=a.DomUtil.create("option","",d.timeSelect);g.textContent=f.format(d.datetimeformat),g.value=f.format("X")+"",e+=d.interval}},c.prototype.update=function(a){var b=this,c={},d=b.slider.result.min,e=b.slider.result.max;a.min&&(d=a.min),a.max&&(e=a.max),c.min=d,c.max=e,b.updateTimeSelect(d,e),b.timeSelect.value=b.slider.result.from+"",a.date&&(c.from=a.date,b.timeSelect.value=a.date+""),b.slider.update(c)},c.prototype.getDate=function(){return moment(1e3*this.slider.result.from).utc()},c}(a.Control);b.Player=c}(a.Control||(a.Control={}))}(L||(L={}));
//# sourceMappingURL=leaflet-player-control.map
\ No newline at end of file
......@@ -150,12 +150,6 @@ var L;
Player.prototype.clear = function () {
this.disable();
};
//TODO
// Player: Changing speed while backward play causes forward play
// Should stop if playing change transition time and then start playing with step to get right direction
// Player: Cannot click in progress bar when playing. Sometimes click are not registered. Try change from onChange to onFinish
// Player: Both playbuttons are sometimes active at the same time
// Player: Drag handle should be enabled
Player.prototype.addLayout = function () {
var self = this;
self.playerDiv = L.DomUtil.create('div', 'player', self.container);
......@@ -225,13 +219,14 @@ var L;
}
});
self.slider = $(timeSliderDiv).data("ionRangeSlider");
self.timeSelect = L.DomUtil.create('select', 'uk-width-4-6 uk-text-bold player-time', timeSelectDiv);
self.timeSelect = L.DomUtil.create('select', 'uk-width-4-6 player-time', timeSelectDiv);
self.updateTimeSelect(self.slider.result.min, self.slider.result.max);
var transitionButton = L.DomUtil.create('button', 'uk-button uk-button-small uk-text-bold uk-width-2-6', timeSelectDiv);
var tachometerIcon = L.DomUtil.create('span', 'uk-icon-tachometer', transitionButton);
var transitionSpeed = 1;
var title = document.createTextNode(' x' + transitionSpeed);
transitionButton.appendChild(title);
transitionButton.title = 'Change play speed';
transitionButton.onclick = function () {
switch (transitionSpeed) {
case 1:
......@@ -244,9 +239,16 @@ var L;
transitionSpeed = 1;
break;
}
console.log(self.player.getSteps());
console.log(self.player.getTransitionTime());
self.player.setTransitionTime(self.player.getSteps() * self.transitionTime / transitionSpeed);
if (self.player.isPlaying()) {
self.player.pause();
var steps = self.player.getSteps();
self.player.setTransitionTime(self.transitionTime / transitionSpeed);
self.player._steps = steps;
self.player.release();
}
else {
self.player.setTransitionTime(self.transitionTime / transitionSpeed);
}
title = self.replaceText(transitionButton, ' x' + transitionSpeed, title);
};
var timeButtonGroup = L.DomUtil.create('div', 'uk-button-group', controlsDiv);
......
This diff is collapsed.
......@@ -173,13 +173,6 @@ export class Player extends L.Control {
this.disable();
}
//TODO
// Player: Changing speed while backward play causes forward play
// Should stop if playing change transition time and then start playing with step to get right direction
// Player: Cannot click in progress bar when playing. Sometimes click are not registered. Try change from onChange to onFinish
// Player: Both playbuttons are sometimes active at the same time
// Player: Drag handle should be enabled
private addLayout() {
var self = this;
self.playerDiv = <HTMLDivElement>L.DomUtil.create('div', 'player', self.container);
......@@ -247,7 +240,7 @@ export class Player extends L.Control {
}
});
self.slider = $(timeSliderDiv).data("ionRangeSlider");
self.timeSelect = <HTMLSelectElement>L.DomUtil.create('select', 'uk-width-4-6 uk-text-bold player-time', timeSelectDiv);
self.timeSelect = <HTMLSelectElement>L.DomUtil.create('select', 'uk-width-4-6 player-time', timeSelectDiv);
self.updateTimeSelect(self.slider.result.min, self.slider.result.max);
var transitionButton = <HTMLButtonElement>L.DomUtil.create('button', 'uk-button uk-button-small uk-text-bold uk-width-2-6', timeSelectDiv);
......@@ -255,6 +248,7 @@ export class Player extends L.Control {
var transitionSpeed = 1;
var title = document.createTextNode(' x'+transitionSpeed);
transitionButton.appendChild(title);
transitionButton.title = 'Change play speed';
transitionButton.onclick = function() {
switch (transitionSpeed) {
case 1:
......@@ -267,9 +261,15 @@ export class Player extends L.Control {
transitionSpeed = 1;
break;
}
console.log(self.player.getSteps());
console.log(self.player.getTransitionTime());
self.player.setTransitionTime(self.player.getSteps()*self.transitionTime/transitionSpeed);
if (self.player.isPlaying()) {
self.player.pause();
var steps = self.player.getSteps();
self.player.setTransitionTime(self.transitionTime/transitionSpeed);
self.player._steps = steps;
self.player.release();
} else {
self.player.setTransitionTime(self.transitionTime/transitionSpeed);
}
title = self.replaceText(transitionButton, ' x'+transitionSpeed, title );
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment