mirror of
https://github.com/serratus/quaggaJS.git
synced 2026-08-12 21:21:42 +08:00
Added fake zoom to live-example
This commit is contained in:
@@ -88,6 +88,14 @@
|
|||||||
<select name="input-stream_constraints" id="deviceSelection">
|
<select name="input-stream_constraints" id="deviceSelection">
|
||||||
</select>
|
</select>
|
||||||
</label>
|
</label>
|
||||||
|
<label>
|
||||||
|
<span>Zoom</span>
|
||||||
|
<select name="input-stream_constraints">
|
||||||
|
<option selected="selected" value="1">1x</option>
|
||||||
|
<option value="1.5">1.5x</option>
|
||||||
|
<option value="2">2x</option>
|
||||||
|
</select>
|
||||||
|
</label>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</div>
|
</div>
|
||||||
<div id="result_strip">
|
<div id="result_strip">
|
||||||
|
|||||||
+15
-11
@@ -116,7 +116,7 @@ $(function() {
|
|||||||
},
|
},
|
||||||
setState: function(path, value) {
|
setState: function(path, value) {
|
||||||
if (typeof this._accessByPath(this.inputMapper, path) === "function") {
|
if (typeof this._accessByPath(this.inputMapper, path) === "function") {
|
||||||
value = this._accessByPath(this.inputMapper, path)(value);
|
value = this._accessByPath(this.inputMapper, path)(value, this.state);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._accessByPath(this.state, path, value);
|
this._accessByPath(this.state, path, value);
|
||||||
@@ -134,24 +134,30 @@ $(function() {
|
|||||||
},
|
},
|
||||||
inputMapper: {
|
inputMapper: {
|
||||||
inputStream: {
|
inputStream: {
|
||||||
constraints: function(value){
|
constraints: function(value, state){
|
||||||
if (/^(\d+)x(\d+)$/.test(value)) {
|
if (/^(\d+)x(\d+)$/.test(value)) {
|
||||||
var values = value.split('x');
|
var values = value.split('x');
|
||||||
return {
|
return {
|
||||||
landscape: {
|
landscape: Object.assign({}, state.inputStream.constraints.landscape, {
|
||||||
width: {ideal: parseInt(values[0])},
|
width: {ideal: parseInt(values[0])},
|
||||||
height: {ideal: parseInt(values[1])},
|
height: {ideal: parseInt(values[1])},
|
||||||
zoom: 1.5,
|
}),
|
||||||
},
|
portrait: Object.assign({}, state.inputStream.constraints.portrait, {
|
||||||
portrait: {
|
|
||||||
width: {ideal: parseInt(values[0])},
|
width: {ideal: parseInt(values[0])},
|
||||||
height: {ideal: parseInt(values[0])},
|
height: {ideal: parseInt(values[0])},
|
||||||
zoom: 1.5,
|
}),
|
||||||
aspectRatio: 1,
|
|
||||||
},
|
|
||||||
width: {ideal: parseInt(values[0])},
|
width: {ideal: parseInt(values[0])},
|
||||||
height: {ideal: parseInt(values[1])}
|
height: {ideal: parseInt(values[1])}
|
||||||
};
|
};
|
||||||
|
} else if (/^(\d+)\.?(\d+)?$/.test(value)) {
|
||||||
|
return Object.assign({}, state.inputStream.constraints, {
|
||||||
|
landscape: Object.assign({}, state.inputStream.constraints.landscape, {
|
||||||
|
zoom: {ideal: parseFloat(value)},
|
||||||
|
}),
|
||||||
|
portrait: Object.assign({}, state.inputStream.constraints.portrait, {
|
||||||
|
zoom: {ideal: parseFloat(value)},
|
||||||
|
}),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
deviceId: value
|
deviceId: value
|
||||||
@@ -190,12 +196,10 @@ $(function() {
|
|||||||
landscape: {
|
landscape: {
|
||||||
width: {ideal: 640},
|
width: {ideal: 640},
|
||||||
height: {ideal: 480},
|
height: {ideal: 480},
|
||||||
zoom: 1.5,
|
|
||||||
},
|
},
|
||||||
portrait: {
|
portrait: {
|
||||||
width: {ideal: 640},
|
width: {ideal: 640},
|
||||||
height: {ideal: 640},
|
height: {ideal: 640},
|
||||||
zoom: 1.5,
|
|
||||||
aspectRatio: 1,
|
aspectRatio: 1,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user