Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix delay and countdown, as well as src 404 error #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/angular/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
/* jshint validthis: true */
var vm = this;
vm.config = {
delay: 2,
delay: 1,
shots: 3,
countdown : 3,
flashFallbackUrl: 'vendors/webcamjs/webcam.swf',
shutterUrl: 'shutter.mp3',
flashNotDetectedText: 'Seu browser não atende os requisitos mínimos para utilização da camera. ' +
Expand Down
33 changes: 18 additions & 15 deletions dist/ng-webcam.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
};

function template(element, attrs) {
return ['<div class="ng-webcam no-overlay" ng-class="{\'no-overlay\' : vm.counter === 0 || vm.config.countdown === 0}">',
'<span ng-show="vm.webcamLive === true && vm.config.countdown > 0 && vm.counter > 0" id="ng-webcam-counter">{{vm.counter}}</span>',
'<img ng-show="vm.webcamLive === true" id="ng-webcam-overlay" src="{{vm.config.overlay}}" />',
return ['<div class="ng-webcam" ng-class="{\'no-overlay\' : vm.counter === 0 || vm.config.countdown === 0}">',
'<span ng-show="vm.webcamLive === true && vm.config.countdown > 0 && vm.counter > 0" id="counter">{{vm.counter}}</span>',
'<img ng-show="vm.webcamLive === true" id="ng-webcam-overlay" ng-src="{{vm.config.overlay}}" />',
'<div id="ng-webcam-container"></div>',
'</div>'].join('');
}
Expand All @@ -63,7 +63,7 @@
var images = [];
vm.webcamLoaded = false;
vm.webcamLive = false;
vm.counter = 3;
vm.counter = 0;
vm.init = init;
vm.destroy = destroy;
/**
Expand Down Expand Up @@ -103,13 +103,13 @@
function init() {
vm.config = vm.config || {};
if(window.localStorage) window.localStorage.setItem('visited', '1');
if(angular.isUndefined(vm.config.viewerWidth)) vm.config.viewerWidth = 'auto';
if(angular.isUndefined(vm.config.viewerHeight)) vm.config.viewerHeight = 'auto';
if(angular.isUndefined(vm.config.viewerWidth)) vm.config.viewerWidth = 320;
if(angular.isUndefined(vm.config.viewerHeight)) vm.config.viewerHeight = 240;
if(angular.isUndefined(vm.config.outputWidth)) vm.config.outputWidth = 320;
if(angular.isUndefined(vm.config.outputHeight)) vm.config.outputHeight = 240;
if(angular.isUndefined(vm.config.delay)) vm.config.delay = 0;
if(angular.isUndefined(vm.config.shots)) vm.config.shots = 1;
if(angular.isUndefined(vm.config.countdown)) vm.config.countdown = 0;
if(angular.isUndefined(vm.config.countdown)){ vm.config.countdown = 0; } else {vm.counter = vm.config.countdown; }
configureListeners();
configure();
}
Expand All @@ -126,7 +126,7 @@
$interval.cancel(countdownTimer);
countdownTimer = undefined;
}
vm.counter = 3;
vm.counter = 0;

}

Expand Down Expand Up @@ -203,28 +203,31 @@
}

function onWebcamCapture() {
if(angular.isUndefined(vm.config.countdown)) {
if(!vm.config.countdown) {
var count = 0;
snapshotTimer = $interval(function() {
capture(count);
count++;
}, (vm.config.delay * 1000), vm.config.shots);
} else {
if(countdownTimer !== undefined) return;
vm.counter = 3;
vm.counter = vm.config.countdown;
countdownTimer = $interval(function() {
vm.counter = vm.counter - 1;
if(vm.counter === 0) {
if(countdownTimer) {
$interval.cancel(countdownTimer);
}
var count = 0;

//snap first
capture(0);
var count = 1;
snapshotTimer = $interval(function() {
capture(count);
count++;
}, (vm.config.delay * 1000), vm.config.shots);
capture(count);
count++;
}, (vm.config.delay * 1000), vm.config.shots - 1);
}
}, 1000, 3);
}, 1000, vm.config.countdown);
}
}

Expand Down
Loading