I try to bind events to slider button.
Here is my slider button html:
<input id="swipe" type="range" style="width: 100%">
And here is Javascript function where I try to bind events:
function createMap() {
var swipe = document.getElementById('swipe');
var bing = new ol.layer.Tile({
source: new ol.source.BingMaps({
key: 'My Bing Map sKey',
imagerySet: 'Aerial'
})
});
bing.on('precompose', function (event) {
var ctx = event.context;
var width = ctx.canvas.width * (swipe.value / 100);
ctx.save();
ctx.beginPath();
ctx.rect(width, 0, ctx.canvas.width - width, ctx.canvas.height);
ctx.clip();
});
bing.on('postcompose', function (event) {
var ctx = event.context;
ctx.restore();
});
swipe.addEventListener('input', function () {
map.render();
}, false);
}
As you can see above I have swipe.addEventListener
that have to be triggered whenever I move the slider.
But swipe.addEventListener
does not fire when I move the slider, it seems that event not added.
Any idea why event not added? and how to fix it?
UPDATE
I get this warning whenever I move slider:
The specified value "NaN" is not a valid number. The value must match to the following regular expression: -?(\d+|\d+\.\d+|\.\d+)([eE][-+]?\d+)?