mirror of
https://github.com/frontendnetwork/vegancheck.me
synced 2024-11-10 06:24:13 +00:00
Out-Animation fadeOut
on camera-view
This commit is contained in:
parent
c78307c126
commit
97a90e411c
1 changed files with 26 additions and 8 deletions
34
js/app.js
34
js/app.js
|
@ -20,28 +20,46 @@ function setupLiveReader(resultElement) {
|
|||
BarcodeScanner.init()
|
||||
var closer = document.getElementById('controls')
|
||||
closer.style.display = 'inline-block'
|
||||
|
||||
// When barcode is detected
|
||||
BarcodeScanner.streamCallback = function(result) {
|
||||
document.getElementById('barcode').value = result[0].Value
|
||||
BarcodeScanner.StopStreamDecode()
|
||||
video.pause()
|
||||
stream.getTracks()[0].stop()
|
||||
container.style.display = 'none'
|
||||
closer.style.display = 'none';
|
||||
container.classList.add('fadeOut')
|
||||
closer.classList.add('fadeOut')
|
||||
setTimeout(function() {
|
||||
container.classList.remove('fadeOut')
|
||||
closer.classList.remove('fadeOut')
|
||||
container.style.display = 'none'
|
||||
closer.style.display = 'none'
|
||||
BarcodeScanner.StopStreamDecode()
|
||||
video.pause()
|
||||
}, 1000);
|
||||
|
||||
// Auto submit barcode
|
||||
document.getElementsByTagName('button')[0].click();
|
||||
}
|
||||
|
||||
// Close stream when button is clicked
|
||||
closer.onclick = function(close) {
|
||||
BarcodeScanner.StopStreamDecode()
|
||||
video.pause()
|
||||
stream.getTracks()[0].stop()
|
||||
container.style.display = 'none'
|
||||
closer.style.display = 'none';
|
||||
container.classList.add('fadeOut')
|
||||
closer.classList.add('fadeOut')
|
||||
setTimeout(function() {
|
||||
container.classList.remove('fadeOut')
|
||||
closer.classList.remove('fadeOut')
|
||||
container.style.display = 'none'
|
||||
closer.style.display = 'none'
|
||||
BarcodeScanner.StopStreamDecode()
|
||||
video.pause()
|
||||
}, 1000);
|
||||
}
|
||||
|
||||
video.setAttribute('autoplay', '')
|
||||
video.setAttribute('playsinline', '')
|
||||
video.setAttribute('style', 'width: 100%; height: 100%;')
|
||||
video.srcObject = stream
|
||||
|
||||
container.appendChild(video)
|
||||
video.onloadedmetadata = function(e) {
|
||||
video.play()
|
||||
|
|
Loading…
Reference in a new issue